diff --git a/symlinks/config/nvim/lua/init/plugins.lua b/symlinks/config/nvim/lua/init/plugins.lua index be36b7d..0a8d03a 100644 --- a/symlinks/config/nvim/lua/init/plugins.lua +++ b/symlinks/config/nvim/lua/init/plugins.lua @@ -39,8 +39,6 @@ return require("packer").startup { -- Tools use "direnv/direnv.vim" -- Integration with Direnv 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 "rcarriga/nvim-dap-ui" -- UI components 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 "hrsh7th/nvim-cmp" -- completion integration 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 use "tjdevries/nlua.nvim" -- Built-in Lua integration with LSP diff --git a/symlinks/config/nvim/lua/lsp/diagnostic.lua b/symlinks/config/nvim/lua/lsp/diagnostic.lua index 9e0ce73..47deea6 100644 --- a/symlinks/config/nvim/lua/lsp/diagnostic.lua +++ b/symlinks/config/nvim/lua/lsp/diagnostic.lua @@ -2,17 +2,58 @@ -- - LSP diagnostics config - ------------------------------------------------------------------------------- -require("nvim-ale-diagnostic") +local null_ls = require('null-ls') -vim.lsp.handlers["textDocument/publishDiagnostics"] = - vim.lsp.with( - vim.lsp.diagnostic.on_publish_diagnostics, - { - underline = false, - virtual_text = false, - signs = true, - update_in_insert = false - } -) +null_ls.setup({ + sources = { + -- Python + null_ls.builtins.diagnostics.flake8, + null_ls.builtins.formatting.isort, + null_ls.builtins.formatting.autopep8, -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! * + autocmd BufWritePre 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, {}) diff --git a/symlinks/config/nvim/lua/lsp/server_config.lua b/symlinks/config/nvim/lua/lsp/server_config.lua index d629f10..740ffb0 100644 --- a/symlinks/config/nvim/lua/lsp/server_config.lua +++ b/symlinks/config/nvim/lua/lsp/server_config.lua @@ -12,81 +12,55 @@ M.on_attach = function(client, bufnr) vim.keymap.set( "n", "", - function() - vim.lsp.buf.definition() - end, + vim.lsp.buf.definition, opts ) vim.keymap.set( "n", "gD", - function() - vim.lsp.buf.declaration() - end, + vim.lsp.buf.declaration, opts ) vim.keymap.set( "n", "gr", - function() - vim.lsp.buf.references() - end, + vim.lsp.buf.references, opts ) vim.keymap.set( "n", "gi", - function() - vim.lsp.buf.implementation() - end, + vim.lsp.buf.implementation, opts ) vim.keymap.set( "n", "rn", - function() - vim.lsp.buf.rename() - end, + vim.lsp.buf.rename, opts ) vim.keymap.set( "n", "", - function() - vim.lsp.buf.signature_help() - end, + vim.lsp.buf.signature_help, opts ) vim.keymap.set( "n", "K", - function() - vim.lsp.buf.hover() - end, + vim.lsp.buf.hover, opts ) vim.keymap.set( "n", "", - function() - vim.lsp.buf.code_action() - end, + vim.lsp.buf.code_action, opts ) vim.keymap.set( "n", "ac", - function() - vim.lsp.buf.code_action() - end, - opts - ) - vim.keymap.set( - "n", - "a", - function() - vim.lsp.buf.code_action_range() - end, + vim.lsp.buf.code_action, opts ) end diff --git a/symlinks/config/nvim/plugin/ale.vim b/symlinks/config/nvim/plugin/ale.vim deleted file mode 100644 index d72a320..0000000 --- a/symlinks/config/nvim/plugin/ale.vim +++ /dev/null @@ -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 [W (ale_first) -nmap [w (ale_previous) -nmap ]w (ale_next) -nmap ]W (ale_last) diff --git a/symlinks/config/nvim/plugin/dap.lua b/symlinks/config/nvim/plugin/dap.lua index 1f105e0..f27ebd0 100644 --- a/symlinks/config/nvim/plugin/dap.lua +++ b/symlinks/config/nvim/plugin/dap.lua @@ -21,30 +21,22 @@ require("nvim-dap-virtual-text").setup() vim.keymap.set( "n", "db", - function() - dap.toggle_breakpoint() - end + dap.toggle_breakpoint ) vim.keymap.set( "n", "dc", - function() - dap.continue() - end + dap.continue ) vim.keymap.set( "n", "dso", - function() - dap.step_over() - end + dap.step_over ) vim.keymap.set( "n", "dsi", - function() - dap.step_into() - end + dap.step_into ) -- Nvim DAP UI diff --git a/symlinks/config/nvim/plugin/treesitter.lua b/symlinks/config/nvim/plugin/treesitter.lua index 9f3b35a..905f617 100644 --- a/symlinks/config/nvim/plugin/treesitter.lua +++ b/symlinks/config/nvim/plugin/treesitter.lua @@ -3,10 +3,46 @@ require "nvim-treesitter.configs".setup { highlight = { enable = true -- false will disable the whole extension }, + indent = { + enable = true + }, playground = { enable = true, disable = {}, updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code 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', + }, + }, + }, }