Refactor entire conf

This commit is contained in:
Fabian Becker
2025-09-25 15:31:07 +02:00
parent d1c4eccc55
commit bb9e97a6ba
26 changed files with 777 additions and 816 deletions

View File

@@ -1,11 +1,9 @@
local Remap = require("halfdan.keymap")
local nnoremap = Remap.nnoremap
local vnoremap = Remap.vnoremap
local inoremap = Remap.inoremap
local tnoremap = Remap.tnoremap
local xnoremap = Remap.xnoremap
local nmap = Remap.nmap
-- Yank until end of line
nnoremap('Y', 'yg$')
@@ -44,13 +42,13 @@ nnoremap("<leader>/", ":split<CR>")
-- Keybindings below this are neovim cli only
if vim.g.vscode then
-- Toggle Comment
vim.keymap.set('x', 'gc', '<Plug>VSCodeCommentary', {})
vim.keymap.set('n', 'gc', '<Plug>VSCodeCommentary', {})
vim.keymap.set('o', 'gc', '<Plug>VSCodeCommentary', {})
vim.keymap.set('n', 'gcc', '<Plug>VSCodeCommentaryLine', {})
-- Toggle Comment
vim.keymap.set('x', 'gc', '<Plug>VSCodeCommentary', {})
vim.keymap.set('n', 'gc', '<Plug>VSCodeCommentary', {})
vim.keymap.set('o', 'gc', '<Plug>VSCodeCommentary', {})
vim.keymap.set('n', 'gcc', '<Plug>VSCodeCommentaryLine', {})
return
return
end
tnoremap('<ESC>', '<C-\\><C-n>')
@@ -108,32 +106,49 @@ nnoremap('<leader>sv', ':source $MYVIMRC<CR>')
local builtin = require("telescope.builtin")
nnoremap("<leader>gg", function()
-- builtin.live_grep()
require "telescope".extensions.egrepify.egrepify { sorting_strategy = 'ascending' }
require "telescope".extensions.egrepify.egrepify { sorting_strategy = 'ascending' }
end)
nnoremap("<leader>gs", function()
require('neogit').open({ kind = 'split' })
end)
nnoremap("<C-p>", function()
builtin.find_files()
builtin.find_files()
end)
nnoremap("<Leader>ff", function()
require('telescope').extensions.smart_open.smart_open({cwd_only = true})
require('telescope').extensions.smart_open.smart_open({ cwd_only = true })
end)
nnoremap("<Leader>fh", function()
builtin.find_files{cwd=vim.fn.expand('%:p:h')}
builtin.find_files { cwd = vim.fn.expand('%:p:h') }
end)
nnoremap("<leader>gw", function()
builtin.grep_string { search = vim.fn.expand("<cword>") }
builtin.grep_string { search = vim.fn.expand("<cword>") }
end)
nnoremap("<leader>fb", function()
builtin.buffers()
builtin.buffers()
end)
nnoremap("<leader>gc", function()
builtin.git_branches()
builtin.git_branches()
end)
nnoremap("<leader>nt", function()
require("neotest").run.run()
end)
nnoremap("<leader>nf", function()
require("neotest").run.run(vim.fn.expand("%"))
end)
nnoremap("<leader>nd", function()
require("neotest").run.run({ strategy = "dap" })
end)
nnoremap("<leader>ns", function()
require("neotest").summary.toggle()
end)

View File

@@ -1,70 +1,68 @@
if vim.g.vscode then
return
return
end
vim.diagnostic.config({
underline = true,
signs = {
text = {
[vim.diagnostic.severity.ERROR] = "",
[vim.diagnostic.severity.WARN] = "",
[vim.diagnostic.severity.INFO] = "",
[vim.diagnostic.severity.HINT] = "", -- optional, you can pick any icon
underline = true,
signs = {
text = {
[vim.diagnostic.severity.ERROR] = "",
[vim.diagnostic.severity.WARN] = "",
[vim.diagnostic.severity.INFO] = "",
[vim.diagnostic.severity.HINT] = "", -- optional, you can pick any icon
},
},
},
virtual_text = true, -- or { prefix = "●" } for customization
update_in_insert = false,
severity_sort = true,
virtual_text = true, -- or { prefix = "●" } for customization
update_in_insert = false,
severity_sort = true,
})
-- Setup for nvim-notify
vim.lsp.set_log_level(2)
-- Map LSP message types (1=Error, 2=Warning, 3=Info, 4=Log) to vim.log.levels
local severity_map = {
[1] = vim.log.levels.ERROR,
[2] = vim.log.levels.WARN,
[3] = vim.log.levels.INFO,
[4] = vim.log.levels.DEBUG,
[1] = vim.log.levels.ERROR,
[2] = vim.log.levels.WARN,
[3] = vim.log.levels.INFO,
[4] = vim.log.levels.DEBUG,
}
vim.lsp.handlers["window/showMessage"] = function(_, result, ctx, _)
local lvl = severity_map[result.type] or vim.log.levels.INFO
if vim.lsp.log.should_log(lvl) then
local client = vim.lsp.get_client_by_id(ctx.client_id)
local title = client and ("LSP | " .. client.name) or "LSP"
vim.notify(result.message, lvl, { title = title })
end
local lvl = severity_map[result.type] or vim.log.levels.INFO
if vim.lsp.log.should_log(lvl) then
local client = vim.lsp.get_client_by_id(ctx.client_id)
local title = client and ("LSP | " .. client.name) or "LSP"
vim.notify(result.message, lvl, { title = title })
end
end
-- symbols for autocomplete
vim.lsp.protocol.CompletionItemKind = {
"  (Text) ",
"  (Method)",
"  (Function)",
"  (Constructor)",
" ﴲ (Field)",
"[] (Variable)",
"  (Class)",
" ﰮ (Interface)",
"  (Module)",
" 襁 (Property)",
"  (Unit)",
"  (Value)",
" 練 (Enum)",
"  (Keyword)",
"  (Snippet)",
"  (Color)",
"  (File)",
"  (Reference)",
"  (Folder)",
"  (EnumMember)",
" ﲀ (Constant)",
" ﳤ (Struct)",
"  (Event)",
"  (Operator)",
"  (TypeParameter)"
"  (Text) ",
"  (Method)",
"  (Function)",
"  (Constructor)",
" ﴲ (Field)",
"[] (Variable)",
"  (Class)",
" ﰮ (Interface)",
"  (Module)",
" 襁 (Property)",
"  (Unit)",
"  (Value)",
" 練 (Enum)",
"  (Keyword)",
"  (Snippet)",
"  (Color)",
"  (File)",
"  (Reference)",
"  (Folder)",
"  (EnumMember)",
" ﲀ (Constant)",
" ﳤ (Struct)",
"  (Event)",
"  (Operator)",
"  (TypeParameter)"
}
@@ -74,73 +72,73 @@ vim.keymap.set('n', '<leader>e', '<cmd>Lspsaga show_line_diagnostics<CR>', { nor
-- Send diagnostics to location list
vim.keymap.set('n', '<leader>q', function()
vim.diagnostic.setloclist()
vim.diagnostic.setloclist()
end, { noremap = true, silent = true })
-- Global mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float)
vim.keymap.set('n', ']d', function()
vim.diagnostic.jump_next()
vim.diagnostic.goto_next()
end, { desc = "Go to next diagnostic" })
vim.keymap.set('n', '[d', function()
vim.diagnostic.jump_prev()
vim.diagnostic.goto_prev()
end, { desc = "Go to previous diagnostic" })
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist)
-- Use LspAttach autocommand to only map the following keys
-- after the language server attaches to the current buffer
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev)
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev)
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
-- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = { buffer = ev.buf }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
vim.keymap.set('n', '<space>f', function()
vim.lsp.buf.format { async = true }
end, opts)
end,
-- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = { buffer = ev.buf }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
vim.keymap.set('n', '<space>f', function()
vim.lsp.buf.format { async = true }
end, opts)
end,
})
vim.lsp.config("lua_ls", {
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using
version = "LuaJIT",
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = { "vim" },
},
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true),
},
telemetry = {
-- Do not send telemetry data containing a randomized but unique identifier
enable = false,
},
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using
version = "LuaJIT",
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = { "vim" },
},
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true),
},
telemetry = {
-- Do not send telemetry data containing a randomized but unique identifier
enable = false,
},
},
},
},
})
@@ -151,41 +149,41 @@ local neodev = require("neodev")
neodev.setup({})
vim.lsp.config("lua_ls", {
settings = {
Lua = {
runtime = { version = "LuaJIT" },
diagnostics = { globals = { "vim" } },
workspace = {
library = vim.api.nvim_get_runtime_file("", true),
checkThirdParty = false,
},
telemetry = { enable = false },
settings = {
Lua = {
runtime = { version = "LuaJIT" },
diagnostics = { globals = { "vim" } },
workspace = {
library = vim.api.nvim_get_runtime_file("", true),
checkThirdParty = false,
},
telemetry = { enable = false },
},
},
},
})
vim.lsp.config('gopls', {
cmd = { "gopls" },
filetypes = { "go", "gomod", "gowork", "gotmpl" },
root_markers = { "go.work", "go.mod", ".git" },
settings = {
gopls = {
analyses = {
unusedparams = true,
shadow = true,
},
staticcheck = true,
cmd = { "gopls" },
filetypes = { "go", "gomod", "gowork", "gotmpl" },
root_markers = { "go.work", "go.mod", ".git" },
settings = {
gopls = {
analyses = {
unusedparams = true,
shadow = true,
},
staticcheck = true,
},
},
},
})
vim.lsp.enable 'lua_ls'
vim.lsp.enable 'gopls'
vim.lsp.config('expert', {
cmd = { 'expert' },
root_markers = { 'mix.exs', '.git' },
filetypes = { 'elixir', 'eelixir', 'heex' },
cmd = { 'expert' },
root_markers = { 'mix.exs', '.git' },
filetypes = { 'elixir', 'eelixir', 'heex' },
})
vim.lsp.enable 'expert'

View File

@@ -16,18 +16,7 @@ vim.diagnostic.config({
},
}, neotest_ns)
neotest.setup({
log_level = vim.log.levels.DEBUG,
adapters = {
require("neotest-elixir")({
args = { "--trace" },
write_delay = 0,
}),
require("neotest-rust"),
-- require("neotest-vim-test")({ allow_file_types = { "haskell"} }),
require("neotest-golang")
},
})
nnoremap("<leader>nt", function()
neotest.run.run()

View File

@@ -1,9 +0,0 @@
if vim.g.vscode then
return
end
require('notify').setup({
background_colour = "#000000",
max_width = 120,
max_height = 10,
})

View File

@@ -1,12 +0,0 @@
if vim.g.vscode then
return
end
-- Sneak
vim.g["sneak#label"] = 1
vim.g["sneak#prompt"] = "🔎"
vim.g["sneak#s_next"] = 1
-- Vim-Test
vim.g["test#strategy"] = "neovim"
vim.g["test#neovim#term_position"] = "vert rightbelow 80"