nvim: lsp: Update Python Jedi language server configuration

This commit is contained in:
Sanchayan Maity 2021-12-17 10:40:29 +05:30
parent e661dded6c
commit 7e943ae1c5

View file

@ -97,29 +97,6 @@ local ts_utils_setup = function(client, bufnr, opts)
end
end
-- Pyright isn't usable for GLib/PyGObject based libraries. Both
-- python-lsp-server and jedi-language-server which are based on Jedi and work
-- for GStreamer/GLib etc. are extremely slow for Python files with 1000+
-- lines. So we only enable completion, rename/hover and document highlight
-- support. Jumping to definition takes seconds in large files, so we just
-- rely on in-built support or perhaps that comes from treesitter.
local on_attach_python = function(client, bufnr)
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
vim.lsp.set_log_level('warn')
if client.config.flags then
client.config.flags.allow_incremental_sync = true
client.config.flags.debounce_text_changes = 500
end
local opts = { noremap=true, silent=true }
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gR', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<Leader>k', '<cmd>lua vim.lsp.buf.hover()<CR>' , opts)
vim.api.nvim_command [[autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()]]
vim.api.nvim_command [[autocmd CursorMoved,InsertEnter <buffer> lua vim.lsp.buf.clear_references()]]
end
local on_attach = function(client, bufnr)
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
vim.lsp.set_log_level('warn')
@ -246,8 +223,21 @@ nvim_lsp.hls.setup {
nvim_lsp.jedi_language_server.setup {
on_init = on_init,
on_attach = on_attach_python,
capabilities = capabilities
on_attach = on_attach,
capabilities = capabilities,
init_options = {
completion = {
resolveEagerly = true,
},
jediSettings = {
caseInsensitiveCompletion = false,
},
workspace = {
symbols = {
maxSymbols = 50
},
},
},
}
require('rust-tools').setup(rust_tool_opts)