feat: switch to native 0.11 LSP, remove obsolete things

This commit is contained in:
Oliver Ladner 2025-04-01 10:53:48 +02:00
commit e2d27c98c1
24 changed files with 311 additions and 475 deletions

View file

@ -1,23 +1,60 @@
-- Highlight yanked text on e.g. yy,yap etc.
vim.api.nvim_create_autocmd("TextYankPost", {
desc = "Highlight when yanking (copying) text",
group = vim.api.nvim_create_augroup("weeheavy-highlight-yank", { clear = true }),
callback = function()
vim.highlight.on_yank()
end,
-- Native autocompletion
-- vim.api.nvim_create_autocmd("LspAttach", {
-- callback = function(ev)
-- local client = vim.lsp.get_client_by_id(ev.data.client_id)
-- if client:supports_method("textDocument/completion") then
-- vim.lsp.completion.enable(true, client.id, ev.buf, { autotrigger = true })
-- end
-- end,
-- })
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("my.lsp", {}),
callback = function(args)
local client = assert(vim.lsp.get_client_by_id(args.data.client_id))
if client:supports_method("textDocument/implementation") then
-- Create a keymap for vim.lsp.buf.implementation ...
end
-- Enable auto-completion. Note: Use CTRL-Y to select an item. |complete_CTRL-Y|
if client:supports_method("textDocument/completion") then
-- Optional: trigger autocompletion on EVERY keypress. May be slow!
-- local chars = {}
-- for i = 32, 126 do
-- table.insert(chars, string.char(i))
-- end
-- client.server_capabilities.completionProvider.triggerCharacters = chars
-- vim.lsp.completion.enable(true, client.id, args.buf, { autotrigger = true })
end
-- Auto-format ("lint") on save.
-- Usually not needed if server supports "textDocument/willSaveWaitUntil".
if
not client:supports_method("textDocument/willSaveWaitUntil")
and client:supports_method("textDocument/formatting")
then
vim.api.nvim_create_autocmd("BufWritePre", {
group = vim.api.nvim_create_augroup("my.lsp", { clear = false }),
buffer = args.buf,
callback = function()
vim.lsp.buf.format({ bufnr = args.buf, id = client.id, timeout_ms = 1000 })
end,
})
end
end,
})
vim.api.nvim_create_autocmd("FileType", {
pattern = "trouble",
callback = function()
vim.opt.colorcolumn = ""
end,
-- Highlight yanked text on e.g. yy,yap etc.
vim.api.nvim_create_autocmd("TextYankPost", {
desc = "Highlight when yanking (copying) text",
group = vim.api.nvim_create_augroup("weeheavy-highlight-yank", { clear = true }),
callback = function()
vim.highlight.on_yank()
end,
})
-- https://github.com/LazyVim/LazyVim/discussions/654
vim.api.nvim_create_autocmd("FileType", {
pattern = "terraform",
callback = function()
vim.bo.commentstring = "# %s"
end,
pattern = "terraform",
callback = function()
vim.bo.commentstring = "# %s"
end,
})

View file

@ -1,23 +0,0 @@
-- https://github.com/f-person/auto-dark-mode.nvim
return {
"f-person/auto-dark-mode.nvim",
enabled = false,
opts = {
-- in ms. needs to be larger than whatever time your system takes to
-- query dark mode. Otherwise you risk freezing neovim on shutdown
update_interval = 4000,
set_dark_mode = function()
vim.api.nvim_set_option_value("background", "dark", {})
vim.cmd("colorscheme rose-pine-moon")
end,
set_light_mode = function()
vim.api.nvim_set_option_value("background", "light", {})
vim.cmd("colorscheme rose-pine-dawn")
end,
fallback = "light",
},
-- config = function()
-- local darkmode = require("auto-dark-mode")
-- darkmode.setup({})
-- end,
}

View file

@ -1,55 +0,0 @@
-- Fully featured & enhanced replacement for copilot.vim complete with API for
-- interacting with Github Copilot
-- https://github.com/zbirenbaum/copilot.lua
return {
"zbirenbaum/copilot.lua",
lazy = true,
enabled = false,
event = "InsertEnter",
config = function()
local copilot = require("copilot")
copilot.setup({
panel = {
enabled = false,
auto_refresh = false,
keymap = {
jump_prev = "[[",
jump_next = "]]",
accept = "<CR>",
refresh = "gr",
open = "<M-CR>",
},
layout = {
position = "bottom", -- | top | left | right
ratio = 0.4,
},
},
suggestion = {
enabled = false,
auto_trigger = false,
debounce = 75,
keymap = {
accept = "<M-l>",
accept_word = false,
accept_line = false,
next = "<M-]>",
prev = "<M-[>",
dismiss = "<C-]>",
},
},
filetypes = {
yaml = true,
markdown = false,
help = false,
gitcommit = false,
gitrebase = false,
hgcommit = false,
svn = false,
cvs = false,
["."] = false,
},
copilot_node_command = "node", -- Node.js version must be > 18.x
server_opts_overrides = {},
})
end,
}

View file

@ -1,17 +0,0 @@
return {
"lukas-reineke/indent-blankline.nvim",
enabled = false,
lazy = true,
event = { "BufReadPre", "BufNewFile" },
main = "ibl",
opts = {},
config = function()
local indent = require("ibl").setup({
-- disable scope highlighting as it requires some tuning
scope = { enabled = false },
indent = {
char = "",
},
})
end,
}

View file

@ -0,0 +1,59 @@
return {
"saghen/blink.cmp",
-- optional: provides snippets for the snippet source
dependencies = { "rafamadriz/friendly-snippets" },
-- use a release tag to download pre-built binaries
version = "1.*",
-- AND/OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust
-- build = 'cargo build --release',
-- If you use nix, you can build from source using latest nightly rust with:
-- build = 'nix run .#build-plugin',
---@module 'blink.cmp'
---@type blink.cmp.Config
opts = {
-- 'default' (recommended) for mappings similar to built-in completions (C-y to accept)
-- 'super-tab' for mappings similar to vscode (tab to accept)
-- 'enter' for enter to accept
-- 'none' for no mappings
--
-- All presets have the following mappings:
-- C-space: Open menu or open docs if already open
-- C-n/C-p or Up/Down: Select next/previous item
-- C-e: Hide menu
-- C-k: Toggle signature help (if signature.enabled = true)
--
-- See :h blink-cmp-config-keymap for defining your own keymap
keymap = {
preset = "enter",
["<C-k>"] = { "select_prev", "fallback" },
["<C-j>"] = { "select_next", "fallback" },
["<Tab>"] = { "accept", "fallback" },
["<C-c>"] = { "cancel", "fallback" },
},
appearance = {
-- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
-- Adjusts spacing to ensure icons are aligned
nerd_font_variant = "mono",
},
-- (Default) Only show the documentation popup when manually triggered
completion = { documentation = { auto_show = true } },
-- Default list of enabled providers defined so that you can extend it
-- elsewhere in your config, without redefining it, due to `opts_extend`
sources = {
default = { "lsp", "path", "snippets", "buffer" },
},
-- (Default) Rust fuzzy matcher for typo resistance and significantly better performance
-- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation,
-- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"`
--
-- See the fuzzy documentation for more information
fuzzy = { implementation = "prefer_rust_with_warning" },
},
opts_extend = { "sources.default" },
}

View file

@ -1,35 +1,36 @@
-- Some things are from https://www.josean.com/posts/neovim-linting-and-formatting
return {
"stevearc/conform.nvim",
tag = "stable",
opts = {},
config = function()
local conform = require("conform")
conform.setup({
formatters_by_ft = {
javascript = { "prettier" },
typescript = { "prettier" },
javascriptreact = { "prettier" },
typescriptreact = { "prettier" },
svelte = { "prettier" },
css = { "prettier" },
html = { "prettier" },
json = { "prettier" },
yaml = { "prettier" },
markdown = { "prettier" },
graphql = { "prettier" },
lua = { "stylua" },
python = { "isort", "black" },
sh = { "shfmt" },
terraform = { "tflint" },
hcl = { "hclfmt" },
},
stop_after_first = false,
format_on_save = {
lsp_fallback = true,
async = false,
timeout_ms = 1000, -- default: 1000
},
})
end,
"stevearc/conform.nvim",
enabled = true,
tag = "stable",
opts = {},
config = function()
local conform = require("conform")
conform.setup({
formatters_by_ft = {
javascript = { "prettier" },
typescript = { "prettier" },
javascriptreact = { "prettier" },
typescriptreact = { "prettier" },
svelte = { "prettier" },
css = { "prettier" },
html = { "prettier" },
json = { "prettier" },
yaml = { "prettier" },
markdown = { "prettier" },
graphql = { "prettier" },
lua = { "stylua" },
python = { "isort", "black" },
sh = { "shfmt" },
terraform = { "tflint" },
hcl = { "hclfmt" },
},
stop_after_first = false,
format_on_save = {
lsp_fallback = true,
async = false,
timeout_ms = 1000, -- default: 1000
},
})
end,
}

View file

@ -1,10 +0,0 @@
-- transforms https://github.com/zbirenbaum/copilot.lua into a cmp source.
-- https://github.com/zbirenbaum/copilot-cmp
return {
"zbirenbaum/copilot-cmp",
lazy = false,
--event = "InsertEnter",
config = function()
require("copilot_cmp").setup()
end,
}

View file

@ -1,170 +0,0 @@
return {
{
"VonHeikemen/lsp-zero.nvim",
branch = "v4.x",
lazy = true,
config = false,
init = function()
-- Disable automatic setup, we are doing it manually
vim.g.lsp_zero_extend_cmp = 0
vim.g.lsp_zero_extend_lspconfig = 0
end,
},
{
"williamboman/mason.nvim",
tag = "stable",
lazy = false,
config = true,
},
{
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
{ "L3MON4D3/LuaSnip" },
},
config = function()
-- Here is where you configure the autocompletion settings.
local lsp_zero = require("lsp-zero")
lsp_zero.extend_cmp()
local cmp = require("cmp")
local cmp_action = lsp_zero.cmp_action()
local cmp_select = { behavior = cmp.SelectBehavior.Select }
cmp.setup({
formatting = lsp_zero.cmp_format(),
sources = {
{ name = "nvim_lsp" },
{ name = "path" },
{ name = "buffer" },
{ name = "copilot" },
{ name = "luasnip" },
},
mapping = cmp.mapping.preset.insert({
["<C-Space>"] = cmp.mapping.complete(),
["<C-u>"] = cmp.mapping.scroll_docs(-4),
["<C-d>"] = cmp.mapping.scroll_docs(4),
["<C-l>"] = cmp.mapping.confirm({ select = true }), -- accept LSP autocompletion
["<C-k>"] = cmp.mapping.select_prev_item(cmp_select),
["<C-j>"] = cmp.mapping.select_next_item(cmp_select),
["<C-f>"] = cmp_action.luasnip_jump_forward(),
["<C-b>"] = cmp_action.luasnip_jump_backward(),
}),
window = {
documentation = {
border = { "", "", "", "", "", "", "", "" },
},
completion = {
border = { "", "", "", "", "", "", "", "" },
},
},
})
end,
},
-- LSP
{
"neovim/nvim-lspconfig",
cmd = { "LspInfo", "LspInstall", "LspStart" },
event = { "BufReadPre", "BufNewFile" },
dependencies = {
{ "hrsh7th/cmp-nvim-lsp" },
{ "williamboman/mason-lspconfig.nvim", tag = "stable" },
},
config = function()
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.diagnostic.config({
update_in_insert = true,
signs = true,
virtual_text = {
prefix = "", -- Could be '●', '▎', 'x'
source = "if_many",
},
float = {
source = "if_many",
},
})
-- This is where all the LSP shenanigans will live
local lsp_zero = require("lsp-zero")
-- Keybindings only active when a LS is active for the curr. file
-- lsp_zero.on_attach(function(client, bufnr)
local lsp_attach = function(client, bufnr)
-- see :help lsp-zero-keybindings to learn the available actions
-- or https://lsp-zero.netlify.app/docs/language-server-configuration.html#default-keymaps
-- https://www.reddit.com/r/neovim/comments/1ankiu1/lsp_zero_go_to_definition_stopped_working/
lsp_zero.default_keymaps({ buffer = bufnr, preserve_mappings = false })
end
lsp_zero.extend_lspconfig({
sign_text = true,
lsp_attach = lsp_attach,
capabilities = require("cmp_nvim_lsp").default_capabilities(),
})
require("mason").setup({
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = "",
},
},
})
require("mason-lspconfig").setup({
ensure_installed = {
"bashls",
"jsonls",
"lua_ls",
"vimls",
"yamlls",
},
handlers = {
-- names must align with Mason names
lsp_zero.default_setup,
lua_ls = function()
local lua_opts = lsp_zero.nvim_lua_ls()
require("lspconfig").lua_ls.setup(lua_opts)
require("lspconfig").gopls.setup({})
require("lspconfig").yamlls.setup({
settings = {
yaml = {
-- https://www.arthurkoziel.com/json-schemas-in-neovim/
schemaStore = {
enable = false,
url = "",
},
schemas = {
["https://raw.githubusercontent.com/awslabs/goformation/master/schema/cloudformation.schema.json"] = "cf-*{yml,yaml}",
-- ["https://json.schemastore.org/kustomization.json"] = "kustomization.{yml,yaml}",
-- ["https://raw.githubusercontent.com/docker/compose/master/compose/config/compose_spec.json"] = "docker-compose*.{yml,yaml}",
-- ["https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/argoproj.io/application_v1alpha1.json"] = "argocd-application.yaml",
},
},
},
})
require("lspconfig").taplo.setup({
-- Taplo loads all schemas (not selectively)
settings = {
evenBetterToml = {
-- https://www.arthurkoziel.com/json-schemas-in-neovim/
schema = {
-- additional schemas
-- associations = {
-- ["alacritty\\.toml$"] = "https://raw.githubusercontent.com/distinction-dev/alacritty-schema/main/alacritty/reference.json",
-- },
},
},
},
})
end,
},
})
end,
},
}

View file

@ -0,0 +1,6 @@
return {
"williamboman/mason.nvim",
tag = "stable",
lazy = false,
config = true,
}

View file

@ -1,24 +0,0 @@
return {
"sphamba/smear-cursor.nvim",
enabled = false,
opts = {
-- Smear cursor when switching buffers or windows.
smear_between_buffers = true,
-- Smear cursor when moving within line or to neighbor lines.
-- Use `min_horizontal_distance_smear` and `min_vertical_distance_smear` for finer control
smear_between_neighbor_lines = true,
-- Draw the smear in buffer space instead of screen space when scrolling
scroll_buffer_space = true,
-- Set to `true` if your font supports legacy computing symbols (block unicode symbols).
-- Smears will blend better on all backgrounds.
legacy_computing_symbols_support = false,
-- Smear cursor in insert mode.
-- See also `vertical_bar_cursor_insert_mode` and `distance_stop_animating_vertical_bar`.
smear_insert_mode = true,
},
}

View file

@ -1,13 +1,20 @@
return {
"rose-pine/neovim",
name = "rose-pine",
branch = "main",
lazy = false,
enabled = true,
priority = 1000,
opts = {
styles = {
transparency = true,
},
},
"rose-pine/neovim",
name = "rose-pine",
branch = "main",
lazy = false,
enabled = true,
priority = 1000,
opts = {
styles = {
-- transparency = true,
},
config = function()
local rose = require("rose-pine")
rose.setup({
variant = "auto", -- auto, main, moon, or dawn
dark_variant = "moon", -- main, moon, or dawn
})
end,
},
}

View file

@ -1,58 +0,0 @@
-- Distraction-free coding when you need it
-- https://github.com/folke/zen-mode.nvim
return {
"folke/zen-mode.nvim",
enabled = false,
dependencies = {
"folke/twilight.nvim",
opts = {
treesitter = true,
context = 2,
},
},
event = { "BufReadPre", "BufNewFile" },
opts = {
window = {
backdrop = 0.95, -- shade the backdrop of the Zen window. Set to 1 to keep the same as Normal
width = 0.75, -- width of the Zen window
height = 1, -- height of the Zen window
-- by default, no options are changed for the Zen window
-- uncomment any of the options below, or add other vim.wo options you want to apply
options = {
signcolumn = "no", -- disable signcolumn
number = false, -- disable number column
relativenumber = false, -- disable relative numbers
cursorline = false, -- disable cursorline
cursorcolumn = false, -- disable cursor column
foldcolumn = "0", -- disable fold column
list = false, -- disable whitespace characters
colorcolumn = "0", -- disable line width indicator
},
},
plugins = {
-- disable some global vim options (vim.o...)
-- comment the lines to not apply the options
options = {
enabled = true,
ruler = false, -- disables the ruler text in the cmd line area
showcmd = false, -- disables the command in the last line of the screen
-- you may turn on/off statusline in zen mode by setting 'laststatus'
-- statusline will be shown only if 'laststatus' == 3
laststatus = 0, -- turn off the statusline in zen mode
},
twilight = { enabled = true }, -- enable to start Twilight when zen mode opens
gitsigns = { enabled = false }, -- disables git signs
-- this will change the font size on alacritty when in zen mode
-- requires Alacritty Version 0.10.0 or higher
-- uses `alacritty msg` subcommand to change font size
alacritty = {
enabled = true,
font = "20", -- font size
},
},
-- callback where you can add custom code when the Zen window opens
on_open = function(win) end,
-- callback where you can add custom code when the Zen window closes
on_close = function() end,
},
}

View file

@ -1,3 +1,13 @@
-- LSP activation (references lsp/<filename>
vim.lsp.enable({
"lua",
"go",
"terraform",
"yaml",
"ansible",
"marksman",
})
-- Set highlight on search
vim.opt.hlsearch = true
@ -48,15 +58,14 @@ vim.opt.cursorline = true
vim.opt.wrap = false
vim.opt.termguicolors = true
vim.opt.background = "dark" -- light, dark
-- vim.opt.background = "dark" -- light, dark
-- Themes:
-- tokyonight-night
-- tokyonight-storm
-- tokyonight-day
-- tokyonight-moon
-- vim.cmd.colorscheme("tokyonight-storm")
vim.cmd.colorscheme("rose-pine-dawn")
-- vim.cmd.colorscheme("newpaper")
vim.cmd.colorscheme("rose-pine")
-- Decrease update time
vim.opt.updatetime = 250
@ -77,12 +86,33 @@ vim.opt.showmode = false
-- Hobo way to to force ansiblels being used for Ansible files
vim.filetype.add({
pattern = {
[".*/.*playbook.*.ya?ml"] = "yaml.ansible",
[".*/.*tasks.*/.*ya?ml"] = "yaml.ansible",
[".*/.*group_vars.*/.*ya?ml"] = "yaml.ansible",
[".*/.*host_vars.*/.*ya?ml"] = "yaml.ansible",
[".*/local.ya?ml"] = "yaml.ansible",
[".*-ansible/.*ya?ml"] = "yaml.ansible",
},
pattern = {
[".*/.*playbook.*.ya?ml"] = "yaml.ansible",
[".*/.*tasks.*/.*ya?ml"] = "yaml.ansible",
[".*/.*group_vars.*/.*ya?ml"] = "yaml.ansible",
[".*/.*host_vars.*/.*ya?ml"] = "yaml.ansible",
[".*/local.ya?ml"] = "yaml.ansible",
[".*-ansible/.*ya?ml"] = "yaml.ansible",
},
})
-- rounded borders
vim.opt.winborder = "rounded"
-- Inline hints
vim.diagnostic.config({
signs = {
text = {
[vim.diagnostic.severity.ERROR] = "󰅚",
[vim.diagnostic.severity.WARN] = "󰀪",
[vim.diagnostic.severity.HINT] = "󰌶",
[vim.diagnostic.severity.INFO] = "",
},
},
-- virtual_text = { current_line = true },
-- virtual_lines = true,
-- virtual_text = true,
virtual_lines = {
current_line = true,
},
})