dev: automated commit - 2025-12-22 17:45:39
This commit is contained in:
parent
2879a2ca5d
commit
00f3778fbf
4 changed files with 80 additions and 81 deletions
1
init.lua
1
init.lua
|
|
@ -7,6 +7,7 @@ require("config.options")
|
||||||
require("config.remap")
|
require("config.remap")
|
||||||
require("config.autocomands")
|
require("config.autocomands")
|
||||||
require("config.lazy")
|
require("config.lazy")
|
||||||
|
require("config.lsp")
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("VimEnter", {
|
vim.api.nvim_create_autocmd("VimEnter", {
|
||||||
callback = function()
|
callback = function()
|
||||||
|
|
|
||||||
|
|
@ -49,3 +49,16 @@ vim.filetype.add({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
|
group = vim.api.nvim_create_augroup("lsp", { clear = true }),
|
||||||
|
callback = function(ev)
|
||||||
|
local opts = { buffer = ev.buf, silent = true }
|
||||||
|
nmap("K", vim.lsp.buf.hover, vim.tbl_extend("force", opts, { desc = "Hover Doc" }))
|
||||||
|
nmap("<C-h>", vim.lsp.buf.signature_help, vim.tbl_extend("force", opts, { desc = "Signature Help" }))
|
||||||
|
nmap("<leader>r", vim.lsp.buf.rename, vim.tbl_extend("force", opts, { desc = "Rename" }))
|
||||||
|
nmap("<leader>ca", vim.lsp.buf.code_action, vim.tbl_extend("force", opts, { desc = "Code Action" }))
|
||||||
|
nmap("vd", vim.diagnostic.open_float, vim.tbl_extend("force", opts, { desc = "View Diagnostics" }))
|
||||||
|
nmap("<leader>lr", "<cmd>LspRestart<CR>", vim.tbl_extend("force", opts, { desc = "Restart LSP" }))
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
|
||||||
42
lua/config/lsp.lua
Normal file
42
lua/config/lsp.lua
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
vim.lsp.enable({
|
||||||
|
"gopls",
|
||||||
|
"jsonls",
|
||||||
|
"clangd",
|
||||||
|
"lua_ls",
|
||||||
|
"yamlls",
|
||||||
|
"graphql",
|
||||||
|
"html",
|
||||||
|
"cssls",
|
||||||
|
"omnisharp",
|
||||||
|
"svelte",
|
||||||
|
"templ",
|
||||||
|
"tinymist",
|
||||||
|
"jdtls",
|
||||||
|
"nixd",
|
||||||
|
"qmlls",
|
||||||
|
"zls",
|
||||||
|
"tsgo",
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
|
group = vim.api.nvim_create_augroup("lsp", { clear = true }),
|
||||||
|
callback = function(ev)
|
||||||
|
local opts = { buffer = ev.buf, silent = true }
|
||||||
|
nmap("K", vim.lsp.buf.hover, vim.tbl_extend("force", opts, { desc = "Hover Doc" }))
|
||||||
|
nmap("<C-h>", vim.lsp.buf.signature_help, vim.tbl_extend("force", opts, { desc = "Signature Help" }))
|
||||||
|
nmap("<leader>r", vim.lsp.buf.rename, vim.tbl_extend("force", opts, { desc = "Rename" }))
|
||||||
|
nmap("<leader>ca", vim.lsp.buf.code_action, vim.tbl_extend("force", opts, { desc = "Code Action" }))
|
||||||
|
nmap("vd", vim.diagnostic.open_float, vim.tbl_extend("force", opts, { desc = "View Diagnostics" }))
|
||||||
|
nmap("<leader>lr", "<cmd>LspRestart<CR>", vim.tbl_extend("force", opts, { desc = "Restart LSP" }))
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Enhance floating preview windows
|
||||||
|
local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview
|
||||||
|
function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
|
||||||
|
opts = opts or {}
|
||||||
|
opts.border = opts.border or "rounded"
|
||||||
|
opts.max_width = opts.max_width or 80
|
||||||
|
opts.max_height = opts.max_height or 20
|
||||||
|
return orig_util_open_floating_preview(contents, syntax, opts, ...)
|
||||||
|
end
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
local M = {
|
return {
|
||||||
"neovim/nvim-lspconfig",
|
{
|
||||||
dependencies = {
|
"j-hui/fidget.nvim",
|
||||||
|
opts = {},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"folke/lazydev.nvim",
|
"folke/lazydev.nvim",
|
||||||
ft = "lua",
|
ft = "lua",
|
||||||
|
|
@ -10,10 +12,6 @@ local M = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"j-hui/fidget.nvim",
|
|
||||||
opts = {},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"ray-x/go.nvim",
|
"ray-x/go.nvim",
|
||||||
ft = "go",
|
ft = "go",
|
||||||
|
|
@ -27,59 +25,4 @@ local M = {
|
||||||
vim.cmd([[silent! GoModTidy]])
|
vim.cmd([[silent! GoModTidy]])
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function M.config()
|
|
||||||
local lspconfig = require("lspconfig")
|
|
||||||
|
|
||||||
vim.lsp.enable({ "tsgo" })
|
|
||||||
|
|
||||||
local servers = {
|
|
||||||
"gopls",
|
|
||||||
"jsonls",
|
|
||||||
"clangd",
|
|
||||||
"lua_ls",
|
|
||||||
"yamlls",
|
|
||||||
"graphql",
|
|
||||||
"html",
|
|
||||||
"cssls",
|
|
||||||
"omnisharp",
|
|
||||||
"svelte",
|
|
||||||
"templ",
|
|
||||||
"tinymist",
|
|
||||||
"jdtls",
|
|
||||||
"nixd",
|
|
||||||
"qmlls",
|
|
||||||
"zls",
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, server in ipairs(servers) do
|
|
||||||
lspconfig[server].setup({
|
|
||||||
on_attach = function(client, bufnr)
|
|
||||||
local opts = { buffer = bufnr, silent = true }
|
|
||||||
|
|
||||||
nmap("K", vim.lsp.buf.hover, vim.tbl_extend("force", opts, { desc = "Hover Doc" }))
|
|
||||||
nmap("<C-h>", vim.lsp.buf.signature_help, vim.tbl_extend("force", opts, { desc = "Signature Help" }))
|
|
||||||
nmap("<leader>r", vim.lsp.buf.rename, vim.tbl_extend("force", opts, { desc = "Rename" }))
|
|
||||||
nmap("<leader>ca", vim.lsp.buf.code_action, vim.tbl_extend("force", opts, { desc = "Code Action" }))
|
|
||||||
nmap("vd", vim.diagnostic.open_float, vim.tbl_extend("force", opts, { desc = "View Diagnostics" }))
|
|
||||||
nmap("<leader>lr", "<cmd>LspRestart<CR>", vim.tbl_extend("force", opts, { desc = "Restart LSP" }))
|
|
||||||
|
|
||||||
if client.server_capabilities.documentHighlightProvider then
|
|
||||||
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
|
||||||
buffer = bufnr,
|
|
||||||
callback = vim.lsp.buf.document_highlight,
|
|
||||||
})
|
|
||||||
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
|
|
||||||
buffer = bufnr,
|
|
||||||
callback = vim.lsp.buf.clear_references,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
||||||
--
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue