plugin/lsp: initial config
This commit is contained in:
parent
841751ff30
commit
5ad0343b84
3 changed files with 78 additions and 0 deletions
|
@ -9,6 +9,7 @@ let
|
||||||
./syntax
|
./syntax
|
||||||
./explorer
|
./explorer
|
||||||
./theme
|
./theme
|
||||||
|
./lsp
|
||||||
];
|
];
|
||||||
|
|
||||||
basicConfig = builtins.readFile ./basic.lua;
|
basicConfig = builtins.readFile ./basic.lua;
|
||||||
|
|
66
lsp/config.lua
Normal file
66
lsp/config.lua
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
local lsp_config = require 'lspconfig'
|
||||||
|
|
||||||
|
-- always show signcolumns
|
||||||
|
vim.opt.signcolumn = "yes"
|
||||||
|
|
||||||
|
-- Mappings.
|
||||||
|
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||||
|
local opts = { noremap=true, silent=true }
|
||||||
|
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
|
||||||
|
vim.keymap.set('n', '[c', vim.diagnostic.goto_prev, opts)
|
||||||
|
vim.keymap.set('n', ']c', vim.diagnostic.goto_next, opts)
|
||||||
|
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
|
||||||
|
|
||||||
|
-- Use an on_attach function to only map the following keys
|
||||||
|
-- after the language server attaches to the current buffer
|
||||||
|
local on_attach = function(client, bufnr)
|
||||||
|
-- Enable completion triggered by <c-x><c-o>
|
||||||
|
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||||
|
|
||||||
|
-- Mappings.
|
||||||
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||||
|
local bufopts = { noremap=true, silent=true, buffer=bufnr }
|
||||||
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
||||||
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
||||||
|
vim.keymap.set('n', 'gy', vim.lsp.buf.type_definition, bufopts)
|
||||||
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
||||||
|
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
||||||
|
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
|
||||||
|
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
|
||||||
|
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
|
||||||
|
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
|
||||||
|
vim.keymap.set('n', '<space>wl', function()
|
||||||
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||||
|
end, bufopts)
|
||||||
|
vim.keymap.set('n', '<localleader>n', vim.lsp.buf.rename, bufopts)
|
||||||
|
vim.keymap.set('n', '<localleader>a', vim.lsp.buf.code_action, bufopts)
|
||||||
|
vim.keymap.set('n', '<localleader>f', vim.lsp.buf.formatting, bufopts)
|
||||||
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
-- See: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
|
||||||
|
--
|
||||||
|
-- nix
|
||||||
|
lsp_config.nil_ls.setup { on_attach = on_attach }
|
||||||
|
|
||||||
|
--[[
|
||||||
|
-- js,ts
|
||||||
|
lsp_config.tsserver.setup { on_attach = on_attach }
|
||||||
|
lsp_config.eslint.setup { on_attach = on_attach }
|
||||||
|
|
||||||
|
-- rust
|
||||||
|
lsp_config.rust_analyzer.setup {
|
||||||
|
on_attach = on_attach,
|
||||||
|
-- Server-specific settings...
|
||||||
|
settings = {
|
||||||
|
["rust-analyzer"] = {
|
||||||
|
"server.path" = "rust-analyzer";
|
||||||
|
"updates.prompt" = false;
|
||||||
|
"updates.checkOnStartup" = false;
|
||||||
|
"checkOnSave.enable" = true;
|
||||||
|
"checkOnSave.command" = "clippy";
|
||||||
|
"cargo.autoreload" = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]--
|
11
lsp/default.nix
Normal file
11
lsp/default.nix
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{ vimPlugins, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
luaConfig = builtins.readFile ./config.lua;
|
||||||
|
|
||||||
|
plugins = [
|
||||||
|
vimPlugins.nvim-lspconfig
|
||||||
|
vimPlugins.nvim-cmp # auto-completion
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
Reference in a new issue