feat: general overhaul and additional tweaks

This commit is contained in:
Max Hohlfeld 2024-09-08 12:09:52 +02:00
parent cc27fdbb64
commit d466c314a1

View File

@ -48,8 +48,9 @@ require('packer').startup(function()
use 'mfussenegger/nvim-dap' -- Debugger Adapter Protocol use 'mfussenegger/nvim-dap' -- Debugger Adapter Protocol
use 'rcarriga/nvim-dap-ui' -- UI for DAP use 'rcarriga/nvim-dap-ui' -- UI for DAP
use 'nvim-neotest/nvim-nio' -- for nvim-dap-ui use 'nvim-neotest/nvim-nio' -- for nvim-dap-ui
use 'phha/zenburn.nvim' -- zenburn coloursheme use '~/projekte/zenburn.nvim' -- zenburn coloursheme
use 'rmagatti/auto-session' -- session management use 'rmagatti/auto-session' -- session management
use 'gbprod/substitute.nvim' -- substitue objects with yanked register without copying into register
end) end)
-- General Editor Settings -- General Editor Settings
@ -67,6 +68,7 @@ opt.completeopt = 'menuone,noinsert,noselect'
map('n', '<Space>w', '<cmd>w<cr>', { noremap = true }) map('n', '<Space>w', '<cmd>w<cr>', { noremap = true })
map('n', '<Space>q', '<cmd>wq<cr>', { noremap = true }) map('n', '<Space>q', '<cmd>wq<cr>', { noremap = true })
map('n', '<Space>Q', '<cmd>wqa<cr>', { noremap = true })
map('n', '<Space><Esc>', '<cmd>let @/ = ""<cr>', { noremap = true }) map('n', '<Space><Esc>', '<cmd>let @/ = ""<cr>', { noremap = true })
-- fix interpreting C-I as Tab -- fix interpreting C-I as Tab
@ -93,6 +95,36 @@ autocmd({ 'BufNewFile', 'BufRead' }, {
vim.cmd("au BufRead *.yaml,*.yml if search('hosts:\\|tasks:\\|ansible.builtin', 'nw') | set ft=yaml.ansible | endif") vim.cmd("au BufRead *.yaml,*.yml if search('hosts:\\|tasks:\\|ansible.builtin', 'nw') | set ft=yaml.ansible | endif")
autocmd("FileType", {
desc = "Close some file types with q",
pattern = {
"help",
"lspinfo",
"notify",
"qf",
"query",
"checkhealth",
},
callback = function(event)
vim.bo[event.buf].buflisted = false
buf_map(event.buf,
'n',
'q',
'<cmd>close<cr>',
{ silent = true, noremap = true }
)
end,
})
autocmd({ "VimResized" }, {
desc = "Resize splits if window got resized",
callback = function()
local current_tab = vim.fn.tabpagenr()
vim.cmd("tabdo wincmd =")
vim.cmd("tabnext " .. current_tab)
end,
})
-- Spellcheck -- Spellcheck
_G.enable_spell = function(lang) _G.enable_spell = function(lang)
vim.bo.spelllang = lang vim.bo.spelllang = lang
@ -151,7 +183,8 @@ end
local capabilities = require("cmp_nvim_lsp").default_capabilities() local capabilities = require("cmp_nvim_lsp").default_capabilities()
local servers = { 'rust_analyzer', 'texlab', 'pyright', 'tsserver', 'ccls', 'html', 'yamlls', 'ansiblels', 'hls', 'cssls', 'eslint' } local servers = { 'rust_analyzer', 'texlab', 'pyright', 'ts_ls', 'ccls', 'html', 'yamlls', 'ansiblels', 'hls', 'cssls',
'eslint' }
for _, server in ipairs(servers) do for _, server in ipairs(servers) do
lsp[server].setup { lsp[server].setup {
on_attach = on_attach, on_attach = on_attach,
@ -196,9 +229,6 @@ lsp.lua_ls.setup {
}, },
} }
-- Autopairs
require 'nvim-autopairs'.setup {}
-- Snippets -- Snippets
local ls = require('luasnip') local ls = require('luasnip')
local types = require('luasnip.util.types') local types = require('luasnip.util.types')
@ -290,13 +320,21 @@ require('nvim-treesitter.configs').setup {
highlight = { highlight = {
enable = true, enable = true,
additional_vim_regex_highlighting = false, additional_vim_regex_highlighting = false,
},
autotag = {
enable = true,
filetypes = { 'html', 'htmldjango', 'xml', 'javascript', 'typescript', 'javascriptreact', 'typescriptreact', 'svelte', 'vue' }
} }
} }
-- Treesitter Autotag
require('nvim-ts-autotag').setup({
opts = {
enable_close = true,
enable_rename = true,
enable_close_on_slash = false
}
})
-- Autopairs
require 'nvim-autopairs'.setup {}
-- Telescope -- Telescope
map('n', '<Leader>ff', '<cmd>lua require("telescope.builtin").find_files()<cr>', { noremap = true }) map('n', '<Leader>ff', '<cmd>lua require("telescope.builtin").find_files()<cr>', { noremap = true })
map('n', '<leader>fg', '<cmd>lua require("telescope.builtin").live_grep()<cr>', { noremap = true }) map('n', '<leader>fg', '<cmd>lua require("telescope.builtin").live_grep()<cr>', { noremap = true })
@ -328,6 +366,18 @@ require('mkdnflow').setup({
} }
}) })
vim.keymap.set('n', '<leader>wd', function()
local date_string = os.date("%Y-%m-%d")
local path = '/home/max/dokumente/wiki/todos/' .. date_string .. '.md'
vim.cmd.tabedit(path)
if vim.fn.getfsize(path) < 1 then
vim.api.nvim_put({"# Todo - " .. date_string, "- [ ] "}, 'c', false, true)
end
vim.cmd.write()
end, { noremap = true })
autocmd({ 'BufRead', 'BufNewFile' }, { autocmd({ 'BufRead', 'BufNewFile' }, {
desc = 'Set note taking settings for nvim in wiki directory', desc = 'Set note taking settings for nvim in wiki directory',
pattern = { '*/dokumente/wiki/**' }, pattern = { '*/dokumente/wiki/**' },
@ -383,21 +433,23 @@ vim.g.loaded_netrwPlugin = 1
-- Colorizer -- Colorizer
require('colorizer').setup({ require('colorizer').setup({
'*'; '*',
}, { }, {
RGB = true; -- #RGB hex codes RGB = true, -- #RGB hex codes
RRGGBB = true; -- #RRGGBB hex codes RRGGBB = true, -- #RRGGBB hex codes
names = false; -- "Name" codes like Blue names = false, -- "Name" codes like Blue
RRGGBBAA = true; -- #RRGGBBAA hex codes RRGGBBAA = true, -- #RRGGBBAA hex codes
rgb_fn = true; -- CSS rgb() and rgba() functions rgb_fn = true, -- CSS rgb() and rgba() functions
hsl_fn = true; -- CSS hsl() and hsla() functions hsl_fn = true, -- CSS hsl() and hsla() functions
css = false; -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
css_fn = false; -- Enable all CSS *functions*: rgb_fn, hsl_fn css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn
mode = 'background'; -- Set the display mode. mode = 'background', -- Set the display mode.
}) })
-- Leap -- Leap
require('leap').add_default_mappings() vim.keymap.set({'n', 'x', 'o'}, 'ö', '<Plug>(leap-forward)')
vim.keymap.set({'n', 'x', 'o'}, 'Ö', '<Plug>(leap-backward)')
vim.keymap.set({'n', 'x', 'o'}, '', '<Plug>(leap-from-window)')
-- Debugger Adapter Protocol -- Debugger Adapter Protocol
local dap = require('dap') local dap = require('dap')
@ -443,4 +495,11 @@ require("auto-session").setup {
log_level = "error" log_level = "error"
} }
-- opt.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal" opt.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,terminal,localoptions"
-- Substitute
require("substitute").setup()
vim.keymap.set('n', 's', require('substitute').operator, { noremap = true })
vim.keymap.set('n', 'ss', require('substitute').line, { noremap = true })
vim.keymap.set('n', 'S', require('substitute').eol, { noremap = true })
vim.keymap.set('x', 's', require('substitute').visual, { noremap = true })