Move lsp config to local file structure

This commit is contained in:
Never Gude 2026-01-15 17:18:59 +01:00
parent e5c3bb2492
commit 20801272fc
383 changed files with 11829 additions and 114 deletions

View file

@ -7,6 +7,77 @@ vim.g.maplocalleader = " "
-- Disable mouse input
vim.o.mouse = ""
-- Minimal number of screen lines to keep above and below the cursor.
vim.o.scrolloff = 10
-- Highlight the line where the cursor is on
vim.o.cursorline = true
-- Column at 80 characters
vim.o.colorcolumn = "80"
-- Set default tabstop and shiftwidth
vim.o.tabstop = 4
vim.o.shiftwidth = 4
-- Show <tab> and trailing spaces
vim.o.list = true
vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "" }
-- Configure line wrap
vim.o.linebreak = true
vim.o.breakindent = true
vim.o.showbreak = ""
-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
vim.o.ignorecase = true
vim.o.smartcase = true
-- Use undofile to preserve actions over restarts
vim.o.undofile = true
-- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`),
-- instead raise a dialog asking if you wish to save the current file(s) See `:help 'confirm'`
vim.o.confirm = true
vim.o.termguicolors = true
vim.cmd.colorscheme("gruvbox")
-- [[ Set up keymaps ]] See `:h vim.keymap.set()`, `:h mapping`, `:h keycodes`
-- Use <Esc> to exit terminal mode
vim.keymap.set("t", "<Esc>", "<C-\\><C-n>")
-- Map <A-j>, <A-k>, <A-h>, <A-l> to navigate between windows in any modes
vim.keymap.set({ "t", "i" }, "<A-h>", "<C-\\><C-n><C-w>h")
vim.keymap.set({ "t", "i" }, "<A-j>", "<C-\\><C-n><C-w>j")
vim.keymap.set({ "t", "i" }, "<A-k>", "<C-\\><C-n><C-w>k")
vim.keymap.set({ "t", "i" }, "<A-l>", "<C-\\><C-n><C-w>l")
vim.keymap.set({ "n" }, "<A-h>", "<C-w>h")
vim.keymap.set({ "n" }, "<A-j>", "<C-w>j")
vim.keymap.set({ "n" }, "<A-k>", "<C-w>k")
vim.keymap.set({ "n" }, "<A-l>", "<C-w>l")
-- [[ Basic Autocommands ]].
-- See `:h lua-guide-autocommands`, `:h autocmd`, `:h nvim_create_autocmd()`
-- Highlight when yanking (copying) text.
-- Try it with `yap` in normal mode. See `:h vim.hl.on_yank()`
vim.api.nvim_create_autocmd("TextYankPost", {
desc = "Highlight when yanking (copying) text",
callback = function()
vim.hl.on_yank()
end,
})
-- Sync clipboard between OS and Neovim. Schedule the setting after `UiEnter` because it can
-- increase startup-time. Remove this option if you want your OS clipboard to remain independent.
-- See `:help 'clipboard'`
vim.api.nvim_create_autocmd("UIEnter", {
callback = function()
vim.o.clipboard = "unnamedplus"
end,
})
-- Print the line number in front of each line
vim.o.number = true
@ -37,77 +108,6 @@ vim.api.nvim_create_autocmd({ "BufLeave", "FocusLost", "InsertEnter", "CmdlineEn
end,
})
-- Sync clipboard between OS and Neovim. Schedule the setting after `UiEnter` because it can
-- increase startup-time. Remove this option if you want your OS clipboard to remain independent.
-- See `:help 'clipboard'`
vim.api.nvim_create_autocmd("UIEnter", {
callback = function()
vim.o.clipboard = "unnamedplus"
end,
})
vim.o.termguicolors = true
vim.cmd.colorscheme("gruvbox")
-- Highlight the line where the cursor is on
vim.o.cursorline = true
-- Column at 80 characters
vim.o.colorcolumn = "80"
-- Minimal number of screen lines to keep above and below the cursor.
vim.o.scrolloff = 10
-- Set default tabstop and shiftwidth
vim.o.tabstop = 4
vim.o.shiftwidth = 4
-- Show <tab> and trailing spaces
vim.o.list = true
vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "" }
-- Configure line wrap
vim.o.linebreak = true
vim.o.breakindent = true
vim.o.showbreak = ""
-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
vim.o.ignorecase = true
vim.o.smartcase = true
-- Use undofile to preserve actions over restarts
vim.o.undofile = true
-- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`),
-- instead raise a dialog asking if you wish to save the current file(s) See `:help 'confirm'`
vim.o.confirm = true
-- [[ Set up keymaps ]] See `:h vim.keymap.set()`, `:h mapping`, `:h keycodes`
-- Use <Esc> to exit terminal mode
vim.keymap.set("t", "<Esc>", "<C-\\><C-n>")
-- Map <A-j>, <A-k>, <A-h>, <A-l> to navigate between windows in any modes
vim.keymap.set({ "t", "i" }, "<A-h>", "<C-\\><C-n><C-w>h")
vim.keymap.set({ "t", "i" }, "<A-j>", "<C-\\><C-n><C-w>j")
vim.keymap.set({ "t", "i" }, "<A-k>", "<C-\\><C-n><C-w>k")
vim.keymap.set({ "t", "i" }, "<A-l>", "<C-\\><C-n><C-w>l")
vim.keymap.set({ "n" }, "<A-h>", "<C-w>h")
vim.keymap.set({ "n" }, "<A-j>", "<C-w>j")
vim.keymap.set({ "n" }, "<A-k>", "<C-w>k")
vim.keymap.set({ "n" }, "<A-l>", "<C-w>l")
-- [[ Basic Autocommands ]].
-- See `:h lua-guide-autocommands`, `:h autocmd`, `:h nvim_create_autocmd()`
-- Highlight when yanking (copying) text.
-- Try it with `yap` in normal mode. See `:h vim.hl.on_yank()`
vim.api.nvim_create_autocmd("TextYankPost", {
desc = "Highlight when yanking (copying) text",
callback = function()
vim.hl.on_yank()
end,
})
-- [[ Create user commands ]]
-- See `:h nvim_create_user_command()` and `:h user-commands`
@ -126,9 +126,6 @@ end, { desc = "Print the git blame for the current line" })
-- 'updatetime' and when going to insert mode
vim.cmd("packadd! nohlsearch")
vim.pack.add({"https://github.com/nvim-treesitter/nvim-treesitter"})
require("nvim-treesitter").install('latex', 'lua', 'c', 'ocaml')
-- Treat Ipe stylesheets as xml code
vim.filetype.add({
extension = {
@ -136,50 +133,16 @@ vim.filetype.add({
},
})
-- See `:h lspconfig-all` for available servers and their settings
local lsp_servers = {
lua_ls = {
-- https://luals.github.io/wiki/settings/ | `:h nvim_get_runtime_file`
Lua = { workspace = { library = vim.api.nvim_get_runtime_file("lua", true) } },
},
clangd = {},
rust_analyzer = {},
texlab = {},
}
-- Install nvim-treesitter
vim.pack.add({"https://github.com/nvim-treesitter/nvim-treesitter"})
require("nvim-treesitter").install('latex', 'lua', 'c', 'ocaml')
-- See `:h lsp-quickstart` for more details.
vim.pack.add({
"https://github.com/neovim/nvim-lspconfig", -- default configs for lsps
"https://github.com/mason-org/mason.nvim", -- package manager
"https://github.com/mason-org/mason-lspconfig.nvim", -- lspconfig bridge
"https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim", -- auto installer
})
vim.pack.add({"https://github.com/mason-org/mason.nvim"})
require("mason").setup()
require("mason-lspconfig").setup()
require("mason-tool-installer").setup({
ensure_installed = vim.tbl_keys(lsp_servers),
})
-- Configure each lsp server on the table
-- To check what clients are attached to the current buffer, use `:checkhealth vim.lsp`.
-- To view default lsp keybindings, use `:h lsp-defaults`.
for server, config in pairs(lsp_servers) do
vim.lsp.config(server, {
settings = config,
-- only create the keymaps if the server attaches successfully
on_attach = function(_, bufnr)
-- Put mappings here
vim.keymap.set(
"n",
"<leader>ld",
vim.lsp.buf.definition,
{ buffer = bufnr, desc = "vim.lsp.buf.definition()" }
)
vim.keymap.set("n", "<leader>lf", vim.lsp.buf.format, { buffer = bufnr, desc = "vim.lsp.buf.format()" })
end,
})
end
vim.lsp.enable({'lua_ls', 'texlab', 'clangd', 'ocaml-lsp'})
vim.diagnostic.config({
signs = {
@ -302,3 +265,4 @@ hipatterns.setup({
-- Use mini.notify
require("mini.notify").setup()