Update diagnostic settings for nvim

pull/2/head
Ensar Sarajčić 2022-04-27 18:46:14 +02:00
parent 774d6d028e
commit 58f395081f
6 changed files with 104 additions and 100 deletions

View File

@ -39,8 +39,6 @@ return require("packer").startup {
-- Tools -- Tools
use "direnv/direnv.vim" -- Integration with Direnv use "direnv/direnv.vim" -- Integration with Direnv
use "vim-test/vim-test" -- Running tests from vim use "vim-test/vim-test" -- Running tests from vim
use "dense-analysis/ale" -- Asynchronous Lint Engine - used for linting, not for LSP
use "nathunsmitty/nvim-ale-diagnostic" -- Neovim LSP + ALE integration
use "mfussenegger/nvim-dap" -- Debug Adapter Protocol use "mfussenegger/nvim-dap" -- Debug Adapter Protocol
use "rcarriga/nvim-dap-ui" -- UI components for DAP use "rcarriga/nvim-dap-ui" -- UI components for DAP
use "theHamsta/nvim-dap-virtual-text" -- Virtual text display for DAP use "theHamsta/nvim-dap-virtual-text" -- Virtual text display for DAP
@ -87,6 +85,7 @@ return require("packer").startup {
use "quangnguyen30192/cmp-nvim-ultisnips" -- Ultisnips source for nvim-cmp use "quangnguyen30192/cmp-nvim-ultisnips" -- Ultisnips source for nvim-cmp
use "hrsh7th/nvim-cmp" -- completion integration use "hrsh7th/nvim-cmp" -- completion integration
use "nvim-lua/lsp_extensions.nvim" -- LSP extensions (like closing labels for Dart) use "nvim-lua/lsp_extensions.nvim" -- LSP extensions (like closing labels for Dart)
use "jose-elias-alvarez/null-ls.nvim" -- Linting and formatting
-- LSP language specific -- LSP language specific
use "tjdevries/nlua.nvim" -- Built-in Lua integration with LSP use "tjdevries/nlua.nvim" -- Built-in Lua integration with LSP

View File

@ -2,17 +2,58 @@
-- - LSP diagnostics config - -- - LSP diagnostics config -
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
require("nvim-ale-diagnostic") local null_ls = require('null-ls')
vim.lsp.handlers["textDocument/publishDiagnostics"] = null_ls.setup({
vim.lsp.with( sources = {
vim.lsp.diagnostic.on_publish_diagnostics, -- Python
{ null_ls.builtins.diagnostics.flake8,
underline = false, null_ls.builtins.formatting.isort,
virtual_text = false, null_ls.builtins.formatting.autopep8,
signs = true,
update_in_insert = false
}
)
vim.g.diagnostic_enable_virtual_text = 1 -- Kotlin
null_ls.builtins.formatting.ktlint,
null_ls.builtins.diagnostics.ktlint,
-- C++ and C
null_ls.builtins.formatting.clang_format,
-- Cmake
null_ls.builtins.formatting.cmake_format,
-- Lua
null_ls.builtins.formatting.lua_format,
-- Dart
null_ls.builtins.formatting.dart_format,
-- Go
null_ls.builtins.formatting.gofmt,
-- Rust
null_ls.builtins.formatting.rustfmt,
-- Java
null_ls.builtins.formatting.google_java_format,
-- General
null_ls.builtins.formatting.trim_newlines,
null_ls.builtins.formatting.trim_whitespace,
null_ls.builtins.hover.dictionary,
},
on_attach = function(client)
if client.resolved_capabilities.document_formatting then
vim.cmd([[
augroup LspFormatting
autocmd! * <buffer>
autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_seq_sync()
augroup END
]])
end
end
})
vim.keymap.set("n", "]w", vim.diagnostic.goto_next)
vim.keymap.set("n", "[w", vim.diagnostic.goto_prev)
vim.api.nvim_create_user_command("Warnings", vim.diagnostic.setloclist, {})
vim.api.nvim_create_user_command("Format", vim.lsp.buf.formatting, {})

View File

@ -12,81 +12,55 @@ M.on_attach = function(client, bufnr)
vim.keymap.set( vim.keymap.set(
"n", "n",
"<C-]>", "<C-]>",
function() vim.lsp.buf.definition,
vim.lsp.buf.definition()
end,
opts opts
) )
vim.keymap.set( vim.keymap.set(
"n", "n",
"gD", "gD",
function() vim.lsp.buf.declaration,
vim.lsp.buf.declaration()
end,
opts opts
) )
vim.keymap.set( vim.keymap.set(
"n", "n",
"gr", "gr",
function() vim.lsp.buf.references,
vim.lsp.buf.references()
end,
opts opts
) )
vim.keymap.set( vim.keymap.set(
"n", "n",
"gi", "gi",
function() vim.lsp.buf.implementation,
vim.lsp.buf.implementation()
end,
opts opts
) )
vim.keymap.set( vim.keymap.set(
"n", "n",
"<Leader>rn", "<Leader>rn",
function() vim.lsp.buf.rename,
vim.lsp.buf.rename()
end,
opts opts
) )
vim.keymap.set( vim.keymap.set(
"n", "n",
"<C-k>", "<C-k>",
function() vim.lsp.buf.signature_help,
vim.lsp.buf.signature_help()
end,
opts opts
) )
vim.keymap.set( vim.keymap.set(
"n", "n",
"K", "K",
function() vim.lsp.buf.hover,
vim.lsp.buf.hover()
end,
opts opts
) )
vim.keymap.set( vim.keymap.set(
"n", "n",
"<A-CR>", "<A-CR>",
function() vim.lsp.buf.code_action,
vim.lsp.buf.code_action()
end,
opts opts
) )
vim.keymap.set( vim.keymap.set(
"n", "n",
"<Leader>ac", "<Leader>ac",
function() vim.lsp.buf.code_action,
vim.lsp.buf.code_action()
end,
opts
)
vim.keymap.set(
"n",
"<Leader>a",
function()
vim.lsp.buf.code_action_range()
end,
opts opts
) )
end end

View File

@ -1,38 +0,0 @@
" -----------------------------------------------------------------------------
" - ALE Plugin configuration -
" -----------------------------------------------------------------------------
" ALE Options
let g:ale_disable_lsp = 1 " Disable LSP, we have other stuff for that
let g:ale_fix_on_save = 1 " Default
" ALE Linters configuration
let g:ale_linters = {}
let g:ale_linters.python = ['flake8']
let g:ale_linters.kotlin = ['ktlint']
let g:ale_linters.clojure = []
let g:ale_linters.cs = ['OmniSharp']
let g:ale_linters.cpp = ['clang']
let g:ale_linters.c = g:ale_linters.cpp
" ALE Fixers configuration
let g:ale_fixers = {}
let g:ale_fixers['*'] = ['remove_trailing_lines', 'trim_whitespace']
let g:ale_fixers.python = ['autopep8', 'isort']
let g:ale_fixers.dart = ['dartfmt']
let g:ale_fixers.lua = ['luafmt']
let g:ale_fixers.go = ['gofmt']
let g:ale_fixers.cpp = ['clang-format', 'clangtidy']
let g:ale_fixers.c = g:ale_fixers.cpp
let g:ale_fixers.cmake = ['cmakeformat']
let g:ale_fixers.java = ['google_java_format']
let g:ale_fixers.rust = ['rustfmt']
" Additional Java options
let g:ale_java_google_java_format_options = '--aosp'
" Warnings navigation
nmap <silent> [W <Plug>(ale_first)
nmap <silent> [w <Plug>(ale_previous)
nmap <silent> ]w <Plug>(ale_next)
nmap <silent> ]W <Plug>(ale_last)

View File

@ -21,30 +21,22 @@ require("nvim-dap-virtual-text").setup()
vim.keymap.set( vim.keymap.set(
"n", "n",
"<leader>db", "<leader>db",
function() dap.toggle_breakpoint
dap.toggle_breakpoint()
end
) )
vim.keymap.set( vim.keymap.set(
"n", "n",
"<leader>dc", "<leader>dc",
function() dap.continue
dap.continue()
end
) )
vim.keymap.set( vim.keymap.set(
"n", "n",
"<leader>dso", "<leader>dso",
function() dap.step_over
dap.step_over()
end
) )
vim.keymap.set( vim.keymap.set(
"n", "n",
"<leader>dsi", "<leader>dsi",
function() dap.step_into
dap.step_into()
end
) )
-- Nvim DAP UI -- Nvim DAP UI

View File

@ -3,10 +3,46 @@ require "nvim-treesitter.configs".setup {
highlight = { highlight = {
enable = true -- false will disable the whole extension enable = true -- false will disable the whole extension
}, },
indent = {
enable = true
},
playground = { playground = {
enable = true, enable = true,
disable = {}, disable = {},
updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
persist_queries = false -- Whether the query persists across vim sessions persist_queries = false -- Whether the query persists across vim sessions
} },
textobjects = {
select = {
enable = true,
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
keymaps = {
-- You can use the capture groups defined in textobjects.scm
['af'] = '@function.outer',
['if'] = '@function.inner',
['ac'] = '@class.outer',
['ic'] = '@class.inner',
},
},
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
[']m'] = '@function.outer',
[']]'] = '@class.outer',
},
goto_next_end = {
[']M'] = '@function.outer',
[']['] = '@class.outer',
},
goto_previous_start = {
['[m'] = '@function.outer',
['[['] = '@class.outer',
},
goto_previous_end = {
['[M'] = '@function.outer',
['[]'] = '@class.outer',
},
},
},
} }