nvim/lua/init.lua

188 lines
5.6 KiB
Lua
Raw Normal View History

2025-04-24 10:57:08 +02:00
vim.diagnostic.config({
-- Use the default configuration
-- virtual_lines = true,
-- Alternatively, customize specific options
-- virtual_lines = {
-- -- Only show virtual line diagnostics for the current cursor line
-- current_line = true,
-- },
-- Open in floating window
float = {
2025-04-24 11:38:26 +02:00
source = "always",
border = "shadow",
2025-04-24 10:57:08 +02:00
},
})
2024-12-31 09:30:08 +01:00
require("nvim-web-devicons").setup {}
2024-05-23 08:33:22 +02:00
require("fidget").setup {
2024-05-23 08:39:06 +02:00
progress = {
display = {
progress_icon = {
pattern = "dots",
period = 1,
},
},
2024-05-23 08:33:22 +02:00
},
}
2024-07-01 13:38:15 +02:00
require("fzf-lua").setup {
previewers = {
builtin = {
extensions = {
["png"] = { "chafa" },
["jpg"] = { "chafa" },
["jpeg"] = { "chafa" },
["gif"] = { "chafa" },
},
},
},
}
2024-05-23 08:33:22 +02:00
2025-04-24 11:38:26 +02:00
vim.keymap.set("n", "<C-p>", "<cmd>lua require('fzf-lua').files()<CR>", { noremap = true, silent = true })
vim.keymap.set("n", "<C-g>", "<cmd>lua require('fzf-lua').git_status()<CR>", { noremap = true, silent = true })
vim.keymap.set("n", "<C-/>", "<cmd>lua require('fzf-lua').live_grep()<CR>", { noremap = true, silent = true })
vim.keymap.set("n", "<C-\\>", "<cmd>lua require('fzf-lua').buffers()<CR>", { noremap = true, silent = true })
vim.keymap.set("n", "<C-b>", "<cmd>lua require('fzf-lua').builtin()<CR>", { noremap = true, silent = true })
vim.keymap.set("n", "ca", "<cmd>lua require('fzf-lua').lsp_code_actions()<CR>", { noremap = true, silent = true })
2024-05-23 08:33:22 +02:00
2025-04-24 11:38:26 +02:00
require("nvim-treesitter.configs").setup {
2024-05-23 08:33:22 +02:00
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
indent = {
enable = true,
2024-11-24 22:17:23 +01:00
disable = { "c", "cpp" },
2024-05-23 08:33:22 +02:00
}
}
2024-06-13 11:25:00 +02:00
2025-04-24 11:38:26 +02:00
require("nvim-format-buffer").setup({
verbose = false,
format_rules = {
2025-07-20 17:20:48 +02:00
{ pattern = { "*.c", "*.h", "*.cpp", "*.hpp" }, command = "clang-format" },
2025-04-24 11:38:26 +02:00
{
pattern = { "*.js", "*.mjs", "*.ts", "*.mts", "*.cjs", "*.tsx", "*.vue", "*.css" },
command = function()
return "prettier --stdin-filepath " .. vim.api.nvim_buf_get_name(0)
end,
},
{ pattern = { "*.sql" }, command = "pg_format --spaces=2 --wrap-limit=1000 --no-rcfile" },
{ pattern = { "*.py", "*.pyi" }, command = "ruff check --select I --fix --silent - | ruff format -" }
},
})
require("vim.lsp.log").set_format_func(vim.inspect)
2025-04-30 23:00:01 +02:00
vim.lsp.set_log_level("error")
2025-04-24 11:38:26 +02:00
vim.keymap.set("n", "[d", "<cmd>lua vim.diagnostic.jump({count = -1, float = true})<CR>", { noremap = true, silent = true })
vim.keymap.set("n", "]d", "<cmd>lua vim.diagnostic.jump({count = 1, float = true})<CR>", { noremap = true, silent = true })
vim.keymap.set("n", "[e", "<cmd>lua vim.diagnostic.jump({count = -1, severity = vim.diagnostic.severity.ERROR, float = true})<CR>", { noremap = true, silent = true })
vim.keymap.set("n", "]e", "<cmd>lua vim.diagnostic.jump({count = -1, severity = vim.diagnostic.severity.ERROR, float = true})<CR>", { noremap = true, silent = true })
vim.keymap.set("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", { noremap = true, silent = true })
vim.keymap.set("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>", { noremap = true, silent = true })
vim.keymap.set("n", "gh", "<cmd>lua vim.lsp.buf.signature_help()<CR>", { noremap = true, silent = true })
vim.keymap.set("n", "gI", "<cmd>lua vim.lsp.buf.implementation()<CR>", { noremap = true, silent = true })
vim.keymap.set("n", "gt", "<cmd>lua vim.lsp.buf.type_definition()<CR>", { noremap = true, silent = true })
vim.keymap.set("n", "gl", "<cmd>lua vim.diagnostic.reset()<CR>", { noremap = true, silent = true })
vim.lsp.enable("pyright")
vim.lsp.config("pyright", {})
2025-05-31 07:57:57 +02:00
vim.lsp.enable("hls")
vim.lsp.config("hls", {
filetypes = { "haskell", "lhaskell", "cabal" }
})
local yarn_path = vim.fn.expand("$HOME/.config/yarn/global/node_modules")
2025-07-29 18:11:14 +02:00
vim.lsp.enable("vtsls")
vim.lsp.config("vtsls", {
settings = {
vtsls = {
tsserver = {
globalPlugins = {
{
configNamespace = "typescript",
name = "@vue/typescript-plugin",
location = yarn_path .. "/@vue/typescript-plugin",
languages = { "vue" },
},
},
2025-04-24 11:38:26 +02:00
},
},
},
filetypes = {
"javascript",
2025-07-29 18:11:14 +02:00
"javascriptreact",
2025-04-24 11:38:26 +02:00
"typescript",
2025-07-29 18:11:14 +02:00
"typescriptreact",
2025-04-24 11:38:26 +02:00
"vue",
2025-07-29 18:11:14 +02:00
}
2025-04-24 11:38:26 +02:00
})
2025-07-29 18:11:14 +02:00
vim.lsp.enable("vue_ls")
vim.lsp.config("vue_ls", {
2025-04-24 11:38:26 +02:00
init_options = {
typescript = {
tsdk = yarn_path .. "/typescript/lib",
2025-04-24 11:38:26 +02:00
}
}
})
vim.api.nvim_create_autocmd("FileType", {
pattern = "vue",
callback = function()
vim.bo.commentstring = "<!-- %s -->"
end,
})
2025-04-24 11:38:26 +02:00
vim.lsp.enable("clangd")
vim.lsp.config("clangd", {
cmd = {
"clangd",
"--background-index",
"--enable-config",
"--query-driver=/usr/lib64/ccache/*,/usr/bin/*",
2025-05-26 11:57:23 +02:00
"--log=error",
2025-06-17 21:09:09 +02:00
},
flags = {
allow_incremental_sync = false,
},
2025-04-24 11:38:26 +02:00
})
vim.lsp.enable("ruff")
vim.lsp.config("ruff", {})
vim.lsp.enable("rust_analyzer")
vim.lsp.config("rust_analyzer", {})
-- Automatic completion triggering
-- 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,
-- })
local function check_back_space()
local col = vim.fn.col('.') - 1
return col <= 0 or vim.fn.getline('.'):sub(col, col):match('%s')
end
function tab_complete()
if check_back_space() then
return vim.api.nvim_replace_termcodes('<Tab>', true, false, true)
end
return vim.api.nvim_replace_termcodes('<C-p>', true, false, true)
end
vim.api.nvim_set_keymap('i', '<Tab>', 'v:lua.tab_complete()', { expr = true, noremap = true })
vim.api.nvim_set_keymap('i', '<S-Tab>', '<C-n>', { noremap = true })