diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 9bd8652..0aaca0a 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -8,25 +8,27 @@ "cmp-tmux": { "branch": "main", "commit": "95b1b921802e6f60627b3e76afb9380fddd87f9a" }, "cmp-treesitter": { "branch": "master", "commit": "13e4ef8f4dd5639fca2eb9150e68f47639a9b37d" }, "cmp_kitty": { "branch": "main", "commit": "a0716db2efb4c452600ef1e4a3ca610889279118" }, - "codeium.vim": { "branch": "main", "commit": "5b8f68d5c0e32ae97d073a56ff14dba5646ec223" }, + "codeium.vim": { "branch": "main", "commit": "bef9cbaa5c19ab85d8048f364bfc0ac8c7ab335d" }, "git-messenger.vim": { "branch": "master", "commit": "8a61bdfa351d4df9a9118ee1d3f45edbed617072" }, - "go.nvim": { "branch": "master", "commit": "d217a74fa823d0adef1a3680c3af562ae14e6854" }, + "go.nvim": { "branch": "master", "commit": "9ac3e6faa32d01479973f4ca368d00b7ae328646" }, "gruvbox.nvim": { "branch": "main", "commit": "6e4027ae957cddf7b193adfaec4a8f9e03b4555f" }, - "lazy.nvim": { "branch": "main", "commit": "83493db50a434a4c5c648faf41e2ead80f96e478" }, "guihua.lua": { "branch": "master", "commit": "9fb6795474918b492d9ab01b1ebaf85e8bf6fe0b" }, + "lazy.nvim": { "branch": "main", "commit": "83493db50a434a4c5c648faf41e2ead80f96e478" }, "lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, - "lualine.nvim": { "branch": "master", "commit": "8b56462bfb746760465264de41b4907310f113ec" }, + "lualine.nvim": { "branch": "master", "commit": "af4c3cf17206810880d2a93562e0a4c0d901c684" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "82c7cb08ddb836ad938b2708e50085f12a8825d2" }, + "mason.nvim": { "branch": "main", "commit": "3b5068f0fc565f337d67a2d315d935f574848ee7" }, "noice.nvim": { "branch": "main", "commit": "bf67d70bd7265d075191e7812d8eb42b9791f737" }, - "nui.nvim": { "branch": "main", "commit": "756c59f46057cd2d43619cd3a6d4e01b2aa60295" }, + "nui.nvim": { "branch": "main", "commit": "3dc46d725f7b94bee5117c0a699b57b1902b5d65" }, "nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" }, - "nvim-dap": { "branch": "master", "commit": "fc880e82059eb21c0fa896be60146e5f17680648" }, + "nvim-dap": { "branch": "master", "commit": "c43c2473ecb482a9d91f32c1d4c0098fffad3c7d" }, "nvim-dap-ui": { "branch": "master", "commit": "9720eb5fa2f41988e8770f973cd11b76dd568a5d" }, "nvim-html-css": { "branch": "main", "commit": "c072b05c56a40d3ec7874fa487723e6bef5d97f8" }, - "nvim-lspconfig": { "branch": "master", "commit": "1917b562a02f20885900b1da0f0ea25028ccedab" }, - "nvim-tree.lua": { "branch": "master", "commit": "041dbd18f440207ad161503a384e7c82d575db66" }, - "nvim-treesitter": { "branch": "master", "commit": "488bec03254207b1dd071be8cb1fb78434b6e777" }, + "nvim-lspconfig": { "branch": "master", "commit": "5b364bd4db0fb68a56ffe427a370920854acb834" }, + "nvim-tree.lua": { "branch": "master", "commit": "f7c09bd72e50e1795bd3afb9e2a2b157b4bfb3c3" }, + "nvim-treesitter": { "branch": "master", "commit": "f87882858438834d2fbb6379aa2be37de901751b" }, "nvim-treesitter-endwise": { "branch": "master", "commit": "60e8c288e011403f248b5f6478dde12bed8a6c55" }, - "nvim-web-devicons": { "branch": "master", "commit": "75df79feb02d5e0ec114e447453775d4d291ea03" }, + "nvim-web-devicons": { "branch": "master", "commit": "cb0c967c9723a76ccb1be0cc3a9a10e577d2f6ec" }, "plenary.nvim": { "branch": "master", "commit": "f7adfc4b3f4f91aab6caebf42b3682945fbc35be" }, "repl.nvim": { "branch": "master", "commit": "ec202eb5786b305c7d73b8cab5ee8fe69a2534a7" }, "telescope.nvim": { "branch": "master", "commit": "7011eaae0ac1afe036e30c95cf80200b8dc3f21a" }, @@ -36,4 +38,4 @@ "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, "vim-wordmotion": { "branch": "master", "commit": "81d9bd298376ab0dc465c85d55afa4cb8d5f47a1" }, "zen-mode.nvim": { "branch": "main", "commit": "78557d972b4bfbb7488e17b5703d25164ae64e6a" } -} +} \ No newline at end of file diff --git a/.config/nvim/lua/lsp.lua b/.config/nvim/lua/lsp.lua index cb6f73c..c5dc688 100644 --- a/.config/nvim/lua/lsp.lua +++ b/.config/nvim/lua/lsp.lua @@ -1,84 +1,3 @@ --- textDocument/diagnostic support until 0.10.0 is released -_timers = {} -local function setup_diagnostics(client, buffer) - if require("vim.lsp.diagnostic")._enable then - return - end - - local diagnostic_handler = function() - local params = vim.lsp.util.make_text_document_params(buffer) - client.request("textDocument/diagnostic", { textDocument = params }, function(err, result) - if err then - local err_msg = string.format("diagnostics error - %s", vim.inspect(err)) - vim.lsp.log.error(err_msg) - end - local diagnostic_items = {} - if result then - diagnostic_items = result.items - end - vim.lsp.diagnostic.on_publish_diagnostics( - nil, - vim.tbl_extend("keep", params, { diagnostics = diagnostic_items }), - { client_id = client.id } - ) - end) - end - - diagnostic_handler() -- to request diagnostics on buffer when first attaching - - vim.api.nvim_buf_attach(buffer, false, { - on_lines = function() - if _timers[buffer] then - vim.fn.timer_stop(_timers[buffer]) - end - _timers[buffer] = vim.fn.timer_start(200, diagnostic_handler) - end, - on_detach = function() - if _timers[buffer] then - vim.fn.timer_stop(_timers[buffer]) - end - end, - }) -end - --- adds ShowRubyDeps command to show dependencies in the quickfix list. --- add the `all` argument to show indirect dependencies as well -local function add_ruby_deps_command(client, bufnr) - vim.api.nvim_buf_create_user_command(bufnr, "ShowRubyDeps", - function(opts) - - local params = vim.lsp.util.make_text_document_params() - - local showAll = opts.args == "all" - - client.request("rubyLsp/workspace/dependencies", params, - function(error, result) - if error then - print("Error showing deps: " .. error) - return - end - - local qf_list = {} - for _, item in ipairs(result) do - if showAll or item.dependency then - table.insert(qf_list, { - text = string.format("%s (%s) - %s", - item.name, - item.version, - item.dependency), - - filename = item.path - }) - end - end - - vim.fn.setqflist(qf_list) - vim.cmd('copen') - end, bufnr) - end, {nargs = "?", complete = function() - return {"all"} - end}) -end @@ -86,38 +5,6 @@ end local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities.textDocument.completion.completionItem.snippetSupport = true --- LSP servers --- Stimulus -require'lspconfig'.stimulus_ls.setup{} --- Ruby -require("lspconfig").ruby_ls.setup({ - on_attach = function(client, buffer) - setup_diagnostics(client, buffer) - add_ruby_deps_command(client, buffer) - end, -}) --- CSS -require'lspconfig'.cssls.setup { - capabilities = capabilities, -} --- SQL -require'lspconfig'.sqlls.setup{} --- JavaScript -require'lspconfig'.eslint.setup{} --- HTML -require'lspconfig'.html.setup { - capabilities = capabilities, -} --- JSON -require'lspconfig'.jsonls.setup { - capabilities = capabilities, -} --- BASH -require'lspconfig'.bashls.setup{} --- Cucumber -require'lspconfig'.cucumber_language_server.setup{} --- Docker -require'lspconfig'.dockerls.setup{} require'lspconfig'local dap, dapui = require("dap"), require("dapui") dap.listeners.after.event_initialized["dapui_config"] = function() dapui.open() diff --git a/.config/nvim/lua/tsv/plugins/go-nvim.lua b/.config/nvim/lua/tsv/plugins/go-nvim.lua new file mode 100644 index 0000000..82fd4d5 --- /dev/null +++ b/.config/nvim/lua/tsv/plugins/go-nvim.lua @@ -0,0 +1,14 @@ +return { + "ray-x/go.nvim", + dependencies = { -- optional packages + "ray-x/guihua.lua", + "neovim/nvim-lspconfig", + "nvim-treesitter/nvim-treesitter", + }, + config = function() + require("go").setup() + end, + event = {"CmdlineEnter"}, + ft = {"go", 'gomod'}, + build = ':lua require("go.install").update_all_sync()' -- if you need to install/update all binaries +} diff --git a/.config/nvim/lua/tsv/plugins/lspconfig.lua b/.config/nvim/lua/tsv/plugins/lspconfig.lua index aa17ef6..e897ecf 100644 --- a/.config/nvim/lua/tsv/plugins/lspconfig.lua +++ b/.config/nvim/lua/tsv/plugins/lspconfig.lua @@ -1,6 +1,109 @@ return { "neovim/nvim-lspconfig", + dependencies = { + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + }, config = function() +-- textDocument/diagnostic support until 0.10.0 is released +_timers = {} +local function setup_diagnostics(client, buffer) + if require("vim.lsp.diagnostic")._enable then + return + end + + local diagnostic_handler = function() + local params = vim.lsp.util.make_text_document_params(buffer) + client.request("textDocument/diagnostic", { textDocument = params }, function(err, result) + if err then + local err_msg = string.format("diagnostics error - %s", vim.inspect(err)) + vim.lsp.log.error(err_msg) + end + local diagnostic_items = {} + if result then + diagnostic_items = result.items + end + vim.lsp.diagnostic.on_publish_diagnostics( + nil, + vim.tbl_extend("keep", params, { diagnostics = diagnostic_items }), + { client_id = client.id } + ) + end) + end + + diagnostic_handler() -- to request diagnostics on buffer when first attaching + + vim.api.nvim_buf_attach(buffer, false, { + on_lines = function() + if _timers[buffer] then + vim.fn.timer_stop(_timers[buffer]) + end + _timers[buffer] = vim.fn.timer_start(200, diagnostic_handler) + end, + on_detach = function() + if _timers[buffer] then + vim.fn.timer_stop(_timers[buffer]) + end + end, + }) +end + +-- adds ShowRubyDeps command to show dependencies in the quickfix list. +-- add the `all` argument to show indirect dependencies as well +local function add_ruby_deps_command(client, bufnr) + vim.api.nvim_buf_create_user_command(bufnr, "ShowRubyDeps", + function(opts) + + local params = vim.lsp.util.make_text_document_params() + + local showAll = opts.args == "all" + + client.request("rubyLsp/workspace/dependencies", params, + function(error, result) + if error then + print("Error showing deps: " .. error) + return + end + + local qf_list = {} + for _, item in ipairs(result) do + if showAll or item.dependency then + table.insert(qf_list, { + text = string.format("%s (%s) - %s", + item.name, + item.version, + item.dependency), + + filename = item.path + }) + end + end + + vim.fn.setqflist(qf_list) + vim.cmd('copen') + end, bufnr) + end, {nargs = "?", complete = function() + return {"all"} + end}) +end + require("mason").setup() + require("mason-lspconfig").setup({ + automatic_installation = true, + }) + require("mason-lspconfig").setup_handlers({ + function(server_name) + require("lspconfig")[server_name].setup({}) + end, + ["ruby_ls"] = function() + require("lspconfig").ruby_ls.setup({ + on_attach = function(client, buffer) + setup_diagnostics(client, buffer) + add_ruby_deps_command(client, buffer) + end, + }) + end + }) + vim.keymap.set('n', 'ld', function() vim.lsp.buf.definition() end, bufopts) vim.keymap.set('n', 'la', function() vim.lsp.buf.code_action() end, bufopts) vim.keymap.set('n', 'lK', vim.lsp.buf.signature_help, {}) vim.keymap.set('n', 'lq', vim.diagnostic.setloclist, {})