2023-11-29 04:27:07 +00:00
|
|
|
{ lib, path }:
|
|
|
|
{ pkgs, config, ... }:
|
|
|
|
let setPath = if path == [ ] then [ "config" ] else path;
|
|
|
|
in lib.setAttrByPath setPath (let cfg = lib.getAttrFromPath path config;
|
|
|
|
in {
|
2023-10-27 06:06:33 +00:00
|
|
|
vimAlias = true;
|
2023-11-29 03:32:43 +00:00
|
|
|
enableMan = false;
|
2023-09-07 14:26:04 +00:00
|
|
|
|
2023-10-27 06:06:33 +00:00
|
|
|
# Basic editing / QoL
|
|
|
|
editorconfig.enable = true;
|
|
|
|
colorschemes.kanagawa.enable = true;
|
|
|
|
plugins = {
|
|
|
|
nix.enable = true;
|
|
|
|
fugitive.enable = true;
|
|
|
|
gitgutter.enable = true;
|
|
|
|
lualine.enable = true;
|
|
|
|
typst-vim.enable = true;
|
|
|
|
telescope = {
|
|
|
|
enable = true;
|
|
|
|
keymaps = {
|
|
|
|
"<leader>tgf" = "git_files";
|
|
|
|
"<leader>tb" = "buffers";
|
|
|
|
"<leader>tl" = "live_grep";
|
|
|
|
"<leader>ts" = "grep_string";
|
|
|
|
"<leader>tf" = "find_files";
|
|
|
|
"<leader>tt" = "builtin";
|
2023-09-14 16:48:15 +00:00
|
|
|
|
2023-10-27 06:06:33 +00:00
|
|
|
gd = "lsp_definitions";
|
|
|
|
gt = "lsp_type_definitions";
|
|
|
|
gr = "lsp_references";
|
|
|
|
gi = "lsp_implementations";
|
|
|
|
gcd = "diagnostics";
|
|
|
|
gsd = "lsp_document_symbols";
|
|
|
|
gsw = "lsp_workspace_symbols";
|
|
|
|
gci = "lsp_incoming_calls";
|
|
|
|
gco = "lsp_outgoing_calls";
|
2023-09-14 16:48:15 +00:00
|
|
|
|
2023-10-27 06:06:33 +00:00
|
|
|
"<leader>tgs" = "git_status";
|
|
|
|
"<leader>tgb" = "git_branches";
|
|
|
|
"<leader>tgc" = "git_commits";
|
2023-09-14 16:48:15 +00:00
|
|
|
};
|
2023-09-07 05:01:23 +00:00
|
|
|
};
|
2023-10-27 06:06:33 +00:00
|
|
|
};
|
|
|
|
extraPlugins = with pkgs.vimPlugins; [
|
|
|
|
vim-fetch
|
|
|
|
vim-fish
|
|
|
|
vim-flatbuffers
|
|
|
|
vim-nftables
|
|
|
|
vim-protobuf
|
|
|
|
vim-toml
|
|
|
|
];
|
|
|
|
options = {
|
|
|
|
hidden = true;
|
|
|
|
backup = false;
|
|
|
|
writebackup = false;
|
|
|
|
cmdheight = 2;
|
|
|
|
shortmess = "filnxtToOFc";
|
|
|
|
signcolumn = "yes";
|
|
|
|
number = true;
|
|
|
|
};
|
2023-09-07 05:01:23 +00:00
|
|
|
|
2023-10-27 06:06:33 +00:00
|
|
|
# LSP
|
|
|
|
plugins.rust-tools = {
|
2023-11-29 04:27:07 +00:00
|
|
|
enable = cfg.plugins.lsp.enable;
|
2023-10-27 06:06:33 +00:00
|
|
|
server.standalone = false;
|
|
|
|
};
|
2023-11-29 04:27:07 +00:00
|
|
|
plugins.clangd-extensions.enable = cfg.plugins.lsp.enable;
|
2023-10-27 06:06:33 +00:00
|
|
|
plugins.lsp = {
|
2023-11-29 04:27:07 +00:00
|
|
|
enable = lib.mkDefault true;
|
2023-10-27 06:06:33 +00:00
|
|
|
servers = {
|
2023-11-29 04:27:07 +00:00
|
|
|
clangd.enable = cfg.plugins.lsp.enable;
|
|
|
|
java-language-server.enable = cfg.plugins.lsp.enable;
|
|
|
|
jsonls.enable = cfg.plugins.lsp.enable;
|
|
|
|
nil_ls.enable = cfg.plugins.lsp.enable;
|
2023-12-03 22:56:08 +00:00
|
|
|
pylsp = {
|
|
|
|
enable = cfg.plugins.lsp.enable;
|
|
|
|
settings.plugins = {
|
|
|
|
pylsp_mypy.enabled = true;
|
|
|
|
black.enabled = true;
|
|
|
|
};
|
|
|
|
};
|
2023-11-29 04:27:07 +00:00
|
|
|
texlab.enable = cfg.plugins.lsp.enable;
|
|
|
|
tsserver.enable = cfg.plugins.lsp.enable;
|
|
|
|
typst-lsp.enable = cfg.plugins.lsp.enable;
|
2023-09-08 20:15:02 +00:00
|
|
|
};
|
2023-09-14 16:48:15 +00:00
|
|
|
|
2023-10-27 06:06:33 +00:00
|
|
|
keymaps = {
|
|
|
|
silent = true;
|
|
|
|
diagnostic = {
|
|
|
|
"<leader>rk" = "goto_prev";
|
|
|
|
"<leader>rj" = "goto_next";
|
2023-09-07 05:01:23 +00:00
|
|
|
};
|
2023-10-27 06:06:33 +00:00
|
|
|
lspBuf = {
|
|
|
|
K = "hover";
|
|
|
|
gD = "declaration";
|
2023-09-07 05:01:23 +00:00
|
|
|
|
2023-10-27 06:06:33 +00:00
|
|
|
"<leader>ra" = "code_action";
|
|
|
|
"<leader>rn" = "rename";
|
|
|
|
"<leader>rs" = "signature_help";
|
|
|
|
"<leader>f" = "format";
|
|
|
|
};
|
2023-09-07 05:01:23 +00:00
|
|
|
};
|
|
|
|
|
2023-10-27 06:06:33 +00:00
|
|
|
onAttach = ''
|
|
|
|
if client.server_capabilities.documentHighlightProvider then
|
|
|
|
vim.api.nvim_create_augroup("lsp_document_highlight", { clear = true })
|
|
|
|
vim.api.nvim_clear_autocmds { buffer = bufnr, group = "lsp_document_highlight" }
|
|
|
|
vim.api.nvim_create_autocmd("CursorHold", {
|
|
|
|
callback = vim.lsp.buf.document_highlight,
|
|
|
|
buffer = bufnr,
|
|
|
|
group = "lsp_document_highlight",
|
|
|
|
desc = "Document Highlight",
|
|
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("CursorMoved", {
|
|
|
|
callback = vim.lsp.buf.clear_references,
|
|
|
|
buffer = bufnr,
|
|
|
|
group = "lsp_document_highlight",
|
|
|
|
desc = "Clear All the References",
|
|
|
|
})
|
|
|
|
end
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
# Autocomplete
|
|
|
|
plugins = {
|
|
|
|
luasnip.enable = true;
|
|
|
|
cmp-cmdline.enable = true;
|
|
|
|
cmp-git.enable = true;
|
|
|
|
cmp-buffer.enable = true;
|
|
|
|
nvim-cmp = {
|
|
|
|
enable = true;
|
|
|
|
snippet.expand = "luasnip";
|
|
|
|
sources = [
|
|
|
|
{ name = "luasnip"; }
|
|
|
|
{ name = "nvim_lsp"; }
|
|
|
|
{ name = "path"; }
|
|
|
|
{ name = "calc"; }
|
|
|
|
{ name = "emoji"; }
|
|
|
|
];
|
|
|
|
mappingPresets = [ "insert" "cmdline" ];
|
|
|
|
mapping = {
|
|
|
|
"<CR>" = "cmp.mapping.confirm({ select = true })";
|
|
|
|
"<C-b>" = "cmp.mapping.scroll_docs(-4)";
|
|
|
|
"<C-f>" = "cmp.mapping.scroll_docs(4)";
|
|
|
|
"<C-Space>" = "cmp.mapping.complete()";
|
|
|
|
"<C-e>" = "cmp.mapping.abort()";
|
2023-09-07 05:01:23 +00:00
|
|
|
};
|
|
|
|
};
|
2023-10-27 06:06:33 +00:00
|
|
|
};
|
2023-09-07 14:26:04 +00:00
|
|
|
|
2023-10-27 06:06:33 +00:00
|
|
|
# For some reason you can't do this directly in nix?
|
|
|
|
extraConfigLuaPost = ''
|
|
|
|
do
|
|
|
|
local cmp = require('cmp')
|
|
|
|
cmp.setup.filetype('gitcommit', {
|
|
|
|
sources = cmp.config.sources({
|
|
|
|
{ name = 'git' },
|
|
|
|
}, {
|
|
|
|
{ name = 'buffer' },
|
2023-09-07 14:26:04 +00:00
|
|
|
})
|
2023-10-27 06:06:33 +00:00
|
|
|
})
|
2023-09-07 14:26:04 +00:00
|
|
|
|
2023-10-27 06:06:33 +00:00
|
|
|
cmp.setup.cmdline({ '/', '?' }, {
|
|
|
|
mapping = cmp.mapping.preset.cmdline(),
|
|
|
|
sources = {
|
|
|
|
{ name = 'buffer' }
|
|
|
|
}
|
|
|
|
})
|
2023-09-07 14:26:04 +00:00
|
|
|
|
2023-10-27 06:06:33 +00:00
|
|
|
cmp.setup.cmdline(':', {
|
|
|
|
mapping = cmp.mapping.preset.cmdline(),
|
|
|
|
sources = cmp.config.sources({
|
|
|
|
{ name = 'path' }
|
|
|
|
}, {
|
|
|
|
{ name = 'cmdline' }
|
2023-09-07 14:26:04 +00:00
|
|
|
})
|
2023-10-27 06:06:33 +00:00
|
|
|
})
|
|
|
|
end
|
|
|
|
'';
|
2023-11-29 04:27:07 +00:00
|
|
|
})
|