dotfiles/symlinks/config/nvim/lua/lsp/diagnostic.lua

61 lines
1.8 KiB
Lua
Raw Normal View History

2021-02-23 11:27:32 +00:00
-------------------------------------------------------------------------------
-- - LSP diagnostics config -
-------------------------------------------------------------------------------
2022-04-27 16:46:14 +00:00
local null_ls = require('null-ls')
null_ls.setup({
sources = {
-- Python
null_ls.builtins.diagnostics.flake8,
null_ls.builtins.formatting.isort,
null_ls.builtins.formatting.autopep8,
-- 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,
null_ls.builtins.code_actions.gitsigns,
2022-04-27 16:46:14 +00:00
},
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, {})