nvim: Update Python related configuration
This commit is contained in:
parent
b41584d996
commit
591077efb4
3 changed files with 37 additions and 18 deletions
|
@ -1 +1,6 @@
|
|||
setlocal textwidth=0
|
||||
setlocal formatprg=black\ -q\ -
|
||||
|
||||
nnoremap <buffer> <silent> gq ggVGgq<C-o><C-o>
|
||||
|
||||
autocmd! BufWritePost <buffer> lua require('lint').try_lint()
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
local nvim_lint = require 'lint'
|
||||
|
||||
vim.api.nvim_set_keymap('n', '<LocalLeader>l', ':lua require(\'lint\').try_lint()<CR>', { noremap = true, unique = true })
|
||||
|
||||
require('lint').linters_by_ft = {
|
||||
nvim_lint.linters_by_ft = {
|
||||
haskell = { 'hlint' },
|
||||
javascript = { 'eslint' },
|
||||
lua = { 'luacheck' },
|
||||
markdown = { 'vale' },
|
||||
pandoc = { 'vale' },
|
||||
python = { 'flake8', 'mypy', 'pycodestyle', 'pylint' },
|
||||
python = { 'pylint', 'mypy', 'flake8' },
|
||||
sh = { 'shellcheck' },
|
||||
typescript = { 'eslint' },
|
||||
text = { 'vale' },
|
||||
}
|
||||
|
||||
nvim_lint.linters.flake8.args = { '--ignore', 'E133,E501,W503' }
|
||||
|
|
|
@ -70,6 +70,29 @@ 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')
|
||||
|
@ -211,22 +234,9 @@ nvim_lsp.hls.setup {
|
|||
capabilities = capabilities
|
||||
}
|
||||
|
||||
nvim_lsp.pylsp.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
pylsp = {
|
||||
plugins = {
|
||||
flake8 = {
|
||||
enabled = true,
|
||||
config = vim.fn.expand('~/.config/flake8')
|
||||
},
|
||||
pylint = {
|
||||
enabled = true,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
nvim_lsp.jedi_language_server.setup {
|
||||
on_attach = on_attach_python,
|
||||
capabilities = capabilities
|
||||
}
|
||||
|
||||
require('rust-tools').setup(rust_tool_opts)
|
||||
|
|
Loading…
Reference in a new issue