Skip to content

Commit

Permalink
nvim: Update rust config and add nvim dap
Browse files Browse the repository at this point in the history
  • Loading branch information
Attamusc committed Oct 31, 2023
1 parent 1267752 commit 7f12681
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dot_config/nvim/lua/atta/main/general.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ local function general_settings()
opt.ttimeoutlen = 0

-- When switching buffers, prefer ones that are already open vs opening a new duplicate
opt.switchbuf = "useopen"
-- opt.switchbuf = "useopen"

-- Automatically indent inside of blocks per the language rules
opt.autoindent = true
Expand Down
34 changes: 33 additions & 1 deletion dot_config/nvim/lua/atta/plugins/lsp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,39 @@ function M.config()
opts = vim.tbl_deep_extend("force", {}, options, opts or {})

if server == "rust_analyzer" then
rust_tools.setup(opts)
local mason_registry = require("mason-registry")
local rust_tools_dap = require("rust-tools.dap")

local codelldb = mason_registry.get_package("codelldb")
local extension_path = codelldb:get_install_path() .. "/extension/"
local codelldb_path = extension_path .. "adapter/codelldb"
local liblldb_path = extension_path .. "lldb/lib/liblldb.dylib"

rust_options = {
dap = {
adapter = rust_tools_dap.get_codelldb_adapter(codelldb_path, liblldb_path),
},
server = vim.tbl_deep_extend("force", opts, {
on_attach = function(client, bufnr)
on_attach(client, bufnr)

vim.keymap.set("n", "K", rust_tools.hover_actions.hover_actions, { buffer = bufnr })
vim.keymap.set(
"n",
"<leader>a",
rust_tools.code_action_group.code_action_group,
{ buffer = bufnr }
)
end,
}),
tools = {
hover_actions = {
auto_focus = true,
},
},
}

rust_tools.setup(rust_options)
else
lspconfig[server].setup(opts)
end
Expand Down
2 changes: 1 addition & 1 deletion dot_config/nvim/lua/atta/plugins/lspsaga.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function M.config()
utils.noremap("n", "K", "<cmd>Lspsaga hover_doc<CR>", { silent = true })

-- code action
utils.noremap({ "n", "v" }, "<leader>ca", "<cmd>Lspsaga code_action<CR>", { silent = true })
utils.noremap({ "n", "v" }, "<leader>a", "<cmd>Lspsaga code_action<CR>", { silent = true })

-- diagnostics
utils.noremap("n", "<leader>cd", "<cmd>Lspsaga show_line_diagnostics<CR>", { silent = true })
Expand Down
1 change: 1 addition & 0 deletions dot_config/nvim/lua/atta/plugins/mason.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ local language_servers = {
}

local tools = {
"codelldb",
"eslint_d",
"black",
"rubocop",
Expand Down
27 changes: 27 additions & 0 deletions dot_config/nvim/lua/atta/plugins/nvim_dap.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
local M = {
"mfussenegger/nvim-dap",
"rcarriga/nvim-dap-ui",
}

function M.config()
local dap = require("dap")
local dapui = require("dapui")

dapui.setup()

dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open()
end
dap.listeners.after.event_terminated["dapui_config"] = function()
dapui.close()
end
dap.listeners.after.event_exited["dapui_config"] = function()
dapui.close()
end

vim.keymap.set("n", "<leader>dt", ":DapToggleBreakpoint<cr>")
vim.keymap.set("n", "<leader>dx", ":DapTerminate<cr>")
vim.keymap.set("n", "<leader>do", ":DapStepOver<cr>")
end

return M
4 changes: 4 additions & 0 deletions dot_config/private_zsh/config/rust.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if [[ -d "$HOME/.cargo" ]]
then
source "$HOME/.cargo/env"
fi
2 changes: 1 addition & 1 deletion dot_config/private_zsh/private_functions/c
Original file line number Diff line number Diff line change
@@ -1 +1 @@
z $PROJECTS/$1;
cd $PROJECTS/$1;

0 comments on commit 7f12681

Please sign in to comment.