diff --git a/init.lua b/init.lua index 27fda379..d9a4f918 100644 --- a/init.lua +++ b/init.lua @@ -90,6 +90,10 @@ require('lazy').setup({ }, }, + { + 'simrat39/rust-tools.nvim', + }, + { -- Autocompletion 'hrsh7th/nvim-cmp', @@ -179,7 +183,7 @@ require('lazy').setup({ -- These are some example plugins that I've included in the kickstart repository. -- Uncomment any of the lines below to enable them. require 'kickstart.plugins.autoformat', - -- require 'kickstart.plugins.debug', + require 'kickstart.plugins.debug', -- NOTE: The import below automatically adds your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping @@ -445,7 +449,14 @@ local servers = { -- clangd = {}, -- gopls = {}, -- pyright = {}, - -- rust_analyzer = {}, + -- rust_analyzer = { + -- inlayHints = { + -- enabled = true, + -- typeHints = { + -- enable = true, + -- }, + -- }, + -- }, -- tsserver = {}, -- eslint = {}, lua_ls = { @@ -535,3 +546,59 @@ cmp.setup { -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et +local rt = require("rust-tools") + +rt.setup({ + -- dap = { + -- adapter = { + -- type = 'server', + -- port = "${port}", + -- executable = { + -- command = codelldb_path, + -- args = { "--port", "${port}" }, + -- } + -- } + -- }, + server = { + on_attach = function(_, bufnr) + local nmap = function(keys, func, desc) + if desc then + desc = 'LSP: ' .. desc + end + + vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) + end + + nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') + + nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') + nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation') + nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') + nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + + -- See `:help K` for why this keymap + nmap('K', vim.lsp.buf.hover, 'Hover Documentation') + nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') + + -- Lesser used LSP functionality + nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') + nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') + nmap('wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, '[W]orkspace [L]ist Folders') + -- Hover actions + vim.keymap.set("n", "", rt.hover_actions.hover_actions, { buffer = bufnr }) + -- Code action groups + vim.keymap.set("n", "ca", rt.code_action_group.code_action_group, + { desc = '[C]ode [A]ctions', buffer = bufnr }) + end, + }, + tools = { + hover_actions = { + auto_focus = true, + }, + }, +}) diff --git a/lua/custom/plugins/debug.lua b/lua/custom/plugins/debug.lua deleted file mode 100644 index 5d456f34..00000000 --- a/lua/custom/plugins/debug.lua +++ /dev/null @@ -1,22 +0,0 @@ -return { - 'puremourning/vimspector', - config = function() - vim.cmd([[ - let g:vimspector_sidebar_width = 40 - let g:vimspector_bottombar_height = 15 - let g:vimspector_terminal_maxwidth = 85 -]]) - -- Vimspector - vim.cmd([[ - nmap call vimspector#Launch() - nmap call vimspector#StepOver() - nmap call vimspector#Reset() - " nmap call vimspector#StepOver()") - nmap call vimspector#StepOut()") - nmap call vimspector#StepInto()") - ]]) - vim.keymap.set('n', "Db", ":call vimspector#ToggleBreakpoint()") - vim.keymap.set('n', "Dw", ":call vimspector#AddWatch()") - vim.keymap.set('n', "De", ":call vimspector#Evaluate()") - end, -} diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index 000bcb8f..80d80841 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -19,7 +19,7 @@ return { 'jay-babu/mason-nvim-dap.nvim', -- Add your own debuggers here - 'leoluz/nvim-dap-go', + -- 'leoluz/nvim-dap-go', }, config = function() local dap = require 'dap' @@ -38,19 +38,22 @@ return { -- online, please don't ask me how to install them :) ensure_installed = { -- Update this to ensure that you have the debuggers for the langs you want - 'delve', + -- 'delve', + -- 'codelldb' }, } -- Basic debugging keymaps, feel free to change to your liking! - vim.keymap.set('n', '', dap.continue) - vim.keymap.set('n', '', dap.step_into) - vim.keymap.set('n', '', dap.step_over) - vim.keymap.set('n', '', dap.step_out) - vim.keymap.set('n', 'b', dap.toggle_breakpoint) + vim.keymap.set('n', '', dap.continue, { desc = "Start debugger" }) + vim.keymap.set('n', '', dap.step_into, { desc = "Step into" }) + vim.keymap.set('n', '', dap.step_over, { desc = "Step over" }) + vim.keymap.set('n', '', dap.step_out, { desc = "Step out" }) + vim.keymap.set('n', 'b', dap.toggle_breakpoint, { desc = "Toggle breakpoint" }) vim.keymap.set('n', 'B', function() - dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ') - end) + dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ') + end + , + { desc = "Breakpoint condition" }) -- Dap UI setup -- For more information, see |:help nvim-dap-ui| @@ -77,7 +80,11 @@ return { dap.listeners.before.event_terminated['dapui_config'] = dapui.close dap.listeners.before.event_exited['dapui_config'] = dapui.close + -- local mason_registry = require("mason-registry") + -- + -- local codelldb = mason_registry.get_package('codelldb') + -- local extension_path = codelldb:get_install_path() .. "/extension/" -- Install golang specific config - require('dap-go').setup() + -- require('dap-go').setup() end, }