init: public

This commit is contained in:
2025-04-13 15:09:14 +08:00
parent 5995c2050b
commit 50247d94e8
253 changed files with 12964 additions and 567 deletions

View File

@@ -0,0 +1,4 @@
M = {}
return M

View File

@@ -0,0 +1,88 @@
local servers = {
"lua_ls",
"pyright",
"gopls",
"clangd",
"rust_analyzer",
"ts_ls",
"jsonls",
"cssls",
"nil_ls",
"html",
}
local extra_config = {
lua_ls = {
settings = {
Lua = {
workspace = {
library = {
vim.api.nvim_get_runtime_file("", true),
"${3rd}/luv/library",
"${3rd}/luassert/library",
}
},
diagnostics = {
globals = {
"vim"
}
},
completion = {
callSnippet = "Replace"
}
}
},
},
rust_analyzer = {
settings = {
rust_analyzer = {
check = {
command = "clippy"
},
formatting = {
command = { "rustfmt" },
},
}
},
},
}
local on_attach = function(client, bufnr)
vim.api.nvim_create_autocmd("CursorHold", {
buffer = bufnr,
callback = function()
local opts = {
focusable = false,
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
border = "rounded",
source = "always",
prefix = " ",
scope = "line",
}
vim.diagnostic.open_float(nil, opts)
end,
})
end
local capabilities = require("cmp_nvim_lsp").default_capabilities()
capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true,
}
local lspconfig = require("lspconfig")
for _, server in ipairs(servers) do
local extra = extra_config[server] or {}
local config = {
on_attach = on_attach,
capabilities = capabilities
}
for k, v in pairs(extra) do
config[k] = v
end
lspconfig[server].setup(config)
end
vim.diagnostic.config({
virtual_lines = true
})

View File

@@ -0,0 +1,7 @@
M = {
-- ensure_installed = require("plugins.lsp.servers")
ensure_installed = {}
}
return M

View File

@@ -0,0 +1,12 @@
M = {
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = ""
}
}
}
return M

View File

@@ -0,0 +1,29 @@
-- Keymaps
local opt = require("core.globals").keymap_opt
vim.keymap.set("n", "K", vim.lsp.buf.hover, opt)
vim.keymap.set("n", "<leader>lR", vim.lsp.buf.rename, opt)
vim.diagnostic.config({
virtual_text = { spacing = 4, prefix = "" },
signs = true,
underline = true,
update_in_insert = true,
severity_sort = true,
})
local signs = { Error = "", Warn = "", Hint = "", Info = "" }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
border = "single",
})
--[[ vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
border = "single",
focusable = false,
relative = "cursor",
}) ]]

View File

@@ -0,0 +1,6 @@
M = {}
vim.keymap.set("n", "<leader>o", "<cmd>Outline<CR>",
{ desc = "Toggle Outline" })
return M

View File

@@ -0,0 +1,15 @@
M = {
"lua_ls",
"pyright",
"gopls",
"clangd",
"rust_analyzer",
"ts_ls",
"jsonls",
"cssls",
"nil_ls",
"html",
}
return M

View File

@@ -0,0 +1,16 @@
M = {
bind = true, -- This is mandatory, otherwise border config won't get registered.
handler_opts = {
border = "rounded"
},
hint_prefix = "^ ",
toggle_key = "<C-k>",
}
vim.keymap.set({ 'n' }, '<leader>k', require('lsp_signature').toggle_float_win,
{ silent = true, noremap = true, desc = 'toggle signature' })
vim.keymap.set({ 'n' }, 'K', vim.lsp.buf.signature_help,
{ silent = true, noremap = true, desc = 'toggle signature' })
return M