Update neovim keybindings & setup ruff lsp
This commit is contained in:
parent
f817379950
commit
a458963ff0
3 changed files with 45 additions and 17 deletions
|
|
@ -10,14 +10,26 @@ local on_attach = function(client, bufnr)
|
|||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
-- mappings
|
||||
local opts = { noremap=true, silent=true }
|
||||
local opts = { buffer = bufnr, noremap = true, silent = true }
|
||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
|
||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
|
||||
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
|
||||
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
|
||||
vim.keymap.set('n', '<space>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, opts)
|
||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
|
||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
|
||||
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
|
||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
||||
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
|
||||
vim.keymap.set('n', '<space>la', vim.lsp.buf.code_action, opts)
|
||||
|
||||
--see `:help vim.lsp.*` for documentation on any of the below functions
|
||||
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -55,6 +67,13 @@ local python_root_dir = function(fname)
|
|||
util.path.dirname(fname)
|
||||
end
|
||||
|
||||
nvim_lsp.ruff_lsp.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
root_dir = python_root_dir
|
||||
})
|
||||
|
||||
|
||||
nvim_lsp.pylsp.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
|
|
@ -63,24 +82,24 @@ nvim_lsp.pylsp.setup({
|
|||
pylsp = {
|
||||
plugins = {
|
||||
ruff = {
|
||||
enabled = true
|
||||
}
|
||||
enabled = false
|
||||
},
|
||||
jedi_completion = { fuzzy = true }
|
||||
}
|
||||
}
|
||||
},
|
||||
root_dir = python_root_dir
|
||||
})
|
||||
|
||||
local pyright_capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
pyright_capabilities.textDocument.publishDiagnostics.tagSupport.valueSet = { 2 }
|
||||
|
||||
nvim_lsp.pyright.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = pyright_capabilities,
|
||||
root_dir = python_root_dir
|
||||
settings = {
|
||||
pyright = {
|
||||
-- Using Ruff's import organizer
|
||||
disableOrganizeImports = true,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
nvim_lsp.html.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue