This commit is contained in:
Nareshkumar Rao 2025-05-18 17:49:42 +02:00
parent e51df8c732
commit 44613b53ef
6 changed files with 119 additions and 70 deletions

View File

@ -1,73 +1,94 @@
vim.lsp.config('lua_ls', { vim.lsp.config("lua_ls", {
on_init = function(client) on_init = function(client)
if client.workspace_folders then if client.workspace_folders then
local path = client.workspace_folders[1].name local path = client.workspace_folders[1].name
if if
path ~= vim.fn.stdpath('config') path ~= vim.fn.stdpath("config")
and (vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc')) and (vim.uv.fs_stat(path .. "/.luarc.json") or vim.uv.fs_stat(path .. "/.luarc.jsonc"))
then then
return return
end end
end end
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, { client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, {
runtime = { runtime = {
-- Tell the language server which version of Lua you're using (most -- Tell the language server which version of Lua you're using (most
-- likely LuaJIT in the case of Neovim) -- likely LuaJIT in the case of Neovim)
version = 'LuaJIT', version = "LuaJIT",
-- Tell the language server how to find Lua modules same way as Neovim -- Tell the language server how to find Lua modules same way as Neovim
-- (see `:h lua-module-load`) -- (see `:h lua-module-load`)
path = { path = {
'lua/?.lua', "lua/?.lua",
'lua/?/init.lua', "lua/?/init.lua",
}, },
}, },
-- Make the server aware of Neovim runtime files -- Make the server aware of Neovim runtime files
workspace = { workspace = {
checkThirdParty = false, checkThirdParty = false,
library = { library = {
vim.env.VIMRUNTIME vim.env.VIMRUNTIME,
-- Depending on the usage, you might want to add additional paths -- Depending on the usage, you might want to add additional paths
-- here. -- here.
-- '${3rd}/luv/library' -- '${3rd}/luv/library'
-- '${3rd}/busted/library' -- '${3rd}/busted/library'
} },
-- Or pull in all of 'runtimepath'. -- Or pull in all of 'runtimepath'.
-- NOTE: this is a lot slower and will cause issues when working on -- NOTE: this is a lot slower and will cause issues when working on
-- your own configuration. -- your own configuration.
-- See https://github.com/neovim/nvim-lspconfig/issues/3189 -- See https://github.com/neovim/nvim-lspconfig/issues/3189
-- library = { -- library = {
-- vim.api.nvim_get_runtime_file('', true), -- vim.api.nvim_get_runtime_file('', true),
-- } -- }
} },
}) })
end, end,
settings = { settings = {
Lua = {} Lua = {},
} },
}) })
vim.lsp.config('rust_analyzer', { vim.lsp.config("rust_analyzer", {
settings = { settings = {
['rust-analyzer'] = { ["rust-analyzer"] = {
checkOnSave = { checkOnSave = {
command = "clippy" command = "clippy",
} },
} },
} },
}) })
vim.api.nvim_create_autocmd("LspAttach", { vim.api.nvim_create_autocmd("LspAttach", {
callback = function(ev) callback = function(ev)
local opts = { buffer = ev.buf, remap = false } local opts = { buffer = ev.buf, remap = false }
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts) vim.keymap.set("n", "gd", function()
vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts) vim.lsp.buf.definition()
vim.keymap.set("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts) end, opts)
vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts) vim.keymap.set("n", "K", function()
vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts) vim.lsp.buf.hover()
vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts) end, opts)
vim.keymap.set("n", "<leader>ii", function() vim.keymap.set("n", "<leader>vd", function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) vim.diagnostic.open_float()
end, opts) end, opts)
end vim.keymap.set("n", "<leader>vrr", function()
vim.lsp.buf.references()
end, opts)
vim.keymap.set("n", "<leader>vca", function()
vim.lsp.buf.code_action()
end, opts)
vim.keymap.set("n", "<leader>vrn", function()
vim.lsp.buf.rename()
end, opts)
vim.keymap.set("n", "<leader>ii", function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
end, opts)
vim.keymap.set("n", "<leader>do", function()
require("dapui").toggle()
end, opts)
vim.keymap.set("n", "<leader>db", function()
require("dap").toggle_breakpoint()
end, opts)
vim.keymap.set("n", "<leader>dc", function()
require("dap").continue()
end, opts)
end,
}) })

View File

@ -10,11 +10,15 @@
"lualine.nvim": { "branch": "master", "commit": "15884cee63a8c205334ab13ab1c891cd4d27101a" }, "lualine.nvim": { "branch": "master", "commit": "15884cee63a8c205334ab13ab1c891cd4d27101a" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "d39a75bbce4b8aad5d627191ea915179c77c100f" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "d39a75bbce4b8aad5d627191ea915179c77c100f" },
"mason-null-ls.nvim": { "branch": "main", "commit": "de19726de7260c68d94691afb057fa73d3cc53e7" }, "mason-null-ls.nvim": { "branch": "main", "commit": "de19726de7260c68d94691afb057fa73d3cc53e7" },
"mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" },
"mason.nvim": { "branch": "main", "commit": "888d6ee499d8089a3a4be4309d239d6be1c1e6c0" }, "mason.nvim": { "branch": "main", "commit": "888d6ee499d8089a3a4be4309d239d6be1c1e6c0" },
"none-ls.nvim": { "branch": "main", "commit": "90e4a27ccaa25979a6b732b9f06dfa43b54957b7" }, "none-ls.nvim": { "branch": "main", "commit": "90e4a27ccaa25979a6b732b9f06dfa43b54957b7" },
"nvim-autopairs": { "branch": "master", "commit": "4d74e75913832866aa7de35e4202463ddf6efd1b" }, "nvim-autopairs": { "branch": "master", "commit": "4d74e75913832866aa7de35e4202463ddf6efd1b" },
"nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" },
"nvim-dap": { "branch": "master", "commit": "8df427aeba0a06c6577dc3ab82de3076964e3b8d" },
"nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" },
"nvim-lspconfig": { "branch": "master", "commit": "ac1dfbe3b60e5e23a2cff90e3bd6a3bc88031a57" }, "nvim-lspconfig": { "branch": "master", "commit": "ac1dfbe3b60e5e23a2cff90e3bd6a3bc88031a57" },
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
"nvim-tree.lua": { "branch": "master", "commit": "be5b788f2dc1522c73fb7afad9092331c8aebe80" }, "nvim-tree.lua": { "branch": "master", "commit": "be5b788f2dc1522c73fb7afad9092331c8aebe80" },
"nvim-treesitter": { "branch": "master", "commit": "066fd6505377e3fd4aa219e61ce94c2b8bdb0b79" }, "nvim-treesitter": { "branch": "master", "commit": "066fd6505377e3fd4aa219e61ce94c2b8bdb0b79" },
"nvim-web-devicons": { "branch": "master", "commit": "1fb58cca9aebbc4fd32b086cb413548ce132c127" }, "nvim-web-devicons": { "branch": "master", "commit": "1fb58cca9aebbc4fd32b086cb413548ce132c127" },

View File

@ -1,3 +1,3 @@
vim.g.mapleader = " " vim.g.mapleader = " "
vim.keymap.set("n", "<leader>pv", vim.cmd.NvimTreeToggle) vim.keymap.set("n", "<leader>pv", vim.cmd.NvimTreeToggle)
vim.keymap.set("t", "<C-w>h", "<C-\\><C-n>", { silent = true }) vim.keymap.set("t", "<Esc>", "<C-\\><C-n>", { silent = true })

View File

@ -34,5 +34,8 @@ vim.g.mapleader = " "
vim.g.loaded_netrw = 1 vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1 vim.g.loaded_netrwPlugin = 1
vim.g.clipboard = "osc52" vim.filetype.add({
vim.opt.clipboard = "unnamedplus" pattern = {
[".*/compose.*%.yaml"] = "yaml.docker-compose",
},
})

View File

@ -116,7 +116,9 @@ return {
opts = { opts = {
formatters_by_ft = { formatters_by_ft = {
typescript = { "prettier" }, typescript = { "prettier" },
jsx = { "prettier" }, javascript = { "prettier" },
typescriptreact = { "prettier" },
javascriptreact = { "prettier" },
lua = { "stylua" }, lua = { "stylua" },
rust = { "rustfmt", lsp_format = "fallback" }, rust = { "rustfmt", lsp_format = "fallback" },
}, },
@ -132,4 +134,9 @@ return {
config = true, config = true,
opts = {}, opts = {},
}, },
{
"rcarriga/nvim-dap-ui",
dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" },
opts = {},
},
} }

View File

@ -18,4 +18,18 @@ return {
}, },
opts = { ensure_installed = { "prettier", "stylua" } }, opts = { ensure_installed = { "prettier", "stylua" } },
}, },
{
"jay-babu/mason-nvim-dap.nvim",
dependencies = {
"mason-org/mason.nvim",
"mfussenegger/nvim-dap",
},
opts = {
ensure_installed = {
"netcoredbg",
"codelldb",
},
handlers = {},
},
},
} }