2021-02-23 11:27:32 +00:00
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
-- - LSP diagnostics config -
|
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
|
2022-04-28 13:53:54 +00:00
|
|
|
local null_ls = require("null-ls")
|
2022-04-27 16:46:14 +00:00
|
|
|
|
|
|
|
null_ls.setup({
|
2022-04-28 13:53:54 +00:00
|
|
|
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.stylua,
|
2022-04-29 07:46:45 +00:00
|
|
|
null_ls.builtins.diagnostics.luacheck.with({
|
|
|
|
extra_args = { "--config", vim.fn.stdpath("config") .. "/.luacheckrc" },
|
|
|
|
}),
|
2022-04-28 13:53:54 +00:00
|
|
|
|
|
|
|
-- 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-29 07:46:45 +00:00
|
|
|
null_ls.builtins.code_actions.refactoring,
|
2022-04-28 13:53:54 +00:00
|
|
|
},
|
|
|
|
on_attach = function(client)
|
|
|
|
if client.resolved_capabilities.document_formatting then
|
|
|
|
vim.cmd([[
|
2022-04-27 16:46:14 +00:00
|
|
|
augroup LspFormatting
|
|
|
|
autocmd! * <buffer>
|
|
|
|
autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_seq_sync()
|
|
|
|
augroup END
|
|
|
|
]])
|
2022-04-28 13:53:54 +00:00
|
|
|
end
|
|
|
|
end,
|
2022-04-27 16:46:14 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
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, {})
|