nix: Vim LSP plugins
This commit is contained in:
parent
e6f25d9fac
commit
39294e4b90
|
@ -16,16 +16,6 @@
|
|||
" Theme
|
||||
source ~/.config/vim/theme.vim
|
||||
|
||||
" Language Server Client
|
||||
{% if variant == 'nvim' %}
|
||||
{{ use_plugin('nvim_lspconfig') }}
|
||||
{{ use_plugin('lightbulb') }}
|
||||
{{ use_plugin('lspkind') }}
|
||||
{{ use_plugin('lsp_signature') }}
|
||||
{% else %}
|
||||
{{ use_plugin('vim_lsp') }}
|
||||
{% endif %}
|
||||
|
||||
" Treesitter
|
||||
{% if variant == 'nvim' %}
|
||||
{{ use_plugin('treesitter') }}
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
{# Shows a lightbulb whenever a codeAction is available under the cursor #}
|
||||
{{ add_source('kosayoda/nvim-lightbulb') -}}
|
||||
autocmd CursorHold,CursorHoldI * lua require'nvim-lightbulb'.update_lightbulb()
|
|
@ -1,8 +0,0 @@
|
|||
{# Show argument documentation when typing a function #}
|
||||
{{ add_source('ray-x/lsp_signature.nvim') -}}
|
||||
|
||||
lua << EOF
|
||||
require'lsp_signature'.on_attach({
|
||||
hint_enable = false,
|
||||
})
|
||||
EOF
|
|
@ -1,6 +0,0 @@
|
|||
{# Add icons to LSP completions #}
|
||||
{{ add_source('onsails/lspkind-nvim') -}}
|
||||
|
||||
lua << EOF
|
||||
require('lspkind').init()
|
||||
EOF
|
|
@ -1,70 +0,0 @@
|
|||
{# LSP client for neovim ≥ 0.5 #}
|
||||
{{ add_source('neovim/nvim-lspconfig') -}}
|
||||
lua << EOF
|
||||
local nvim_lsp = require('lspconfig')
|
||||
|
||||
-- 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', '[e', vim.diagnostic.goto_prev, opts)
|
||||
vim.keymap.set('n', ']e', 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', 'K', vim.lsp.buf.hover, bufopts)
|
||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
||||
vim.keymap.set('n', '<C-S-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', '<space>D', vim.lsp.buf.type_definition, bufopts)
|
||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
|
||||
-- vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
|
||||
-- vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
||||
vim.keymap.set('n', '<space>f', function() vim.lsp.buf.format { async = true } end, bufopts)
|
||||
end
|
||||
|
||||
-- Use a loop to conveniently call 'setup' on multiple servers and
|
||||
-- map buffer local keybindings when the language server attaches
|
||||
local servers = {
|
||||
{% if 'ansible' in dev_stuffs %}
|
||||
"ansiblels",
|
||||
{% endif %}
|
||||
{% if 'nix' in dev_stuffs %}
|
||||
"rnix",
|
||||
{% endif %}
|
||||
{% if 'perl' in dev_stuffs %}
|
||||
"perlls",
|
||||
{% endif %}
|
||||
{% if 'python' in dev_stuffs %}
|
||||
"pylsp",
|
||||
{% endif %}
|
||||
{% if 'php' in dev_stuffs %}
|
||||
"phpactor", -- Install this one manually https://phpactor.readthedocs.io/en/master/usage/standalone.html#global-installation
|
||||
{% endif %}
|
||||
{% if 'sql' in dev_stuffs %}
|
||||
"sqlls",
|
||||
{% endif %}
|
||||
}
|
||||
for _, lsp in ipairs(servers) do
|
||||
nvim_lsp[lsp].setup {
|
||||
on_attach = on_attach,
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
}
|
||||
}
|
||||
end
|
||||
EOF
|
|
@ -1,39 +0,0 @@
|
|||
{# LSP client for Vim8 and neovim #}
|
||||
{{ add_source('prabirshrestha/vim-lsp') -}}
|
||||
{{ add_source('mattn/vim-lsp-settings') -}}
|
||||
" (providers are automatically detected thanks to vim-lsp-settings.
|
||||
" You can even install some locally using :LspInstallServer)
|
||||
|
||||
let g:lsp_signs_enabled = 1
|
||||
let g:lsp_diagnostics_echo_cursor = 1
|
||||
|
||||
let g:lsp_signs_error = {'text': '✗'}
|
||||
let g:lsp_signs_warning = {'text': '‼'}
|
||||
let g:lsp_signs_information = {'text': 'ℹ'}
|
||||
let g:lsp_signs_hint = {'text': '?'}
|
||||
|
||||
let g:lsp_highlight_references_enabled = 1
|
||||
|
||||
function! s:on_lsp_buffer_enabled() abort
|
||||
setlocal omnifunc=lsp#complete
|
||||
setlocal signcolumn=yes
|
||||
if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
|
||||
nmap <buffer> gd <plug>(lsp-definition)
|
||||
nmap <buffer> gD <plug>(lsp-declaration)
|
||||
nmap <buffer> gr <plug>(lsp-references)
|
||||
nmap <buffer> gi <plug>(lsp-implementation)
|
||||
nmap <buffer> <space>rn <plug>(lsp-rename)
|
||||
nmap <buffer> [d <plug>(lsp-previous-diagnostic)
|
||||
nmap <buffer> ]d <plug>(lsp-next-diagnostic)
|
||||
nmap <buffer> K <plug>(lsp-hover)
|
||||
nmap <buffer> <space>f <plug>(lsp-document-format)
|
||||
vmap <buffer> <space>f <plug>(lsp-document-range-format)
|
||||
inoremap <buffer> <expr><c-f> lsp#scroll(+4)
|
||||
inoremap <buffer> <expr><c-d> lsp#scroll(-4)
|
||||
endfunction
|
||||
|
||||
augroup lsp_install
|
||||
au!
|
||||
" call s:on_lsp_buffer_enabled only for languages that has the server registered.
|
||||
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
|
||||
augroup END
|
|
@ -6,7 +6,6 @@
|
|||
# Ansible
|
||||
ansible
|
||||
ansible-lint
|
||||
ansible-language-server
|
||||
|
||||
# C/C++
|
||||
cmake
|
||||
|
@ -42,24 +41,9 @@
|
|||
|
||||
# nix
|
||||
nix
|
||||
rnix-lsp
|
||||
|
||||
# Perl
|
||||
perl536Packages.PLS
|
||||
|
||||
# Python
|
||||
mypy
|
||||
python3Packages.black
|
||||
python3Packages.python-lsp-server
|
||||
python3Packages.pylsp-mypy
|
||||
python3Packages.pyls-isort
|
||||
python3Packages.python-lsp-black
|
||||
# TODO Are all those for the same language server?
|
||||
python3Packages.ipython
|
||||
|
||||
# Bash
|
||||
nodePackages.bash-language-server
|
||||
sqls
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
@ -54,27 +54,27 @@ in
|
|||
# Go to whatever
|
||||
telescope = {
|
||||
enable = true;
|
||||
# FIXME Crashes nvim on startup, complaining about some keymap
|
||||
# keymaps = {
|
||||
# gF = "find_files";
|
||||
# gf = "git_files";
|
||||
# gB = "buffers";
|
||||
# gl = "current_buffer_fuzzy_find";
|
||||
# gL = "live_grep";
|
||||
# gT = "tags";
|
||||
# gt = "treesitter";
|
||||
# gm = "marks";
|
||||
# gh = "oldfiles";
|
||||
# gH = "command_history";
|
||||
# gS = "search_history";
|
||||
# gC = "commands";
|
||||
# gr = "lsp_references";
|
||||
# ga = "lsp_code_actions";
|
||||
# ge = "lsp_document_diagnostics";
|
||||
# gE = "lsp_workspace_diagnostics";
|
||||
# gd = "lsp_definitions";
|
||||
# gs = "lsp_document_symbols";
|
||||
# };
|
||||
keymaps = {
|
||||
gF = "find_files";
|
||||
gf = "git_files";
|
||||
gB = "buffers";
|
||||
gl = "current_buffer_fuzzy_find";
|
||||
gL = "live_grep";
|
||||
gT = "tags";
|
||||
gt = "treesitter";
|
||||
gm = "marks";
|
||||
gh = "oldfiles";
|
||||
gH = "command_history";
|
||||
gS = "search_history";
|
||||
gC = "commands";
|
||||
gr = "lsp_references";
|
||||
# ga = "lsp_code_actions";
|
||||
# ge = "lsp_document_diagnostics";
|
||||
# gE = "lsp_workspace_diagnostics";
|
||||
# FIXME Above makes nvim crash on startup, action is not provided
|
||||
gd = "lsp_definitions";
|
||||
gs = "lsp_document_symbols";
|
||||
};
|
||||
defaults = {
|
||||
vimgrep_arguments = [
|
||||
"${pkgs.ripgrep}/bin/rg"
|
||||
|
@ -97,6 +97,63 @@ in
|
|||
|
||||
# Surrounding pairs
|
||||
surround.enable = true; # Change surrounding pairs (e.g. brackets, quotes)
|
||||
|
||||
# Language Server
|
||||
lsp = {
|
||||
enable = true;
|
||||
keymaps = {
|
||||
silent = true;
|
||||
diagnostic = {
|
||||
"<Space>e" = "open_float";
|
||||
"[e" = "goto_prev";
|
||||
"]e" = "goto_next";
|
||||
};
|
||||
lspBuf = {
|
||||
"gD" = "declaration";
|
||||
"K" = "hover";
|
||||
"gi" = "implementation";
|
||||
"<C-S-k>" = "signature_help";
|
||||
"<space>wa" = "add_workspace_folder";
|
||||
"<space>wr" = "remove_workspace_folder";
|
||||
# "<space>wl" = "list_workspace_folder";
|
||||
# TODO Full thing was function() print(vim.inspect(vim.lsp.buf.list_workspace_folder())) end but not sure I'm ever really using this
|
||||
# Also makes nvim crash like this, so uncommented
|
||||
"<space>D" = "type_definition";
|
||||
"<space>rn" = "rename";
|
||||
"<space>f" = "format";
|
||||
# TODO Full thing was function() vim.lsp.buf.format { async = true } end, so async while this isn't
|
||||
# Maybe replace this with lsp-format?
|
||||
};
|
||||
};
|
||||
servers = {
|
||||
# FIXME ansiblels
|
||||
bashls.enable = true; # Bash
|
||||
jsonls.enable = true; # JSON
|
||||
# FIXME perlls
|
||||
pylsp = { # Python
|
||||
enable = true;
|
||||
settings.plugins = {
|
||||
black.enabled = true;
|
||||
flake8.enabled = true; # FIXME Not getting the warnings I would expect
|
||||
isort.enabled = true;
|
||||
pylsp_mypy.enabled = true;
|
||||
};
|
||||
};
|
||||
# FIXME phpactor. Only from 23.11
|
||||
# phpactor.enable = true; # PHP
|
||||
rnix-lsp.enable = true; # Nix
|
||||
# FIXME sqlls
|
||||
yamlls.enable = true; # Nix
|
||||
# TODO Check out none-ls
|
||||
};
|
||||
# FIXME vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') as onAttach... is it needed?
|
||||
# FIXME flags = { debounce_text_changes = 150 } is the default value ok? Maybe it was actually ignored
|
||||
};
|
||||
nvim-lightbulb = { # Shows a lightbulb whenever a codeAction is available under the cursor
|
||||
enable = true;
|
||||
autocmd.enabled = true;
|
||||
};
|
||||
lspkind.enable = true; # Add icons to LSP completions
|
||||
};
|
||||
extraPlugins = with pkgs.vimPlugins; [
|
||||
nvim-scrollview # Scroll bar
|
||||
|
@ -125,10 +182,14 @@ in
|
|||
vim-gutentags # Generate tags
|
||||
symbols-outline-nvim # Show a symbol panel on the right
|
||||
# TODO Fails on startup. Same on Arch. Config issue?
|
||||
|
||||
# Language server
|
||||
lsp_signature-nvim # Show argument definition when typing a function
|
||||
];
|
||||
extraConfigLua = lib.strings.concatMapStringsSep "\n" (f: builtins.readFile f) [
|
||||
./vim/feline.lua
|
||||
./vim/symbols-outline-nvim.lua
|
||||
./vim/lsp_signature-nvim.lua
|
||||
];
|
||||
extraConfigVim = ''
|
||||
" vim-gutentags
|
||||
|
|
3
config/nix/hm/vim/lsp_signature-nvim.lua
Normal file
3
config/nix/hm/vim/lsp_signature-nvim.lua
Normal file
|
@ -0,0 +1,3 @@
|
|||
require'lsp_signature'.on_attach({
|
||||
hint_enable = false,
|
||||
})
|
Loading…
Reference in a new issue