merged lsp into app.nix
This commit is contained in:
parent
4d72b7a141
commit
a86ffded19
2 changed files with 12 additions and 53 deletions
|
|
@ -102,6 +102,7 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
programs.nixvim.plugins.nvim-lspconfig.enable = true;
|
||||||
programs.nixvim.plugins = with config.neovim.languages; {
|
programs.nixvim.plugins = with config.neovim.languages; {
|
||||||
nix.enable = nix.enable;
|
nix.enable = nix.enable;
|
||||||
rustaceanvim.enable = rust.enable;
|
rustaceanvim.enable = rust.enable;
|
||||||
|
|
@ -116,6 +117,17 @@
|
||||||
rust_analyzer.enable = rust.enable;
|
rust_analyzer.enable = rust.enable;
|
||||||
tsserver.enable = typescript.enable;
|
tsserver.enable = typescript.enable;
|
||||||
};
|
};
|
||||||
|
keymaps = [
|
||||||
|
{ key = "gd"; lspBufAction = "definition"; }
|
||||||
|
{ key = "gD"; lspBufAction = "declaration"; }
|
||||||
|
{ key = "gi"; lspBufAction = "implementation"; }
|
||||||
|
{ key = "gt"; lspBufAction = "type_definition"; }
|
||||||
|
{ key = "K"; lspBufAction = "hover"; }
|
||||||
|
] + lib.options config.neovim.plugins.telescope.enable {
|
||||||
|
key = "gr";
|
||||||
|
action = lib.nixvim.mkRaw
|
||||||
|
"require('telescope.builtin').lsp_references";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,53 +0,0 @@
|
||||||
{ config, pkgs, lib, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
config = lib.mkIf config.neovim.enable {
|
|
||||||
programs.neovim.plugins = let
|
|
||||||
cfgp = config.neovim.plugins;
|
|
||||||
cfgl = config.neovim.languages;
|
|
||||||
|
|
||||||
configText = ''
|
|
||||||
local on_attach = function(_, bufnr)
|
|
||||||
|
|
||||||
local bufmap = function(keys, func)
|
|
||||||
vim.keymap.set('n', keys, func, { buffer = bufnr })
|
|
||||||
end
|
|
||||||
|
|
||||||
bufmap('<leader>r', vim.lsp.buf.rename)
|
|
||||||
bufmap('<leader>a', vim.lsp.buf.code_action)
|
|
||||||
|
|
||||||
bufmap('gd', vim.lsp.buf.definition)
|
|
||||||
bufmap('gD', vim.lsp.buf.declaration)
|
|
||||||
bufmap('gI', vim.lsp.buf.implementation)
|
|
||||||
bufmap('<leader>D', vim.lsp.buf.type_definition)
|
|
||||||
|
|
||||||
'' + lib.strings.optionalString cfgp.telescope.enable ''
|
|
||||||
bufmap('gr', require('telescope.builtin').lsp_references)
|
|
||||||
bufmap('<leader>s', require('telescope.builtin').lsp_document_symbols)
|
|
||||||
bufmap('<leader>S', require('telescope.builtin').lsp_dynamic_workspace_symbols)
|
|
||||||
'' + ''
|
|
||||||
|
|
||||||
bufmap('K', vim.lsp.buf.hover)
|
|
||||||
|
|
||||||
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
|
|
||||||
vim.lsp.buf.format()
|
|
||||||
end, {})
|
|
||||||
end
|
|
||||||
|
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
||||||
'' + lib.strings.optionalString cfgl.c.enable ''
|
|
||||||
require('lspconfig').clangd.setup {}
|
|
||||||
'' + lib.strings.optionalString cfgl.go.enable ''
|
|
||||||
require('lspconfig').gopls.setup {}
|
|
||||||
'' + lib.strings.optionalString cfgl.nix.enable ''
|
|
||||||
require('lspconfig').nil_ls.setup {}
|
|
||||||
'';
|
|
||||||
in with pkgs.vimPlugins; [
|
|
||||||
{
|
|
||||||
plugin = nvim-lspconfig;
|
|
||||||
type = "lua";
|
|
||||||
config = configText;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue