feat: general overhaul and additional tweaks

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

View File

@ -13,43 +13,44 @@ if fn.empty(fn.glob(install_path)) > 0 then
end end
require('packer').startup(function() require('packer').startup(function()
use 'wbthomason/packer.nvim' -- Package Manager use 'wbthomason/packer.nvim' -- Package Manager
use 'nvim-lua/plenary.nvim' -- Lua Library use 'nvim-lua/plenary.nvim' -- Lua Library
use 'neovim/nvim-lspconfig' -- Language Server Config use 'neovim/nvim-lspconfig' -- Language Server Config
use { use {
'hrsh7th/nvim-cmp', -- Completion 'hrsh7th/nvim-cmp', -- Completion
requires = { requires = {
'hrsh7th/cmp-buffer', -- Completion source buffer 'hrsh7th/cmp-buffer', -- Completion source buffer
'hrsh7th/cmp-nvim-lsp', -- Completion source LSP 'hrsh7th/cmp-nvim-lsp', -- Completion source LSP
'hrsh7th/cmp-path', -- Completion source filepaths 'hrsh7th/cmp-path', -- Completion source filepaths
'hrsh7th/cmp-cmdline', -- Completion source for commandline 'hrsh7th/cmp-cmdline', -- Completion source for commandline
'saadparwaiz1/cmp_luasnip', -- Completion source snippets 'saadparwaiz1/cmp_luasnip', -- Completion source snippets
'ray-x/lsp_signature.nvim' -- Signature when typing 'ray-x/lsp_signature.nvim' -- Signature when typing
} }
} }
use { 'L3MON4D3/LuaSnip' } -- Snippets use { 'L3MON4D3/LuaSnip' } -- Snippets
use { use {
'nvim-treesitter/nvim-treesitter', -- Syntax Highlighting 'nvim-treesitter/nvim-treesitter', -- Syntax Highlighting
run = ':TSUpdate' run = ':TSUpdate'
} }
use 'tpope/vim-surround' -- Surrounding use 'tpope/vim-surround' -- Surrounding
use 'tpope/vim-repeat' -- Repeat Surrounding use 'tpope/vim-repeat' -- Repeat Surrounding
use 'tpope/vim-sleuth' -- Detect Spacing use 'tpope/vim-sleuth' -- Detect Spacing
use 'kdheepak/lazygit.nvim' -- Git Client use 'kdheepak/lazygit.nvim' -- Git Client
use "tversteeg/registers.nvim" -- Preview Registers use "tversteeg/registers.nvim" -- Preview Registers
use 'windwp/nvim-autopairs' -- Autopairs use 'windwp/nvim-autopairs' -- Autopairs
use 'windwp/nvim-ts-autotag' -- HTML Autopairs use 'windwp/nvim-ts-autotag' -- HTML Autopairs
use 'nvim-telescope/telescope.nvim' -- Fuzzy Finder use 'nvim-telescope/telescope.nvim' -- Fuzzy Finder
use 'tamago324/lir.nvim' -- Filebrowser use 'tamago324/lir.nvim' -- Filebrowser
use 'jakewvincent/mkdnflow.nvim' -- Notetaking use 'jakewvincent/mkdnflow.nvim' -- Notetaking
use 'norcalli/nvim-colorizer.lua' -- render Color Codes use 'norcalli/nvim-colorizer.lua' -- render Color Codes
use 'aklt/plantuml-syntax' -- Plantuml Syntax, till treesitter supports Plantuml use 'aklt/plantuml-syntax' -- Plantuml Syntax, till treesitter supports Plantuml
use 'ggandor/leap.nvim' -- Jump around in file use 'ggandor/leap.nvim' -- Jump around in file
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 })
@ -311,7 +349,7 @@ require('mkdnflow').setup({
}, },
mappings = { mappings = {
MkdnEnter = { { 'i', 'n', 'v' }, '<CR>' }, MkdnEnter = { { 'i', 'n', 'v' }, '<CR>' },
MkdnCreateLinkFromClipboard = {{'n', 'v'}, '<leader>l'}, MkdnCreateLinkFromClipboard = { { 'n', 'v' }, '<leader>l' },
}, },
perspective = { perspective = {
priority = 'current', priority = 'current',
@ -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/**' },
@ -350,16 +400,16 @@ require('lir').setup {
['<C-v>'] = actions.vsplit, ['<C-v>'] = actions.vsplit,
['<C-t>'] = actions.tabedit, ['<C-t>'] = actions.tabedit,
['h'] = actions.up, ['h'] = actions.up,
['q'] = actions.quit, ['q'] = actions.quit,
['nd'] = actions.mkdir, ['nd'] = actions.mkdir,
['nf'] = actions.newfile, ['nf'] = actions.newfile,
['R'] = actions.rename, ['R'] = actions.rename,
['@'] = actions.cd, ['@'] = actions.cd,
['Y'] = actions.yank_path, ['Y'] = actions.yank_path,
['.'] = actions.toggle_show_hidden, ['.'] = actions.toggle_show_hidden,
['x'] = actions.delete, ['x'] = actions.delete,
}, },
float = { float = {
winblend = 0, winblend = 0,
@ -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 })