refactor
This commit is contained in:
155
modules/home/devtools/neovim/default.nix
Normal file
155
modules/home/devtools/neovim/default.nix
Normal file
@@ -0,0 +1,155 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf mkEnableOption;
|
||||
cfg = config.home.devtools.neovim;
|
||||
in {
|
||||
imports = [
|
||||
./plugins
|
||||
./lsp.nix
|
||||
./syntaxes.nix
|
||||
./keybindings.nix
|
||||
];
|
||||
|
||||
options = {
|
||||
home.devtools.neovim.enable = mkEnableOption "Enable neovim";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
programs.neovim = {
|
||||
enable = true;
|
||||
extraLuaConfig =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
-- Use system clipboard
|
||||
vim.opt.clipboard = "unnamedplus"
|
||||
|
||||
-- Colorscheme
|
||||
vim.cmd("colorscheme gruvbox-material")
|
||||
|
||||
-- Line Numbers and Cursorline
|
||||
vim.opt.number = true
|
||||
vim.opt.cursorline = true
|
||||
vim.wo.relativenumber = false
|
||||
|
||||
-- Nerd Font
|
||||
vim.g.have_nerd_font = true
|
||||
|
||||
-- Enable persistent undo
|
||||
vim.opt.undofile = true
|
||||
vim.opt.undodir = vim.fn.expand("~/.config/nvim/undo")
|
||||
|
||||
-- Set wildcharm to tab for triggering completion
|
||||
vim.opt.wildcharm = vim.fn.char2nr(vim.api.nvim_replace_termcodes("<Tab>", true, true, true))
|
||||
|
||||
-- Folding
|
||||
vim.opt.foldmethod = "manual"
|
||||
vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()"
|
||||
-- vim.opt.foldexpr = "v:lua.vim.treesitter.foldtext()"
|
||||
|
||||
-- Tabs
|
||||
vim.opt.tabstop = 4
|
||||
vim.opt.expandtab = true
|
||||
vim.opt.softtabstop = 0
|
||||
vim.opt.shiftwidth = 0
|
||||
|
||||
-- 2 char-wide overrides for specific file types
|
||||
vim.api.nvim_create_augroup("two_space_tab", { clear = true })
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "json", "html", "htmldjango", "hamlet", "nix", "scss", "typescript", "php", "haskell", "terraform" },
|
||||
command = "setlocal tabstop=2",
|
||||
group = "two_space_tab",
|
||||
})
|
||||
|
||||
-- Set tera to use htmldjango syntax
|
||||
vim.api.nvim_create_augroup("tera_htmldjango", { clear = true })
|
||||
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
|
||||
pattern = "*.tera",
|
||||
command = "setfiletype htmldjango",
|
||||
group = "tera_htmldjango",
|
||||
})
|
||||
|
||||
-- Options when composing mutt mail
|
||||
vim.api.nvim_create_augroup("mail_settings", { clear = true })
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "mail",
|
||||
command = "set noautoindent wrapmargin=0 textwidth=0 linebreak wrap formatoptions+=w",
|
||||
group = "mail_settings",
|
||||
})
|
||||
|
||||
-- Fix nvim size according to terminal
|
||||
vim.api.nvim_create_augroup("fix_size", { clear = true })
|
||||
vim.api.nvim_create_autocmd("VimEnter", {
|
||||
pattern = "*",
|
||||
command = "silent exec '!kill -s SIGWINCH' getpid()",
|
||||
group = "fix_size",
|
||||
})
|
||||
|
||||
-- Highlight when yanking (copying) text
|
||||
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||
desc = "Highlight when yanking (copying) text",
|
||||
group = vim.api.nvim_create_augroup("kickstart-highlight-yank", { clear = true }),
|
||||
callback = function()
|
||||
vim.highlight.on_yank()
|
||||
end,
|
||||
})
|
||||
|
||||
-- Diagnostic signs
|
||||
function add_sign(name, text)
|
||||
vim.fn.sign_define(name, { text = text, texthl = name, numhl = name })
|
||||
end
|
||||
|
||||
add_sign("DiagnosticSignError", " ")
|
||||
add_sign("DiagnosticSignWarn", " ")
|
||||
add_sign("DiagnosticSignHint", " ")
|
||||
add_sign("DiagnosticSignInfo", " ")
|
||||
|
||||
'';
|
||||
|
||||
plugins = with pkgs.vimPlugins; [
|
||||
vim-table-mode
|
||||
editorconfig-nvim
|
||||
vim-surround
|
||||
gruvbox-material-nvim
|
||||
];
|
||||
};
|
||||
|
||||
xdg.desktopEntries = {
|
||||
nvim = {
|
||||
name = "Neovim";
|
||||
genericName = "Text Editor";
|
||||
comment = "Edit text files";
|
||||
exec = "nvim %F";
|
||||
icon = "nvim";
|
||||
mimeType = [
|
||||
"text/english"
|
||||
"text/plain"
|
||||
"text/x-makefile"
|
||||
"text/x-c++hdr"
|
||||
"text/x-c++src"
|
||||
"text/x-chdr"
|
||||
"text/x-csrc"
|
||||
"text/x-java"
|
||||
"text/x-moc"
|
||||
"text/x-pascal"
|
||||
"text/x-tcl"
|
||||
"text/x-tex"
|
||||
"application/x-shellscript"
|
||||
"text/x-c"
|
||||
"text/x-c++"
|
||||
];
|
||||
terminal = true;
|
||||
type = "Application";
|
||||
categories = [
|
||||
"Utility"
|
||||
"TextEditor"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
79
modules/home/devtools/neovim/keybindings.nix
Normal file
79
modules/home/devtools/neovim/keybindings.nix
Normal file
@@ -0,0 +1,79 @@
|
||||
{
|
||||
config = {
|
||||
programs.neovim = {
|
||||
extraLuaConfig =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
-- Key mappings for various commands and navigation
|
||||
vim.api.nvim_set_keymap("n", "<C-j>", "<C-e>", { noremap = true })
|
||||
vim.api.nvim_set_keymap("n", "<C-k>", "<C-y>", { noremap = true })
|
||||
|
||||
-- Buffers
|
||||
vim.api.nvim_set_keymap("n", "<space>b", ":buffers<CR>", { noremap = true })
|
||||
vim.api.nvim_set_keymap("n", "<C-l>", ":bnext<CR>", { noremap = true })
|
||||
vim.api.nvim_set_keymap("n", "<C-h>", ":bprev<CR>", { noremap = true })
|
||||
vim.api.nvim_set_keymap("n", "<C-q>", ":bdel<CR>", { noremap = true })
|
||||
|
||||
-- Navigation
|
||||
vim.api.nvim_set_keymap("n", "<space>e", ":e<space>", { noremap = true })
|
||||
vim.api.nvim_set_keymap("n", "<space>E", ":e %:h<tab>", { noremap = true })
|
||||
vim.api.nvim_set_keymap("n", "<space>c", ":cd<space>", { noremap = true })
|
||||
vim.api.nvim_set_keymap("n", "<space>C", ":cd %:h<tab>", { noremap = true })
|
||||
|
||||
-- Loclist
|
||||
vim.api.nvim_set_keymap("n", "<space>l", ":lwindow<cr>", { noremap = true })
|
||||
vim.api.nvim_set_keymap("n", "[l", ":lprev<cr>", { noremap = true })
|
||||
vim.api.nvim_set_keymap("n", "]l", ":lnext<cr>", { noremap = true })
|
||||
vim.api.nvim_set_keymap("n", "<space>L", ":lhistory<cr>", { noremap = true })
|
||||
vim.api.nvim_set_keymap("n", "[L", ":lolder<cr>", { noremap = true })
|
||||
vim.api.nvim_set_keymap("n", "]L", ":lnewer<cr>", { noremap = true })
|
||||
|
||||
-- Quickfix
|
||||
vim.api.nvim_set_keymap("n", "<space>q", ":cwindow<cr>", { noremap = true })
|
||||
vim.api.nvim_set_keymap("n", "[q", ":cprev<cr>", { noremap = true })
|
||||
vim.api.nvim_set_keymap("n", "]q", ":cnext<cr>", { noremap = true })
|
||||
vim.api.nvim_set_keymap("n", "<space>Q", ":chistory<cr>", { noremap = true })
|
||||
vim.api.nvim_set_keymap("n", "[Q", ":colder<cr>", { noremap = true })
|
||||
vim.api.nvim_set_keymap("n", "]Q", ":cnewer<cr>", { noremap = true })
|
||||
|
||||
-- Make
|
||||
vim.api.nvim_set_keymap("n", "<space>m", ":make<cr>", { noremap = true })
|
||||
|
||||
-- Grep (replace with ripgrep)
|
||||
vim.api.nvim_set_keymap("n", "<space>g", ":grep<space>", { noremap = true })
|
||||
if vim.fn.executable("rg") == 1 then
|
||||
vim.opt.grepprg = "rg --vimgrep"
|
||||
vim.opt.grepformat = "%f:%l:%c:%m"
|
||||
end
|
||||
|
||||
-- Close other splits
|
||||
vim.api.nvim_set_keymap("n", "<space>o", ":only<cr>", { noremap = true })
|
||||
|
||||
-- Sudo save
|
||||
vim.api.nvim_set_keymap("c", "w!!", "w !sudo tee > /dev/null %", { noremap = true })
|
||||
|
||||
-- Other utility key mappings
|
||||
vim.keymap.set("n", "<C-a>", "ggVG", { desc = "Select all" })
|
||||
vim.keymap.set("n", "<C-v>", "p", { desc = "Paste" })
|
||||
vim.keymap.set("i", "<C-v>", "<esc>p", { desc = "Paste" })
|
||||
vim.keymap.set("v", "<C-c>", "y", { desc = "Yank" })
|
||||
|
||||
-- LSP-related mappings
|
||||
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { desc = "Go to declaration" })
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "Go to definition" })
|
||||
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, { desc = "Go to implementation" })
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, { desc = "Hover Documentation" })
|
||||
vim.keymap.set("n", "<space>a", vim.lsp.buf.code_action, { desc = "Code action" })
|
||||
|
||||
-- Diagnostics
|
||||
vim.keymap.set("n", "<space>d", vim.diagnostic.open_float, { desc = "Floating diagnostic" })
|
||||
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "Previous diagnostic" })
|
||||
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { desc = "Next diagnostic" })
|
||||
vim.keymap.set("n", "gl", vim.diagnostic.setloclist, { desc = "Diagnostics on loclist" })
|
||||
vim.keymap.set("n", "gq", vim.diagnostic.setqflist, { desc = "Diagnostics on quickfix" })
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
133
modules/home/devtools/neovim/lsp.nix
Normal file
133
modules/home/devtools/neovim/lsp.nix
Normal file
@@ -0,0 +1,133 @@
|
||||
{pkgs, ...}: {
|
||||
programs.neovim.plugins = with pkgs.vimPlugins; [
|
||||
# LSP and completions for injected langs
|
||||
otter-nvim
|
||||
phpactor
|
||||
# LSP
|
||||
{
|
||||
plugin = nvim-lspconfig;
|
||||
type = "lua";
|
||||
config =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
local lspconfig = require("lspconfig")
|
||||
|
||||
function add_lsp(server, options)
|
||||
if not options["cmd"] then
|
||||
options["cmd"] = server["document_config"]["default_config"]["cmd"]
|
||||
end
|
||||
if not options["capabilities"] then
|
||||
options["capabilities"] = require("cmp_nvim_lsp").default_capabilities()
|
||||
end
|
||||
|
||||
if vim.fn.executable(options["cmd"][1]) == 1 then
|
||||
server.setup(options)
|
||||
end
|
||||
end
|
||||
|
||||
-- Other LSPs
|
||||
add_lsp(lspconfig.bashls, {})
|
||||
add_lsp(lspconfig.clangd, {})
|
||||
add_lsp(lspconfig.dartls, {})
|
||||
add_lsp(lspconfig.dockerls, {})
|
||||
add_lsp(lspconfig.gopls, {})
|
||||
add_lsp(lspconfig.hls, {})
|
||||
add_lsp(lspconfig.jdtls, {})
|
||||
add_lsp(lspconfig.kotlin_language_server, {})
|
||||
add_lsp(lspconfig.phpactor, { init_options = { ["language_server_php_cs_fixer.enabled"] = true } })
|
||||
add_lsp(lspconfig.rust_analyzer, {})
|
||||
add_lsp(lspconfig.nixd, {})
|
||||
add_lsp(lspconfig.lua_ls, {})
|
||||
add_lsp(lspconfig.pylsp, {})
|
||||
add_lsp(lspconfig.solargraph, {})
|
||||
add_lsp(lspconfig.terraformls, {})
|
||||
add_lsp(lspconfig.texlab, { chktex = {
|
||||
onEdit = true,
|
||||
onOpenAndSave = true,
|
||||
} })
|
||||
add_lsp(lspconfig.ts_ls, {})
|
||||
add_lsp(lspconfig.typst_lsp, {})
|
||||
add_lsp(lspconfig.elixirls, { cmd = { "elixir-ls" } })
|
||||
'';
|
||||
}
|
||||
{
|
||||
plugin = ltex_extra-nvim;
|
||||
type = "lua";
|
||||
config =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
local ltex_extra = require("ltex_extra")
|
||||
add_lsp(lspconfig.ltex, {
|
||||
on_attach = function(client, bufnr)
|
||||
ltex_extra.setup({
|
||||
path = vim.fn.expand("~") .. "/.local/state/ltex",
|
||||
})
|
||||
end,
|
||||
})
|
||||
'';
|
||||
}
|
||||
|
||||
# Snippets
|
||||
luasnip
|
||||
|
||||
# Completions
|
||||
cmp-nvim-lsp
|
||||
cmp_luasnip
|
||||
cmp-rg
|
||||
cmp-buffer
|
||||
cmp-path
|
||||
{
|
||||
plugin = cmp-git;
|
||||
type = "lua";
|
||||
config =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
require("cmp_git").setup({})
|
||||
'';
|
||||
}
|
||||
|
||||
lspkind-nvim
|
||||
{
|
||||
plugin = nvim-cmp;
|
||||
type = "lua";
|
||||
config =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
local cmp = require("cmp")
|
||||
|
||||
cmp.setup({
|
||||
formatting = {
|
||||
format = require("lspkind").cmp_format({
|
||||
before = function(entry, vim_item)
|
||||
return vim_item
|
||||
end,
|
||||
}),
|
||||
},
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require("luasnip").lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({}),
|
||||
sources = {
|
||||
{ name = "otter" },
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
{ name = "git" },
|
||||
{ name = "buffer", option = { get_bufnrs = vim.api.nvim_list_bufs } },
|
||||
{ name = "path" },
|
||||
{ name = "rg" },
|
||||
},
|
||||
})
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
38
modules/home/devtools/neovim/plugins/alpha.nix
Normal file
38
modules/home/devtools/neovim/plugins/alpha.nix
Normal file
@@ -0,0 +1,38 @@
|
||||
{pkgs, ...}: {
|
||||
programs.neovim.plugins = with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = alpha-nvim;
|
||||
type = "lua";
|
||||
config =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
local alpha = require("alpha")
|
||||
local dashboard = require("alpha.themes.dashboard")
|
||||
|
||||
dashboard.section.header.val = {
|
||||
" ",
|
||||
" ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ",
|
||||
" ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ ",
|
||||
" ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ ",
|
||||
" ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ ",
|
||||
" ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ",
|
||||
" ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ",
|
||||
" ",
|
||||
}
|
||||
dashboard.section.header.opts.hl = "Title"
|
||||
|
||||
dashboard.section.buttons.val = {
|
||||
dashboard.button("n", " New file", ":enew<CR>"),
|
||||
dashboard.button("e", " Explore", ":Explore<CR>"),
|
||||
dashboard.button("g", " Git summary", ":Git | :only<CR>"),
|
||||
dashboard.button("c", " Nix config flake", ":e ~/.nix-config/flake.nix<CR>"),
|
||||
}
|
||||
|
||||
alpha.setup(dashboard.opts)
|
||||
vim.keymap.set("n", "<space>h", ":Alpha<CR>", { desc = "Open home dashboard" })
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
15
modules/home/devtools/neovim/plugins/autopairs.nix
Normal file
15
modules/home/devtools/neovim/plugins/autopairs.nix
Normal file
@@ -0,0 +1,15 @@
|
||||
{pkgs, ...}: {
|
||||
programs.neovim.plugins = with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = nvim-autopairs;
|
||||
type = "lua";
|
||||
config =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
require("nvim-autopairs").setup({})
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
15
modules/home/devtools/neovim/plugins/bqf.nix
Normal file
15
modules/home/devtools/neovim/plugins/bqf.nix
Normal file
@@ -0,0 +1,15 @@
|
||||
{pkgs, ...}: {
|
||||
programs.neovim.plugins = with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = nvim-bqf;
|
||||
type = "lua";
|
||||
config =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
require("bqf").setup({})
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
15
modules/home/devtools/neovim/plugins/bufferline.nix
Normal file
15
modules/home/devtools/neovim/plugins/bufferline.nix
Normal file
@@ -0,0 +1,15 @@
|
||||
{pkgs, ...}: {
|
||||
programs.neovim.plugins = with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = bufferline-nvim;
|
||||
type = "lua";
|
||||
config =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
require("bufferline").setup({})
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
15
modules/home/devtools/neovim/plugins/colorizer.nix
Normal file
15
modules/home/devtools/neovim/plugins/colorizer.nix
Normal file
@@ -0,0 +1,15 @@
|
||||
{pkgs, ...}: {
|
||||
programs.neovim.plugins = with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = nvim-colorizer-lua;
|
||||
type = "lua";
|
||||
config =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
require("colorizer").setup({})
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
22
modules/home/devtools/neovim/plugins/comment.nix
Normal file
22
modules/home/devtools/neovim/plugins/comment.nix
Normal file
@@ -0,0 +1,22 @@
|
||||
{pkgs, ...}: {
|
||||
programs.neovim.plugins = with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = comment-nvim;
|
||||
type = "lua";
|
||||
config =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
require("Comment").setup({
|
||||
opleader = {
|
||||
line = "<C-b>",
|
||||
},
|
||||
toggler = {
|
||||
line = "<C-b>",
|
||||
},
|
||||
})
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
47
modules/home/devtools/neovim/plugins/conform.nix
Normal file
47
modules/home/devtools/neovim/plugins/conform.nix
Normal file
@@ -0,0 +1,47 @@
|
||||
{pkgs, ...}: {
|
||||
programs.neovim.plugins = with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = conform-nvim;
|
||||
type = "lua";
|
||||
config =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
require("conform").setup({
|
||||
default_format_opts = {
|
||||
timeout_ms = 3000,
|
||||
async = false, -- not recommended to change
|
||||
quiet = false, -- not recommended to change
|
||||
lsp_format = "fallback", -- not recommended to change
|
||||
},
|
||||
formatters_by_ft = {
|
||||
bash = { "shfmt" },
|
||||
css = { "prettierd" },
|
||||
html = { "prettierd" },
|
||||
javascript = { "prettierd" },
|
||||
json = { "fixjson" },
|
||||
lua = { "stylua" },
|
||||
nix = { "alejandra" },
|
||||
php = { "php_cs_fixer" },
|
||||
python = { "black" },
|
||||
rust = { "rustfmt" },
|
||||
sh = { "shfmt" },
|
||||
typescript = { "prettierd" },
|
||||
query = { "sql_formatter" },
|
||||
yaml = { "prettierd" },
|
||||
["*"] = { "injected" },
|
||||
},
|
||||
})
|
||||
|
||||
-- Optionally, set up a command or auto-command to format on save
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
require("conform").format()
|
||||
end,
|
||||
})
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
45
modules/home/devtools/neovim/plugins/copilot.nix
Normal file
45
modules/home/devtools/neovim/plugins/copilot.nix
Normal file
@@ -0,0 +1,45 @@
|
||||
{pkgs, ...}: {
|
||||
programs.neovim.plugins = with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = copilot-lua;
|
||||
type = "lua";
|
||||
config =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
require("copilot").setup({
|
||||
panel = {
|
||||
enabled = true,
|
||||
auto_refresh = true,
|
||||
keymap = {
|
||||
jump_prev = "[[",
|
||||
jump_next = "]]",
|
||||
accept = "<CR>",
|
||||
refresh = "gr",
|
||||
open = "<M-CR>",
|
||||
},
|
||||
layout = {
|
||||
position = "bottom", -- | top | left | right
|
||||
ratio = 0.4,
|
||||
},
|
||||
},
|
||||
suggestion = {
|
||||
enabled = true,
|
||||
auto_trigger = true,
|
||||
hide_during_completion = true,
|
||||
debounce = 75,
|
||||
keymap = {
|
||||
accept = "<C-CR>",
|
||||
accept_word = false,
|
||||
accept_line = false,
|
||||
next = "<M-]>",
|
||||
prev = "<M-[>",
|
||||
dismiss = "<C-]>",
|
||||
},
|
||||
},
|
||||
})
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
24
modules/home/devtools/neovim/plugins/default.nix
Normal file
24
modules/home/devtools/neovim/plugins/default.nix
Normal file
@@ -0,0 +1,24 @@
|
||||
{pkgs, ...}: {
|
||||
programs.neovim.plugins = with pkgs.vimPlugins; [
|
||||
vim-illuminate
|
||||
];
|
||||
imports = [
|
||||
./alpha.nix
|
||||
./bufferline.nix
|
||||
./copilot.nix
|
||||
./fidget.nix
|
||||
./gitsigns.nix
|
||||
./treesitter.nix
|
||||
./conform.nix
|
||||
./gx.nix
|
||||
./bqf.nix
|
||||
./colorizer.nix
|
||||
./web-devicons.nix
|
||||
./oil.nix
|
||||
./lualine.nix
|
||||
./range-highlight.nix
|
||||
./fugitive.nix
|
||||
./which-key.nix
|
||||
./autopairs.nix
|
||||
];
|
||||
}
|
||||
21
modules/home/devtools/neovim/plugins/fidget.nix
Normal file
21
modules/home/devtools/neovim/plugins/fidget.nix
Normal file
@@ -0,0 +1,21 @@
|
||||
{pkgs, ...}: {
|
||||
programs.neovim.plugins = with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = fidget-nvim;
|
||||
type = "lua";
|
||||
config =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
require("fidget").setup({
|
||||
progress = {
|
||||
display = {
|
||||
progress_icon = { pattern = "dots", period = 1 },
|
||||
},
|
||||
},
|
||||
})
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
15
modules/home/devtools/neovim/plugins/fugitive.nix
Normal file
15
modules/home/devtools/neovim/plugins/fugitive.nix
Normal file
@@ -0,0 +1,15 @@
|
||||
{pkgs, ...}: {
|
||||
programs.neovim.plugins = with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = vim-fugitive;
|
||||
type = "viml";
|
||||
config =
|
||||
/*
|
||||
vim
|
||||
*/
|
||||
''
|
||||
nmap <space>G :Git<CR>
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
23
modules/home/devtools/neovim/plugins/gitsigns.nix
Normal file
23
modules/home/devtools/neovim/plugins/gitsigns.nix
Normal file
@@ -0,0 +1,23 @@
|
||||
{pkgs, ...}: {
|
||||
programs.neovim.plugins = with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = gitsigns-nvim;
|
||||
type = "lua";
|
||||
config =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
require("gitsigns").setup({
|
||||
signs = {
|
||||
add = { text = "+" },
|
||||
change = { text = "~" },
|
||||
delete = { text = "_" },
|
||||
topdelete = { text = "‾" },
|
||||
changedelete = { text = "~" },
|
||||
},
|
||||
})
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
28
modules/home/devtools/neovim/plugins/gx.nix
Normal file
28
modules/home/devtools/neovim/plugins/gx.nix
Normal file
@@ -0,0 +1,28 @@
|
||||
{pkgs, ...}: let
|
||||
gx-nvim = pkgs.vimUtils.buildVimPlugin {
|
||||
name = "gx-nvim";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "chrishrb";
|
||||
repo = "gx.nvim";
|
||||
rev = "f29a87454b02880e0d76264c21be8316224a7395";
|
||||
hash = "sha256-QWJ/cPvSyMTJoWLg51BNFf9+/9i7G+nzennpHP/eQ4g=";
|
||||
};
|
||||
};
|
||||
in {
|
||||
programs.neovim.plugins = [
|
||||
{
|
||||
plugin = gx-nvim;
|
||||
type = "lua";
|
||||
config =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
require("gx").setup({})
|
||||
vim.keymap.set({ "n", "x" }, "gx", ":Browse<CR>", {
|
||||
desc = "Open the file under cursor with system app",
|
||||
})
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
54
modules/home/devtools/neovim/plugins/lualine.nix
Normal file
54
modules/home/devtools/neovim/plugins/lualine.nix
Normal file
@@ -0,0 +1,54 @@
|
||||
{pkgs, ...}: {
|
||||
programs.neovim.plugins = with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = lualine-nvim;
|
||||
type = "lua";
|
||||
config =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
require("lualine").setup({
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = "gruvbox-material",
|
||||
component_separators = { left = "", right = "" },
|
||||
section_separators = { left = "", right = "" },
|
||||
disabled_filetypes = {
|
||||
statusline = {},
|
||||
winbar = {},
|
||||
},
|
||||
ignore_focus = {},
|
||||
always_divide_middle = true,
|
||||
globalstatus = false,
|
||||
refresh = {
|
||||
statusline = 1000,
|
||||
tabline = 1000,
|
||||
winbar = 1000,
|
||||
},
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { "mode" },
|
||||
lualine_b = { "branch", "diff", "diagnostics" },
|
||||
lualine_c = { "filename" },
|
||||
lualine_x = { "encoding", "fileformat", "filetype" },
|
||||
lualine_y = { "progress" },
|
||||
lualine_z = { "location" },
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = { "filename" },
|
||||
lualine_x = { "location" },
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
},
|
||||
tabline = {},
|
||||
winbar = {},
|
||||
inactive_winbar = {},
|
||||
extensions = {},
|
||||
})
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
51
modules/home/devtools/neovim/plugins/none-ls.nix
Normal file
51
modules/home/devtools/neovim/plugins/none-ls.nix
Normal file
@@ -0,0 +1,51 @@
|
||||
{pkgs, ...}: {
|
||||
programs.neovim = {
|
||||
plugins = with pkgs.vimPlugins; [
|
||||
none-ls-nvim
|
||||
plenary-nvim
|
||||
nvim-treesitter.withAllGrammars
|
||||
];
|
||||
extraConfig =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
-- Require necessary plugins
|
||||
require("plenary")
|
||||
require("nvim-treesitter.configs").setup({
|
||||
highlight = {
|
||||
enable = true,
|
||||
},
|
||||
indent = {
|
||||
enable = true,
|
||||
},
|
||||
})
|
||||
|
||||
local null_ls = require("null-ls")
|
||||
|
||||
-- Setup null-ls with stylua and other formatters
|
||||
null_ls.setup({
|
||||
sources = {
|
||||
null_ls.builtins.formatting.alejandra,
|
||||
null_ls.builtins.formatting.stylua,
|
||||
null_ls.builtins.formatting.black,
|
||||
null_ls.builtins.formatting.isort,
|
||||
null_ls.builtins.formatting.phpcsfixer,
|
||||
null_ls.builtins.formatting.pint,
|
||||
null_ls.builtins.formatting.prettier,
|
||||
null_ls.builtins.formatting.sql_formatter,
|
||||
null_ls.builtins.formatting.xmllint,
|
||||
null_ls.builtins.formatting.shfmt,
|
||||
},
|
||||
})
|
||||
|
||||
-- Function to format on save
|
||||
local function format_on_save()
|
||||
vim.cmd([[autocmd BufWritePre * lua vim.lsp.buf.format({ async = true })]])
|
||||
end
|
||||
|
||||
-- Call the function to enable auto format on save
|
||||
format_on_save()
|
||||
'';
|
||||
};
|
||||
}
|
||||
35
modules/home/devtools/neovim/plugins/oil.nix
Normal file
35
modules/home/devtools/neovim/plugins/oil.nix
Normal file
@@ -0,0 +1,35 @@
|
||||
{pkgs, ...}: {
|
||||
programs.neovim.plugins = with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = oil-nvim;
|
||||
type = "lua";
|
||||
config =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
require("oil").setup({
|
||||
buf_options = {
|
||||
buflisted = true,
|
||||
bufhidden = "delete",
|
||||
},
|
||||
cleanup_delay_ms = false,
|
||||
use_default_keymaps = false,
|
||||
keymaps = {
|
||||
["<CR>"] = "actions.select",
|
||||
["-"] = "actions.parent",
|
||||
["_"] = "actions.open_cwd",
|
||||
["`"] = "actions.cd",
|
||||
["~"] = "actions.tcd",
|
||||
["gc"] = "actions.close",
|
||||
["gr"] = "actions.refresh",
|
||||
["gs"] = "actions.change_sort",
|
||||
["gx"] = "actions.open_external",
|
||||
["g."] = "actions.toggle_hidden",
|
||||
["g\\"] = "actions.toggle_trash",
|
||||
},
|
||||
})
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
15
modules/home/devtools/neovim/plugins/plenary.nix
Normal file
15
modules/home/devtools/neovim/plugins/plenary.nix
Normal file
@@ -0,0 +1,15 @@
|
||||
{pkgs, ...}: {
|
||||
programs.neovim.plugins = with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = plenary-nvim;
|
||||
type = "lua";
|
||||
config =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
require("plenary").setup({})
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
15
modules/home/devtools/neovim/plugins/range-highlight.nix
Normal file
15
modules/home/devtools/neovim/plugins/range-highlight.nix
Normal file
@@ -0,0 +1,15 @@
|
||||
{pkgs, ...}: {
|
||||
programs.neovim.plugins = with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = range-highlight-nvim;
|
||||
type = "lua";
|
||||
config =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
require("range-highlight").setup({})
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
20
modules/home/devtools/neovim/plugins/treesitter.nix
Normal file
20
modules/home/devtools/neovim/plugins/treesitter.nix
Normal file
@@ -0,0 +1,20 @@
|
||||
{pkgs, ...}: {
|
||||
programs.neovim.plugins = with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = nvim-treesitter.withAllGrammars;
|
||||
type = "lua";
|
||||
config =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
require("nvim-treesitter.configs").setup({
|
||||
highlight = {
|
||||
enable = true,
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
})
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
15
modules/home/devtools/neovim/plugins/web-devicons.nix
Normal file
15
modules/home/devtools/neovim/plugins/web-devicons.nix
Normal file
@@ -0,0 +1,15 @@
|
||||
{pkgs, ...}: {
|
||||
programs.neovim.plugins = with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = nvim-web-devicons;
|
||||
type = "lua";
|
||||
config =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
require("nvim-web-devicons").setup({})
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
15
modules/home/devtools/neovim/plugins/which-key.nix
Normal file
15
modules/home/devtools/neovim/plugins/which-key.nix
Normal file
@@ -0,0 +1,15 @@
|
||||
{pkgs, ...}: {
|
||||
programs.neovim.plugins = with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = which-key-nvim;
|
||||
type = "lua";
|
||||
config =
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
require("which-key").setup({})
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
54
modules/home/devtools/neovim/syntaxes.nix
Normal file
54
modules/home/devtools/neovim/syntaxes.nix
Normal file
@@ -0,0 +1,54 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
programs.neovim = {
|
||||
extraConfig =
|
||||
lib.mkAfter # vim
|
||||
|
||||
''
|
||||
function! SetCustomKeywords()
|
||||
syn match Todo /TODO/
|
||||
syn match Done /DONE/
|
||||
syn match Start /START/
|
||||
syn match End /END/
|
||||
endfunction
|
||||
|
||||
autocmd Syntax * call SetCustomKeywords()
|
||||
'';
|
||||
plugins = with pkgs.vimPlugins; [
|
||||
rust-vim
|
||||
dart-vim-plugin
|
||||
plantuml-syntax
|
||||
vim-markdown
|
||||
vim-nix
|
||||
vim-toml
|
||||
kotlin-vim
|
||||
haskell-vim
|
||||
pgsql-vim
|
||||
vim-terraform
|
||||
vim-jsx-typescript
|
||||
vim-caddyfile
|
||||
|
||||
{
|
||||
plugin = vimtex;
|
||||
config = let
|
||||
viewMethod =
|
||||
if config.programs.zathura.enable
|
||||
then "zathura"
|
||||
else "general";
|
||||
in
|
||||
/*
|
||||
vim
|
||||
*/
|
||||
''
|
||||
let g:vimtex_view_method = '${viewMethod}'
|
||||
"Don't open automatically
|
||||
let g:vimtex_quickfix_mode = 0
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user