added latex support and reorg ftplugins
This commit is contained in:
parent
7f1b34fd6f
commit
f2eaf7c67a
38 changed files with 600 additions and 234 deletions
|
|
@ -1,7 +1,6 @@
|
|||
return {
|
||||
'neovim/nvim-lspconfig',
|
||||
dependencies = {
|
||||
-- Automatically install LSPs to stdpath for neovim
|
||||
{ 'williamboman/mason.nvim', config = true },
|
||||
'williamboman/mason-lspconfig.nvim',
|
||||
'WhoIsSethDaniel/mason-tool-installer.nvim',
|
||||
|
|
@ -13,77 +12,35 @@ return {
|
|||
opts = {},
|
||||
},
|
||||
|
||||
-- Additional lua configuration, makes nvim stuff amazing!
|
||||
-- Additional Lua configuration
|
||||
'folke/neodev.nvim',
|
||||
},
|
||||
config = function()
|
||||
local on_attach = function(client, 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
|
||||
|
||||
-- Key mappings for LSP features
|
||||
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
||||
nmap('<leader>ca', function()
|
||||
vim.lsp.buf.code_action(require('telescope.themes').get_dropdown({
|
||||
winblend = 10,
|
||||
previewer = false,
|
||||
}))
|
||||
end, '[C]ode [A]ction')
|
||||
|
||||
nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
|
||||
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
|
||||
nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
|
||||
nmap('<leader>D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition')
|
||||
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
|
||||
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
||||
|
||||
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
|
||||
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
|
||||
|
||||
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
|
||||
nmap('gv', ':vsplit<CR>:lua vim.lsp.buf.declaration()<CR>', '[G]oto [V]irtual Text')
|
||||
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
|
||||
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
|
||||
nmap('<leader>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, '[W]orkspace [L]ist Folders')
|
||||
end
|
||||
|
||||
-- General capabilities for LSP servers
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
if pcall(require, 'cmp_nvim_lsp') then
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
local has_cmp, cmp_nvim_lsp = pcall(require, 'cmp_nvim_lsp')
|
||||
if has_cmp then
|
||||
capabilities = cmp_nvim_lsp.default_capabilities()
|
||||
end
|
||||
|
||||
require('neodev').setup({
|
||||
library = {
|
||||
plugins = { 'nvim-dap-ui' },
|
||||
types = true,
|
||||
},
|
||||
})
|
||||
|
||||
-- LSP server configurations
|
||||
local servers = {
|
||||
bashls = { filetypes = { 'sh', 'bash' } },
|
||||
clangd = {},
|
||||
gopls = {
|
||||
settings = {
|
||||
gopls = {
|
||||
gofumpt = true,
|
||||
staticcheck = true,
|
||||
completeUnimported = true,
|
||||
usePlaceholders = true,
|
||||
analysis = {
|
||||
unusedParams = true,
|
||||
analyses = {
|
||||
unusedparams = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
htmx = {
|
||||
filetypes = { 'html' },
|
||||
},
|
||||
ruff_lsp = {
|
||||
filetypes = { 'python' },
|
||||
},
|
||||
ruff_lsp = { filetypes = { 'python' } },
|
||||
pyright = {
|
||||
filetypes = { 'python' },
|
||||
settings = {
|
||||
|
|
@ -97,102 +54,99 @@ return {
|
|||
},
|
||||
},
|
||||
},
|
||||
rust_analyzer = {
|
||||
cmd = { 'rustup', 'run', 'stable', 'rust-analyzer' },
|
||||
rust_analyzer = { cmd = { 'rustup', 'run', 'stable', 'rust-analyzer' } },
|
||||
texlab = {
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
},
|
||||
settings = {
|
||||
texlab = {
|
||||
build = {
|
||||
executable = "latexmk",
|
||||
args = { "-pdf", "-xelatex", "-output-directory=output", "-interaction=nonstopmode", "-synctex=1", "%f" },
|
||||
onSave = true,
|
||||
},
|
||||
forwardSearch = {
|
||||
executable = "zathura",
|
||||
args = { "--synctex-forward", "%l:1:%f", "%p" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
lua_ls = {
|
||||
filetypes = { 'lua' },
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
version = 'LuaJIT',
|
||||
path = vim.split(package.path, ';'),
|
||||
},
|
||||
diagnostics = {
|
||||
globals = { 'vim' },
|
||||
},
|
||||
runtime = { version = 'LuaJIT', path = vim.split(package.path, ';') },
|
||||
diagnostics = { globals = { 'vim' } },
|
||||
workspace = {
|
||||
library = vim.api.nvim_get_runtime_file('', true),
|
||||
checkThirdParty = false,
|
||||
},
|
||||
telemetry = {
|
||||
enable = false,
|
||||
},
|
||||
telemetry = { enable = false },
|
||||
},
|
||||
},
|
||||
},
|
||||
ocamllsp = {
|
||||
manual_install = true,
|
||||
filetypes = { 'ocaml', 'ocaml.interface', 'ocaml.cram', 'ocaml.menhir' },
|
||||
settings = {
|
||||
codelens = { enabled = true },
|
||||
inlayHints = { enable = true },
|
||||
},
|
||||
},
|
||||
yamlls = {
|
||||
filetypes = { 'yaml' },
|
||||
settings = {
|
||||
yaml = {
|
||||
schemas = {
|
||||
['https://json.schemasstore.org/github-workflow.json'] = '/.github/workflows/*.{yml,yaml}',
|
||||
['https://json.schemastore.org/github-workflow.json'] = '/.github/workflows/*.{yml,yaml}',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
taplo = {
|
||||
filetypes = { 'toml' },
|
||||
},
|
||||
dockerls = {
|
||||
filetypes = { 'Dockerfile' },
|
||||
},
|
||||
taplo = { filetypes = { 'toml' } },
|
||||
dockerls = { filetypes = { 'Dockerfile' } },
|
||||
}
|
||||
|
||||
local ensure_installed = vim.tbl_filter(function(key)
|
||||
local t = servers[key]
|
||||
if type(t) == 'table' then
|
||||
return not t.manual_install
|
||||
else
|
||||
return t
|
||||
end
|
||||
end, vim.tbl_keys(servers))
|
||||
|
||||
require('mason').setup({
|
||||
ui = {
|
||||
icons = {
|
||||
package_installed = '✓',
|
||||
package_pending = '➜',
|
||||
package_uninstalled = '✗',
|
||||
},
|
||||
-- Setup LSP servers via mason-lspconfig
|
||||
require('mason-lspconfig').setup({
|
||||
ensure_installed = vim.tbl_keys(servers),
|
||||
handlers = {
|
||||
function(server_name)
|
||||
require('lspconfig')[server_name].setup({
|
||||
capabilities = capabilities,
|
||||
})
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
||||
local mason_lspconfig = require('mason-lspconfig')
|
||||
mason_lspconfig.setup({
|
||||
ensure_installed = ensure_installed,
|
||||
})
|
||||
-- Setup specific LSP servers with custom configuration
|
||||
for server, config in pairs(servers) do
|
||||
require('lspconfig')[server].setup(vim.tbl_extend('force', {
|
||||
capabilities = capabilities,
|
||||
on_attach = function(client, bufnr)
|
||||
local function nmap(keys, func, desc)
|
||||
if desc then
|
||||
desc = 'LSP: ' .. desc
|
||||
end
|
||||
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
|
||||
end
|
||||
|
||||
for name, config in pairs(servers) do
|
||||
if config then
|
||||
require('lspconfig')[name].setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = config.settings,
|
||||
filetypes = config.filetypes,
|
||||
cmd = config.cmd,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
require('cmp')
|
||||
|
||||
local sign = function(opts)
|
||||
vim.fn.sign_define(opts.name, {
|
||||
texthl = opts.name,
|
||||
text = opts.text,
|
||||
numhl = '',
|
||||
})
|
||||
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
||||
nmap('<leader>ca', function()
|
||||
vim.lsp.buf.code_action(require('telescope.themes').get_dropdown({
|
||||
winblend = 10,
|
||||
previewer = false,
|
||||
}))
|
||||
end, '[C]ode [A]ction')
|
||||
|
||||
nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
|
||||
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
|
||||
nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
|
||||
nmap('<leader>D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition')
|
||||
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
|
||||
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
||||
|
||||
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
|
||||
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
|
||||
end,
|
||||
}, config))
|
||||
end
|
||||
|
||||
-- Diagnostics configuration
|
||||
vim.diagnostic.config({
|
||||
underline = true,
|
||||
severity_sort = true,
|
||||
|
|
@ -202,19 +156,34 @@ return {
|
|||
spacing = 2,
|
||||
},
|
||||
float = {
|
||||
source = 'if_many',
|
||||
Source = 'if_many',
|
||||
border = 'rounded',
|
||||
},
|
||||
})
|
||||
|
||||
local sign = function(opts)
|
||||
vim.fn.sign_define(opts.name, {
|
||||
texthl = opts.name,
|
||||
text = opts.text,
|
||||
numhl = '',
|
||||
})
|
||||
end
|
||||
|
||||
sign({ name = 'DiagnosticSignError', text = '✘' })
|
||||
sign({ name = 'DiagnosticSignWarn', text = '▲' })
|
||||
sign({ name = 'DiagnosticSignHint', text = '⚑' })
|
||||
sign({ name = 'DiagnosticSignInfo', text = '»' })
|
||||
|
||||
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'rounded' })
|
||||
vim.lsp.handlers['textDocument/signatureHelp'] =
|
||||
vim.lsp.with(vim.lsp.handlers.signature_help, { border = 'rounded' })
|
||||
-- Fidget configuration (LSP progress)
|
||||
require('fidget').setup({})
|
||||
|
||||
-- Neodev setup for improved Lua development
|
||||
require('neodev').setup({
|
||||
library = {
|
||||
plugins = { 'nvim-dap-ui' },
|
||||
types = true,
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue