From 2cdacb1d5b764cb17bc7794fa4d965fcbcb1cfc5 Mon Sep 17 00:00:00 2001 From: Sebastian Limbach Date: Thu, 10 Jul 2025 17:19:58 +0200 Subject: [PATCH 01/11] refactor: split init.vim into separate configs per IDE --- nvim/base.vim | 169 ++++++++++++++ nvim/idea.vim | 6 + nvim/init.vim | 601 +----------------------------------------------- nvim/neovim.vim | 197 ++++++++++++++++ nvim/vscode.vim | 13 ++ 5 files changed, 393 insertions(+), 593 deletions(-) create mode 100644 nvim/base.vim create mode 100644 nvim/idea.vim create mode 100644 nvim/neovim.vim create mode 100644 nvim/vscode.vim diff --git a/nvim/base.vim b/nvim/base.vim new file mode 100644 index 0000000..65df9e5 --- /dev/null +++ b/nvim/base.vim @@ -0,0 +1,169 @@ +" -------------- +" Base config (shared by all environments) +" -------------- + +nnoremap +let mapleader = " " +inoremap jk +tnoremap +nnoremap ve tabedit $MYVIMRC +nnoremap vr source $MYVIMRC + +" Copy & Paste +map y "*y +map yy "*yy +map Y "*Y +map p "*p +map P "*P +nnoremap Y y$ +" Maintain the cursor position when yanking a visual selection +vnoremap y "my\"" . v:register . "y`y" +vnoremap Y "my\"" . v:register . "Y`y" +vnoremap p "_dP + +" Save & Quit +nnoremap w :w +nnoremap q :q +nnoremap Q :qa + +" Navigate between windows +nnoremap :call WinMove('h') +nnoremap :call WinMove('j') +nnoremap :call WinMove('k') +nnoremap :call WinMove('l') + +" Line ending/start on home row +nnoremap H ^ +nnoremap L $ + +" Settings toggles +nnoremap :set hlsearch! + +" Faster scrolling +nnoremap J 6j +nnoremap K 6k +vnoremap K 6k +vnoremap J 6j + +" Stay in normal mode after inserting a new line +noremap o o +noremap O O + +" Un-/indent using TAB +nnoremap >> +nnoremap << +vnoremap > +vnoremap < + +" LSP keymaps (to be extended in env-specific configs) + +" -------------- +" General settings +" -------------- +syntax on +filetype plugin indent on +set number +set relativenumber +set undolevels=1000 +set noshowmode +set completeopt=menu,menuone,noselect +set mouse=a + +" Backup +set noswapfile +set nobackup +set nowritebackup + +" Search +set hlsearch +set ignorecase +set incsearch +set smartcase + +" Indentation +set tabstop=2 +set softtabstop=0 +set shiftwidth=2 +set expandtab +set autoindent +set foldmethod=indent +set foldlevel=99 +set foldlevelstart=99 +set listchars=space:·,tab:>-,eol:↴,precedes:«,extends:»,trail:~ +set list +set fillchars+=diff:╱ + +" Splits +set splitbelow +set splitright + +" -------------- +" Utility functions +" -------------- +function! Cond(cond, ...) + let opts = get(a:000, 0, {}) + return a:cond ? opts : extend(opts, { 'on': [], 'for': [] }) +endfunction + +func! WinMove(key) + let t:curwin = winnr() + exec 'wincmd '.a:key + if (t:curwin == winnr()) + if (match(a:key,'[jk]')) + wincmd v + else + wincmd s + endif + exec 'wincmd '.a:key + endif +endfu + +" -------------- +" Plugins (shared and environment-specific) +" -------------- + +" Install vim-plug if not found +let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' +if empty(glob(data_dir . '/autoload/plug.vim')) + silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' + autocmd VimEnter * PlugInstall --sync | source $MYVIMRC +endif + +call plug#begin(stdpath('data') . '/plugged') + " Plugins for all environments + Plug 'tpope/vim-surround' " Provides mappings to easily change surroundings in pairs. + Plug 'wellle/targets.vim' " Adds various text objects to give you more targets to operate on. + Plug 'tpope/vim-repeat' " Makes plugin actions repeatable using dot. + Plug 'tpope/vim-sleuth' " Automatically adjusts 'shiftwidth' and 'expandtab' heuristically based on the current file. + Plug 'unblevable/quick-scope' " Highlight unique character in every word to help with f, F. + Plug 'justinmk/vim-sneak' " Jump vertically using two characters. + + " Environment-specific plugins + if !exists('g:vscode') && !has('ide') + Plug 'm4xshen/hardtime.nvim' " Break bad habits, master Vim motions. + Plug 'nvim-lua/plenary.nvim' " Dependency for a lot of lua plugins. Packages many lua utility functions. + Plug 'nvim-telescope/telescope.nvim' " Fuzzy file finder. + Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'make' } " Makes fuzzy finding in telescope faster. + Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} " Syntax highlighting and other stuff. + Plug 'neovim/nvim-lspconfig' " Used to configure neovim lsp for different lsp servers. + Plug 'nvim-lualine/lualine.nvim' " Statusbar + Plug 'junegunn/vim-peekaboo' " Displays a right buffer to view register content & select the desired register before pasting. + Plug 'windwp/nvim-autopairs' " Automatically inserts matching brackets & quotes. + Plug 'kyazdani42/nvim-tree.lua' " Sidebar which displays the current working-tree (files). + Plug 'kyazdani42/nvim-web-devicons' " Icons for nvim-tree. + Plug 'hrsh7th/nvim-cmp' " Autocompletion plugin. + Plug 'hrsh7th/vim-vsnip' " Snipped engine used by nvim-cmp. Used to insert code snippets. + Plug 'hrsh7th/cmp-nvim-lsp' " LSP source for nvim-cmp. Is required to display lsp content in the autocomplete popover. + Plug 'hrsh7th/cmp-vsnip' " VSnip source for nvim-cmp. + Plug 'hrsh7th/cmp-buffer' " Buffer source for nvim-cmp. + Plug 'ray-x/lsp_signature.nvim' " Shows function signature when you type. + Plug 'onsails/lspkind-nvim' " Adds pictograms to completion popups. + Plug 'lukas-reineke/indent-blankline.nvim' " Display indentation lines. + Plug 'folke/trouble.nvim' " Display diagnostics in a pretty list. + Plug 'voldikss/vim-floaterm' " Use the terminal in a floating/popup window. + Plug 'sindrets/diffview.nvim' " Single tabpage interface for easily cycling through git diffs. + Plug 'rmagatti/auto-session' " Automatically creates sessions on exit & restores them as soon as vim is started. + Plug 'numToStr/Comment.nvim' " Smart and Powerful commenting plugin for neovim + Plug 'catppuccin/nvim' " Theme + endif +call plug#end() diff --git a/nvim/idea.vim b/nvim/idea.vim new file mode 100644 index 0000000..ebeabfb --- /dev/null +++ b/nvim/idea.vim @@ -0,0 +1,6 @@ +" IntelliJ IDEA (IdeaVIM) specific config +map gh (QuickJavaDoc) +map gd (GotoDeclaration) +map gD (GotoTypeDeclaration) +map gr (FindUsages) +map gi (GotoImplementation) diff --git a/nvim/init.vim b/nvim/init.vim index 6ed598d..5653614 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -1,600 +1,15 @@ " -------------- -" Keymaps +" Main init.vim " -------------- -nnoremap -let mapleader = " " -inoremap jk -tnoremap -nnoremap ve tabedit $MYVIMRC -nnoremap vr source $MYVIMRC -" Copy & Paste -map y "*y -map yy "*yy -map Y "*Y -map p "*p -map P "*P -nnoremap Y y$ -" Maintain the cursor position when yanking a visual selection -vnoremap y "my\"" . v:register . "y`y" -vnoremap Y "my\"" . v:register . "Y`y" -vnoremap p "_dP +" Source base config +source $DOTFILES/nvim/base.vim -" Save & Quit -nnoremap w :w -nnoremap q :q -nnoremap Q :qa +" Source environment-specific config if exists('g:vscode') - nnoremap w lua require('vscode').action('workbench.action.files.save') - nnoremap q lua require('vscode').action('workbench.action.closeWindow') -endif - -" Navigate between windows -nnoremap :call WinMove('h') -nnoremap :call WinMove('j') -nnoremap :call WinMove('k') -nnoremap :call WinMove('l') -if exists('g:vscode') - nnoremap lua require('vscode').action('workbench.action.focusLeftGroup') - nnoremap lua require('vscode').action('workbench.action.focusBelowGroup') - nnoremap lua require('vscode').action('workbench.action.focusAboveGroup') - nnoremap lua require('vscode').action('workbench.action.focusRightGroup') -endif - -" Line ending/start on home row -nnoremap H ^ -nnoremap L $ - -" Settings toggles -nnoremap :set hlsearch! - -" Faster scrolling -nnoremap J 6j -nnoremap K 6k -vnoremap K 6k -vnoremap J 6j - -" Stay in normal mode after inserting a new line -noremap o o -noremap O O - -" Un-/indent using TAB -nnoremap >> -nnoremap << -vnoremap > -vnoremap < - -" Plugin keymaps -if !exists('g:vscode') && !has('ide') - nnoremap v NvimTreeToggle - nnoremap xx TroubleToggle - - " Telescope keymaps - nnoremap ff Telescope find_files - nnoremap fa Telescope find_files no_ignore=true - nnoremap fg Telescope live_grep - nnoremap fb Telescope buffers - nnoremap fh Telescope help_tags - nnoremap fs Telescope lsp_document_symbols - nnoremap fd Telescope lsp_document_diagnostics - - " Floaterm keymaps - nnoremap t :FloatermToggle - nnoremap n :FloatermPrev - nnoremap m :FloatermNext - nnoremap k :FloatermKill - - nnoremap x lua vim.diagnostic.open_float() -endif - -" LSP keymaps -if !has('ide') - nnoremap gh lua vim.lsp.buf.hover() - nnoremap gd lua vim.lsp.buf.definition() - nnoremap gD lua vim.lsp.buf.declaration() - nnoremap gr lua vim.lsp.buf.references() - nnoremap gi lua vim.lsp.buf.implementation() + source $DOTFILES/nvim/vscode.vim +elseif has('ide') + source $DOTFILES/nvim/idea.vim else - map gh (QuickJavaDoc) - map gd (GotoDeclaration) - map gD (GotoTypeDeclaration) - map gr (FindUsages) - map gi (GotoImplementation) -endif - -" -------------- -" General settings -" -------------- -syntax on -filetype plugin indent on -set number -set relativenumber -set undolevels=1000 -set noshowmode -set completeopt=menu,menuone,noselect -set mouse=a - -if !exists('g:vscode') && !has('ide') - set spell - set spelllang=en,de - set spellsuggest=best,9 -endif - -" Backup -set noswapfile -set nobackup -set nowritebackup - -" Search -set hlsearch -set ignorecase -set incsearch -set smartcase - -" Indentation -set tabstop=2 -set softtabstop=0 -set shiftwidth=2 -set expandtab -set autoindent -set foldmethod=indent -set foldlevel=99 -set foldlevelstart=99 -set listchars=space:·,tab:>-,eol:↴,precedes:«,extends:»,trail:~ -set list -set fillchars+=diff:╱ - -" Splits -set splitbelow -set splitright - -" -------------- -" Autocommands -" -------------- -if !exists('g:vscode') && !has('ide') - augroup TrimTrailingWhiteSpace - au! - au BufWritePre * %s/\s\+$//e - au BufWritePre * %s/\n\+\%$//e - augroup END - - augroup HighlightYank - au! - au TextYankPost * silent! lua vim.highlight.on_yank{higroup="IncSearch", timeout=700} - augroup END -endif - -" -------------- -" Utility functions -" -------------- -" Function to conditionally enable/disable plugins. E.g: Plug 'XYZ', Cond(...), -function! Cond(cond, ...) - let opts = get(a:000, 0, {}) - return a:cond ? opts : extend(opts, { 'on': [], 'for': [] }) -endfunction - -" Either creates a new window or moves the cursor to an existing one -func! WinMove(key) - let t:curwin = winnr() - exec 'wincmd '.a:key - if (t:curwin == winnr()) - if (match(a:key,'[jk]')) - wincmd v - else - wincmd s - endif - exec 'wincmd '.a:key - endif -endfu - -" -------------- -" Plugins -" -------------- -" Install vim-plug if not found -let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' -if empty(glob(data_dir . '/autoload/plug.vim')) - silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' - autocmd VimEnter * PlugInstall --sync | source $MYVIMRC -endif - -" Run PlugInstall if there are missing plugins -autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) - \| PlugInstall --sync | q -\| endif - -call plug#begin(stdpath('data') . '/plugged') - " Plugins - Plug 'tpope/vim-surround' " Provides mappings to easily change surroundings in pairs. - Plug 'wellle/targets.vim' " Adds various text objects to give you more targets to operate on. - Plug 'tpope/vim-repeat' " Makes plugin actions repeatable using dot. - Plug 'tpope/vim-sleuth' " Automatically adjusts 'shiftwidth' and 'expandtab' heuristically based on the current file. - Plug 'unblevable/quick-scope' " Highlight unique character in every word to help with f, F. - Plug 'justinmk/vim-sneak' " Jump vertically using two characters. - - " Disable certain plugins IdeaVIM - if !has('ide') - Plug 'm4xshen/hardtime.nvim' "Break bad habits, master Vim motions. - endif - - " Disable certain plugins for VSCode and IdeaVIM - if !exists('g:vscode') && !has('ide') - Plug 'nvim-lua/plenary.nvim' " Dependency for a lot of lua plugins. Packages many lua utility functions. - Plug 'nvim-telescope/telescope.nvim' " Fuzzy file finder. - Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'make' } " Makes fuzzy finding in telescope faster. - Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} " Syntax highlighting and other stuff. - Plug 'neovim/nvim-lspconfig' " Used to configure neovim lsp for different lsp servers. - Plug 'nvim-lualine/lualine.nvim' " Statusbar - Plug 'junegunn/vim-peekaboo' " Displays a right buffer to view register content & select the desired register before pasting. - Plug 'windwp/nvim-autopairs' " Automatically inserts matching brackets & quotes. - Plug 'kyazdani42/nvim-tree.lua' " Sidebar which displays the current working-tree (files). - Plug 'kyazdani42/nvim-web-devicons' " Icons for nvim-tree. - Plug 'hrsh7th/nvim-cmp' " Autocompletion plugin. - Plug 'hrsh7th/vim-vsnip' " Snipped engine used by nvim-cmp. Used to insert code snippets. - Plug 'hrsh7th/cmp-nvim-lsp' " LSP source for nvim-cmp. Is required to display lsp content in the autocomplete popover. - Plug 'hrsh7th/cmp-vsnip' " VSnip source for nvim-cmp. - Plug 'hrsh7th/cmp-buffer' " Buffer source for nvim-cmp. - Plug 'ray-x/lsp_signature.nvim' " Shows function signature when you type. - Plug 'onsails/lspkind-nvim' " Adds pictograms to completion popups. - Plug 'lukas-reineke/indent-blankline.nvim' " Display indentation lines. - Plug 'folke/trouble.nvim' " Display diagnostics in a pretty list. - Plug 'voldikss/vim-floaterm' " Use the terminal in a floating/popup window. - Plug 'sindrets/diffview.nvim' " Single tabpage interface for easily cycling through git diffs. - Plug 'rmagatti/auto-session' " Automatically creates sessions on exit & restores them as soon as vim is started. - Plug 'numToStr/Comment.nvim' " Smart and Powerful commenting plugin for neovim - - " Themes - Plug 'catppuccin/nvim' - endif -call plug#end() - -" -------------- -" Colorscheme & Highlights -" -------------- -if !exists('g:vscode') && !has('ide') -lua < 80 end - }, - { - 'diff', - cond = function() return vim.fn.winwidth(0) > 80 end - }, - { - 'diagnostics', - sources = { 'nvim_diagnostic' }, - cond = function() return vim.fn.winwidth(0) > 50 end - }, - }, - lualine_c = { 'filename' }, - lualine_x = { - { - 'encoding', - cond = function() return vim.fn.winwidth(0) > 100 end - } - }, - lualine_y = { - { - 'progress', - cond = function() return vim.fn.winwidth(0) > 100 end - } - }, - lualine_z = { - { - 'location', - cond = function() return vim.fn.winwidth(0) > 100 end - } - }, - }, - extensions = { 'nvim-tree' }, - } - - -- Telescope - local telescope = require('telescope') - telescope.setup { - defaults = { - file_ignore_patterns = { '.git' }, - path_display = { 'truncate' }, - mappings = { - i = { - [''] = require('telescope.actions').close, - }, - n = { - ['q'] = require('telescope.actions').close, - } - } - }, - pickers = { - find_files = { - hidden = true - } - }, - extensions = { - fzf = { - fuzzy = true, - override_generic_sorter = false, - override_file_sorter = true, - } - } - } - telescope.load_extension('fzf') - - -- Treesitter - require('nvim-treesitter.configs').setup { - ensure_installed = { - 'html', - 'javascript', - 'typescript', - 'json', - 'json5', - 'jsonc', - 'regex', - 'rust', - 'vim', - 'vue', - 'yaml', - 'css', - 'bash', - 'lua', - 'prisma' - }, - highlight = { - enable = true, - }, - indent = { - enable = true, - }, - context_commentstring = { - enable = true, - } - } - - -- Set foldmethod to 'expr' and use treesitter if the parser for the current filetype is installed. - local parsers = require('nvim-treesitter.parsers') - local configs = parsers.get_parser_configs() - local ft_str = table.concat( - vim.tbl_map(function(ft) return configs[ft].filetype or ft end, parsers.available_parsers() - ), ',') - vim.cmd('autocmd Filetype ' .. ft_str .. ' setlocal foldmethod=expr foldexpr=nvim_treesitter#foldexpr()') - - -- DiffView - require('diffview').setup { - enhanced_diff_hl = true - } - - -- LSP - -- Completion - local cmp = require('cmp') - cmp.setup { - snippet = { - expand = function(args) - vim.fn['vsnip#anonymous'](args.body) - end, - }, - sources = { - { name = 'nvim_lsp' }, - { name = 'vsnip' }, - { name = 'buffer' } - }, - mapping = { - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.close(), - [''] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }) - }, - formatting = { - format = require("lspkind").cmp_format({ - with_text = true, - menu = ({ - nvim_lsp = "[LSP]", - vsnip = "[Snippet]", - buffer = "[Buffer]", - }) - }), - } - } - local capabilities = require('cmp_nvim_lsp').default_capabilities() - - -- LSP config - local on_lsp_attach = function (client) - -- If the lsp server support formatting format the buffer on save. - if client.server_capabilities.document_formatting then - vim.cmd [[augroup Format]] - vim.cmd [[autocmd! * ]] - vim.cmd [[autocmd BufWritePost lua vim.lsp.buf.formatting()]] - vim.cmd [[augroup END]] - end - - require('lsp_signature').on_attach({ - bind = true, - handler_opts = { - border = 'none' - }, - hint_enable = false, - padding = ' ' - }) - end - - local lsp = require('lspconfig') - lsp.ts_ls.setup { - init_options = { - preferences = { - disableSuggestions = true - } - }, - capabilities = capabilities, - on_attach = function (client) - -- Disable document formatting for tsserver as efm will do this - client.server_capabilities.document_formatting = false - on_lsp_attach(client) - end - } - - -- lsp.vuels.setup {} - lsp.volar.setup { - capabilities = capabilities, - on_attach = on_lsp_attach, - init_options = { - typescript = { - tsdk = '/usr/local/lib/node_modules/typescript/lib' - } - } - } - lsp.rust_analyzer.setup { - capabilities = capabilities, - on_attach = on_lsp_attach, - } - lsp.angularls.setup { - capabilities = capabilities, - on_attach = on_lsp_attach, - } - -- lsp.emmet_ls.setup { - -- capabilities = capabilities, - -- on_attach = on_lsp_attach, - -- } - lsp.prismals.setup { - capabilities = capabilities, - on_attach = on_lsp_attach, - } - - local eslint_d = { - lintCommand = 'eslint_d --cache -f visualstudio --stdin --stdin-filename ${INPUT}', - lintIgnoreExitCode = true, - lintStdin = true, - lintFormats = { - '%f(%l,%c): %tarning %m', - '%f(%l,%c): %trror %m' - }, - formatCommand = 'eslint_d --fix-to-stdout --stdin --stdin-filename ${INPUT}', - formatStdin = true - } - - lsp.efm.setup { - capabilities = capabilities, - on_attach = on_lsp_attach, - filetypes = { 'javascript', 'typescript' }, - init_options = { - documentFormatting = true - }, - settings = { - rootMarkers = { '.git' }, - lintDebounce = 500, - languages = { - typescript = { eslint_d }, - javascript = { eslint_d }, - vue = { eslint_d } - } - } - } - - -- LSP handlers - vim.lsp.handlers['textDocument/formatting'] = function(err, result, ctx) - -- Used to format the buffer in an async way. - -- https://github.com/lukas-reineke/dotfiles/blob/e84ddf819b7b279dd77b558a65421feca5543180/vim/lua/lsp/handlers.lua - if err ~= nil or result == nil then - return - end - if - vim.api.nvim_buf_get_var(ctx.bufnr, "init_changedtick") == vim.api.nvim_buf_get_var(ctx.bufnr, "changedtick") - then - local view = vim.fn.winsaveview() - vim.lsp.util.apply_text_edits(result, ctx.bufnr) - vim.fn.winrestview(view) - if ctx.bufnr == vim.api.nvim_get_current_buf() then - vim.b.saving_format = true - vim.cmd [[update]] - vim.b.saving_format = false - end - end - end -EOF + source $DOTFILES/nvim/neovim.vim endif diff --git a/nvim/neovim.vim b/nvim/neovim.vim new file mode 100644 index 0000000..5b0d7d1 --- /dev/null +++ b/nvim/neovim.vim @@ -0,0 +1,197 @@ +" Neovim-specific config (not VSCode, not IdeaVIM) +set spell +set spelllang=en,de +set spellsuggest=best,9 + +" Plugin keymaps +nnoremap v NvimTreeToggle +nnoremap xx TroubleToggle +nnoremap ff Telescope find_files +nnoremap fa Telescope find_files no_ignore=true +nnoremap fg Telescope live_grep +nnoremap fb Telescope buffers +nnoremap fh Telescope help_tags +nnoremap fs Telescope lsp_document_symbols +nnoremap fd Telescope lsp_document_diagnostics +nnoremap t :FloatermToggle +nnoremap n :FloatermPrev +nnoremap m :FloatermNext +nnoremap k :FloatermKill +nnoremap x lua vim.diagnostic.open_float() + +" LSP keymaps +nnoremap gh lua vim.lsp.buf.hover() +nnoremap gd lua vim.lsp.buf.definition() +nnoremap gD lua vim.lsp.buf.declaration() +nnoremap gr lua vim.lsp.buf.references() +nnoremap gi lua vim.lsp.buf.implementation() + +" -------------- +" Plugin config +" -------------- +let g:qs_highlight_on_keys = ['f', 'F', 't', 'T'] +let g:sneak#label = 1 +let g:floaterm_title = '($1|$2)' + +lua < 80 end }, + { 'diff', cond = function() return vim.fn.winwidth(0) > 80 end }, + { 'diagnostics', sources = { 'nvim_diagnostic' }, cond = function() return vim.fn.winwidth(0) > 50 end }, + }, + lualine_c = { 'filename' }, + lualine_x = { { 'encoding', cond = function() return vim.fn.winwidth(0) > 100 end } }, + lualine_y = { { 'progress', cond = function() return vim.fn.winwidth(0) > 100 end } }, + lualine_z = { { 'location', cond = function() return vim.fn.winwidth(0) > 100 end } }, + }, + extensions = { 'nvim-tree' }, +} +local telescope = require('telescope') +telescope.setup { + defaults = { + file_ignore_patterns = { '.git' }, + path_display = { 'truncate' }, + mappings = { + i = { [''] = require('telescope.actions').close }, + n = { ['q'] = require('telescope.actions').close }, + }, + }, + pickers = { find_files = { hidden = true } }, + extensions = { fzf = { fuzzy = true, override_generic_sorter = false, override_file_sorter = true } }, +} +telescope.load_extension('fzf') +require('nvim-treesitter.configs').setup { + ensure_installed = { + 'html','javascript','typescript','json','json5','jsonc','regex','rust','vim','vue','yaml','css','bash','lua','prisma' + }, + highlight = { enable = true }, + indent = { enable = true }, + context_commentstring = { enable = true }, +} +local parsers = require('nvim-treesitter.parsers') +local configs = parsers.get_parser_configs() +local ft_str = table.concat( + vim.tbl_map(function(ft) return configs[ft].filetype or ft end, parsers.available_parsers()), ',') +vim.cmd('autocmd Filetype ' .. ft_str .. ' setlocal foldmethod=expr foldexpr=nvim_treesitter#foldexpr()') +require('diffview').setup { enhanced_diff_hl = true } +local cmp = require('cmp') +cmp.setup { + snippet = { expand = function(args) vim.fn['vsnip#anonymous'](args.body) end }, + sources = { { name = 'nvim_lsp' }, { name = 'vsnip' }, { name = 'buffer' } }, + mapping = { + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.close(), + [''] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), + }, + formatting = { + format = require("lspkind").cmp_format({ + with_text = true, + menu = ({ nvim_lsp = "[LSP]", vsnip = "[Snippet]", buffer = "[Buffer]" }) + }), + }, +} +local capabilities = require('cmp_nvim_lsp').default_capabilities() +local on_lsp_attach = function (client) + if client.server_capabilities.document_formatting then + vim.cmd [[augroup Format]] + vim.cmd [[autocmd! * ]] + vim.cmd [[autocmd BufWritePost lua vim.lsp.buf.formatting()]] + vim.cmd [[augroup END]] + end + require('lsp_signature').on_attach({ + bind = true, + handler_opts = { border = 'none' }, + hint_enable = false, + padding = ' ' + }) +end +local lsp = require('lspconfig') +lsp.ts_ls.setup { + init_options = { preferences = { disableSuggestions = true } }, + capabilities = capabilities, + on_attach = function (client) + client.server_capabilities.document_formatting = false + on_lsp_attach(client) + end +} +lsp.volar.setup { + capabilities = capabilities, + on_attach = on_lsp_attach, + init_options = { typescript = { tsdk = '/usr/local/lib/node_modules/typescript/lib' } } +} +lsp.rust_analyzer.setup { capabilities = capabilities, on_attach = on_lsp_attach } +lsp.angularls.setup { capabilities = capabilities, on_attach = on_lsp_attach } +lsp.prismals.setup { capabilities = capabilities, on_attach = on_lsp_attach } +local eslint_d = { + lintCommand = 'eslint_d --cache -f visualstudio --stdin --stdin-filename ${INPUT}', + lintIgnoreExitCode = true, + lintStdin = true, + lintFormats = { + '%f(%l,%c): %tarning %m', + '%f(%l,%c): %trror %m' + }, + formatCommand = 'eslint_d --fix-to-stdout --stdin --stdin-filename ${INPUT}', + formatStdin = true +} +lsp.efm.setup { + capabilities = capabilities, + on_attach = on_lsp_attach, + filetypes = { 'javascript', 'typescript' }, + init_options = { documentFormatting = true }, + settings = { + rootMarkers = { '.git' }, + lintDebounce = 500, + languages = { + typescript = { eslint_d }, + javascript = { eslint_d }, + vue = { eslint_d } + } + } +} +vim.lsp.handlers['textDocument/formatting'] = function(err, result, ctx) + if err ~= nil or result == nil then return end + if vim.api.nvim_buf_get_var(ctx.bufnr, "init_changedtick") == vim.api.nvim_buf_get_var(ctx.bufnr, "changedtick") then + local view = vim.fn.winsaveview() + vim.lsp.util.apply_text_edits(result, ctx.bufnr) + vim.fn.winrestview(view) + if ctx.bufnr == vim.api.nvim_get_current_buf() then + vim.b.saving_format = true + vim.cmd [[update]] + vim.b.saving_format = false + end + end +end + +require('catppuccin').setup { + integrations = { + telescope = true, + nvimtree = { enabled = true }, + cmp = true + }, +} +EOF +let g:catppuccin_flavour = "macchiato" " latte, frappe, macchiato, mocha +colorscheme catppuccin +set background=dark +set termguicolors diff --git a/nvim/vscode.vim b/nvim/vscode.vim new file mode 100644 index 0000000..97b9a3a --- /dev/null +++ b/nvim/vscode.vim @@ -0,0 +1,13 @@ +" VSCode-specific config +nnoremap w lua require('vscode').action('workbench.action.files.save') +nnoremap q lua require('vscode').action('workbench.action.closeWindow') +nnoremap lua require('vscode').action('workbench.action.focusLeftGroup') +nnoremap lua require('vscode').action('workbench.action.focusBelowGroup') +nnoremap lua require('vscode').action('workbench.action.focusAboveGroup') +nnoremap lua require('vscode').action('workbench.action.focusRightGroup') + +nnoremap gh lua vim.lsp.buf.hover() +nnoremap gd lua vim.lsp.buf.definition() +nnoremap gD lua vim.lsp.buf.declaration() +nnoremap gr lua vim.lsp.buf.references() +nnoremap gi lua vim.lsp.buf.implementation() From 850366fa4bd48b379e83563c8f4a3d52c4a257f9 Mon Sep 17 00:00:00 2001 From: Sebastian Limbach Date: Thu, 10 Jul 2025 17:26:18 +0200 Subject: [PATCH 02/11] fix: add missing config --- nvim/neovim.vim | 474 +++++++++++++++++++++++++++++++++--------------- nvim/vscode.vim | 6 + 2 files changed, 329 insertions(+), 151 deletions(-) diff --git a/nvim/neovim.vim b/nvim/neovim.vim index 5b0d7d1..bed38fb 100644 --- a/nvim/neovim.vim +++ b/nvim/neovim.vim @@ -26,6 +26,20 @@ nnoremap gD lua vim.lsp.buf.declaration() nnoremap gr lua vim.lsp.buf.references() nnoremap gi lua vim.lsp.buf.implementation() +" -------------- +" Autocommands +" -------------- +augroup TrimTrailingWhiteSpace + au! + au BufWritePre * %s/\s\+$//e + au BufWritePre * %s/\n\+\%$//e +augroup END + +augroup HighlightYank + au! + au TextYankPost * silent! lua vim.highlight.on_yank{higroup="IncSearch", timeout=700} +augroup END + " -------------- " Plugin config " -------------- @@ -34,164 +48,322 @@ let g:sneak#label = 1 let g:floaterm_title = '($1|$2)' lua < 80 end }, - { 'diff', cond = function() return vim.fn.winwidth(0) > 80 end }, - { 'diagnostics', sources = { 'nvim_diagnostic' }, cond = function() return vim.fn.winwidth(0) > 50 end }, - }, - lualine_c = { 'filename' }, - lualine_x = { { 'encoding', cond = function() return vim.fn.winwidth(0) > 100 end } }, - lualine_y = { { 'progress', cond = function() return vim.fn.winwidth(0) > 100 end } }, - lualine_z = { { 'location', cond = function() return vim.fn.winwidth(0) > 100 end } }, - }, - extensions = { 'nvim-tree' }, -} -local telescope = require('telescope') -telescope.setup { - defaults = { - file_ignore_patterns = { '.git' }, - path_display = { 'truncate' }, - mappings = { - i = { [''] = require('telescope.actions').close }, - n = { ['q'] = require('telescope.actions').close }, - }, - }, - pickers = { find_files = { hidden = true } }, - extensions = { fzf = { fuzzy = true, override_generic_sorter = false, override_file_sorter = true } }, -} -telescope.load_extension('fzf') -require('nvim-treesitter.configs').setup { - ensure_installed = { - 'html','javascript','typescript','json','json5','jsonc','regex','rust','vim','vue','yaml','css','bash','lua','prisma' - }, - highlight = { enable = true }, - indent = { enable = true }, - context_commentstring = { enable = true }, -} -local parsers = require('nvim-treesitter.parsers') -local configs = parsers.get_parser_configs() -local ft_str = table.concat( - vim.tbl_map(function(ft) return configs[ft].filetype or ft end, parsers.available_parsers()), ',') -vim.cmd('autocmd Filetype ' .. ft_str .. ' setlocal foldmethod=expr foldexpr=nvim_treesitter#foldexpr()') -require('diffview').setup { enhanced_diff_hl = true } -local cmp = require('cmp') -cmp.setup { - snippet = { expand = function(args) vim.fn['vsnip#anonymous'](args.body) end }, - sources = { { name = 'nvim_lsp' }, { name = 'vsnip' }, { name = 'buffer' } }, - mapping = { - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.close(), - [''] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), - }, - formatting = { - format = require("lspkind").cmp_format({ - with_text = true, - menu = ({ nvim_lsp = "[LSP]", vsnip = "[Snippet]", buffer = "[Buffer]" }) - }), - }, -} -local capabilities = require('cmp_nvim_lsp').default_capabilities() -local on_lsp_attach = function (client) - if client.server_capabilities.document_formatting then - vim.cmd [[augroup Format]] - vim.cmd [[autocmd! * ]] - vim.cmd [[autocmd BufWritePost lua vim.lsp.buf.formatting()]] - vim.cmd [[augroup END]] - end - require('lsp_signature').on_attach({ - bind = true, - handler_opts = { border = 'none' }, - hint_enable = false, - padding = ' ' - }) -end -local lsp = require('lspconfig') -lsp.ts_ls.setup { - init_options = { preferences = { disableSuggestions = true } }, - capabilities = capabilities, - on_attach = function (client) - client.server_capabilities.document_formatting = false - on_lsp_attach(client) + -- Hardtime + require('hardtime').setup { + disable_mouse = false + } + + -- Comment + require('Comment').setup {} + + -- Autopairs + require('nvim-autopairs').setup { + check_ts = true + } + + -- Auto session + require('auto-session').setup { + pre_save_cmds = {'tabdo NvimTreeClose'} + } + + -- Nvim Tree + require('nvim-tree').setup { + diagnostics = { + enable = true + }, + view = { + adaptive_size = true + }, + git = { + ignore = false + }, + } + + -- Trouble + require('trouble').setup { + mode = 'document_diagnostics' + } + + -- Lualine + require('lualine').setup { + options = { + theme = 'iceberg_dark', + }, + sections = { + lualine_a = { 'mode' }, + lualine_b = { + { + 'branch', + cond = function() return vim.fn.winwidth(0) > 80 end + }, + { + 'diff', + cond = function() return vim.fn.winwidth(0) > 80 end + }, + { + 'diagnostics', + sources = { 'nvim_diagnostic' }, + cond = function() return vim.fn.winwidth(0) > 50 end + }, + }, + lualine_c = { 'filename' }, + lualine_x = { + { + 'encoding', + cond = function() return vim.fn.winwidth(0) > 100 end + } + }, + lualine_y = { + { + 'progress', + cond = function() return vim.fn.winwidth(0) > 100 end + } + }, + lualine_z = { + { + 'location', + cond = function() return vim.fn.winwidth(0) > 100 end + } + }, + }, + extensions = { 'nvim-tree' }, + } + + -- Telescope + local telescope = require('telescope') + telescope.setup { + defaults = { + file_ignore_patterns = { '.git' }, + path_display = { 'truncate' }, + mappings = { + i = { + [''] = require('telescope.actions').close, + }, + n = { + ['q'] = require('telescope.actions').close, + } + } + }, + pickers = { + find_files = { + hidden = true + } + }, + extensions = { + fzf = { + fuzzy = true, + override_generic_sorter = false, + override_file_sorter = true, + } + } + } + telescope.load_extension('fzf') + + -- Treesitter + require('nvim-treesitter.configs').setup { + ensure_installed = { + 'html', + 'javascript', + 'typescript', + 'json', + 'json5', + 'jsonc', + 'regex', + 'rust', + 'vim', + 'vue', + 'yaml', + 'css', + 'bash', + 'lua', + 'prisma' + }, + highlight = { + enable = true, + }, + indent = { + enable = true, + }, + context_commentstring = { + enable = true, + } + } + + -- Set foldmethod to 'expr' and use treesitter if the parser for the current filetype is installed. + local parsers = require('nvim-treesitter.parsers') + local configs = parsers.get_parser_configs() + local ft_str = table.concat( + vim.tbl_map(function(ft) return configs[ft].filetype or ft end, parsers.available_parsers() + ), ',') + vim.cmd('autocmd Filetype ' .. ft_str .. ' setlocal foldmethod=expr foldexpr=nvim_treesitter#foldexpr()') + + -- DiffView + require('diffview').setup { + enhanced_diff_hl = true + } + + -- LSP + -- Completion + local cmp = require('cmp') + cmp.setup { + snippet = { + expand = function(args) + vim.fn['vsnip#anonymous'](args.body) + end, + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'vsnip' }, + { name = 'buffer' } + }, + mapping = { + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.close(), + [''] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }) + }, + formatting = { + format = require("lspkind").cmp_format({ + with_text = true, + menu = ({ + nvim_lsp = "[LSP]", + vsnip = "[Snippet]", + buffer = "[Buffer]", + }) + }), + } + } + local capabilities = require('cmp_nvim_lsp').default_capabilities() + + -- LSP config + local on_lsp_attach = function (client) + -- If the lsp server support formatting format the buffer on save. + if client.server_capabilities.document_formatting then + vim.cmd [[augroup Format]] + vim.cmd [[autocmd! * ]] + vim.cmd [[autocmd BufWritePost lua vim.lsp.buf.formatting()]] + vim.cmd [[augroup END]] + end + + require('lsp_signature').on_attach({ + bind = true, + handler_opts = { + border = 'none' + }, + hint_enable = false, + padding = ' ' + }) end -} -lsp.volar.setup { - capabilities = capabilities, - on_attach = on_lsp_attach, - init_options = { typescript = { tsdk = '/usr/local/lib/node_modules/typescript/lib' } } -} -lsp.rust_analyzer.setup { capabilities = capabilities, on_attach = on_lsp_attach } -lsp.angularls.setup { capabilities = capabilities, on_attach = on_lsp_attach } -lsp.prismals.setup { capabilities = capabilities, on_attach = on_lsp_attach } -local eslint_d = { - lintCommand = 'eslint_d --cache -f visualstudio --stdin --stdin-filename ${INPUT}', - lintIgnoreExitCode = true, - lintStdin = true, - lintFormats = { - '%f(%l,%c): %tarning %m', - '%f(%l,%c): %trror %m' - }, - formatCommand = 'eslint_d --fix-to-stdout --stdin --stdin-filename ${INPUT}', - formatStdin = true -} -lsp.efm.setup { - capabilities = capabilities, - on_attach = on_lsp_attach, - filetypes = { 'javascript', 'typescript' }, - init_options = { documentFormatting = true }, - settings = { - rootMarkers = { '.git' }, - lintDebounce = 500, - languages = { - typescript = { eslint_d }, - javascript = { eslint_d }, - vue = { eslint_d } + + local lsp = require('lspconfig') + lsp.ts_ls.setup { + init_options = { + preferences = { + disableSuggestions = true + } + }, + capabilities = capabilities, + on_attach = function (client) + -- Disable document formatting for tsserver as efm will do this + client.server_capabilities.document_formatting = false + on_lsp_attach(client) + end + } + + -- lsp.vuels.setup {} + lsp.volar.setup { + capabilities = capabilities, + on_attach = on_lsp_attach, + init_options = { + typescript = { + tsdk = '/usr/local/lib/node_modules/typescript/lib' + } } } -} -vim.lsp.handlers['textDocument/formatting'] = function(err, result, ctx) - if err ~= nil or result == nil then return end - if vim.api.nvim_buf_get_var(ctx.bufnr, "init_changedtick") == vim.api.nvim_buf_get_var(ctx.bufnr, "changedtick") then - local view = vim.fn.winsaveview() - vim.lsp.util.apply_text_edits(result, ctx.bufnr) - vim.fn.winrestview(view) - if ctx.bufnr == vim.api.nvim_get_current_buf() then - vim.b.saving_format = true - vim.cmd [[update]] - vim.b.saving_format = false + lsp.rust_analyzer.setup { + capabilities = capabilities, + on_attach = on_lsp_attach, + } + lsp.angularls.setup { + capabilities = capabilities, + on_attach = on_lsp_attach, + } + -- lsp.emmet_ls.setup { + -- capabilities = capabilities, + -- on_attach = on_lsp_attach, + -- } + lsp.prismals.setup { + capabilities = capabilities, + on_attach = on_lsp_attach, + } + + local eslint_d = { + lintCommand = 'eslint_d --cache -f visualstudio --stdin --stdin-filename ${INPUT}', + lintIgnoreExitCode = true, + lintStdin = true, + lintFormats = { + '%f(%l,%c): %tarning %m', + '%f(%l,%c): %trror %m' + }, + formatCommand = 'eslint_d --fix-to-stdout --stdin --stdin-filename ${INPUT}', + formatStdin = true + } + + lsp.efm.setup { + capabilities = capabilities, + on_attach = on_lsp_attach, + filetypes = { 'javascript', 'typescript' }, + init_options = { + documentFormatting = true + }, + settings = { + rootMarkers = { '.git' }, + lintDebounce = 500, + languages = { + typescript = { eslint_d }, + javascript = { eslint_d }, + vue = { eslint_d } + } + } + } + + -- LSP handlers + vim.lsp.handlers['textDocument/formatting'] = function(err, result, ctx) + -- Used to format the buffer in an async way. + -- https://github.com/lukas-reineke/dotfiles/blob/e84ddf819b7b279dd77b558a65421feca5543180/vim/lua/lsp/handlers.lua + if err ~= nil or result == nil then + return + end + if + vim.api.nvim_buf_get_var(ctx.bufnr, "init_changedtick") == vim.api.nvim_buf_get_var(ctx.bufnr, "changedtick") + then + local view = vim.fn.winsaveview() + vim.lsp.util.apply_text_edits(result, ctx.bufnr) + vim.fn.winrestview(view) + if ctx.bufnr == vim.api.nvim_get_current_buf() then + vim.b.saving_format = true + vim.cmd [[update]] + vim.b.saving_format = false + end end end -end - -require('catppuccin').setup { - integrations = { - telescope = true, - nvimtree = { enabled = true }, - cmp = true - }, -} EOF + let g:catppuccin_flavour = "macchiato" " latte, frappe, macchiato, mocha colorscheme catppuccin set background=dark set termguicolors +highlight QuickScopePrimary guifg='#afff5f' gui=underline ctermfg=155 cterm=underline +highlight QuickScopeSecondary guifg='#5fffff' gui=underline ctermfg=81 cterm=underline +highlight Sneak guifg='#afff5f' gui=underline ctermfg=81 cterm=underline +highlight SneakLabel guifg='#afff5f' gui=underline ctermfg=81 cterm=underline +highlight SneakLabelMask guifg=NONE ctermfg=NONE cterm=nocombine +highlight DiffAdd guibg='#164846' +highlight DiffDelete guibg='#823c41' +highlight DiffChange guibg='#394b70' diff --git a/nvim/vscode.vim b/nvim/vscode.vim index 97b9a3a..b47b081 100644 --- a/nvim/vscode.vim +++ b/nvim/vscode.vim @@ -11,3 +11,9 @@ nnoremap gd lua vim.lsp.buf.definition() nnoremap gD lua vim.lsp.buf.declaration() nnoremap gr lua vim.lsp.buf.references() nnoremap gi lua vim.lsp.buf.implementation() + +lua < Date: Thu, 10 Jul 2025 17:28:43 +0200 Subject: [PATCH 03/11] fix: plugin section --- nvim/base.vim | 75 +++++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 32 deletions(-) diff --git a/nvim/base.vim b/nvim/base.vim index 65df9e5..1aeeff9 100644 --- a/nvim/base.vim +++ b/nvim/base.vim @@ -129,41 +129,52 @@ if empty(glob(data_dir . '/autoload/plug.vim')) autocmd VimEnter * PlugInstall --sync | source $MYVIMRC endif +" Run PlugInstall if there are missing plugins +autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) + \| PlugInstall --sync | q +\| endif + call plug#begin(stdpath('data') . '/plugged') - " Plugins for all environments - Plug 'tpope/vim-surround' " Provides mappings to easily change surroundings in pairs. - Plug 'wellle/targets.vim' " Adds various text objects to give you more targets to operate on. - Plug 'tpope/vim-repeat' " Makes plugin actions repeatable using dot. - Plug 'tpope/vim-sleuth' " Automatically adjusts 'shiftwidth' and 'expandtab' heuristically based on the current file. - Plug 'unblevable/quick-scope' " Highlight unique character in every word to help with f, F. - Plug 'justinmk/vim-sneak' " Jump vertically using two characters. - - " Environment-specific plugins + " Plugins + Plug 'tpope/vim-surround' " Provides mappings to easily change surroundings in pairs. + Plug 'wellle/targets.vim' " Adds various text objects to give you more targets to operate on. + Plug 'tpope/vim-repeat' " Makes plugin actions repeatable using dot. + Plug 'tpope/vim-sleuth' " Automatically adjusts 'shiftwidth' and 'expandtab' heuristically based on the current file. + Plug 'unblevable/quick-scope' " Highlight unique character in every word to help with f, F. + Plug 'justinmk/vim-sneak' " Jump vertically using two characters. + + " Disable certain plugins IdeaVIM + if !has('ide') + Plug 'm4xshen/hardtime.nvim' "Break bad habits, master Vim motions. + endif + + " Disable certain plugins for VSCode and IdeaVIM if !exists('g:vscode') && !has('ide') - Plug 'm4xshen/hardtime.nvim' " Break bad habits, master Vim motions. - Plug 'nvim-lua/plenary.nvim' " Dependency for a lot of lua plugins. Packages many lua utility functions. - Plug 'nvim-telescope/telescope.nvim' " Fuzzy file finder. + Plug 'nvim-lua/plenary.nvim' " Dependency for a lot of lua plugins. Packages many lua utility functions. + Plug 'nvim-telescope/telescope.nvim' " Fuzzy file finder. Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'make' } " Makes fuzzy finding in telescope faster. Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} " Syntax highlighting and other stuff. - Plug 'neovim/nvim-lspconfig' " Used to configure neovim lsp for different lsp servers. - Plug 'nvim-lualine/lualine.nvim' " Statusbar - Plug 'junegunn/vim-peekaboo' " Displays a right buffer to view register content & select the desired register before pasting. - Plug 'windwp/nvim-autopairs' " Automatically inserts matching brackets & quotes. - Plug 'kyazdani42/nvim-tree.lua' " Sidebar which displays the current working-tree (files). - Plug 'kyazdani42/nvim-web-devicons' " Icons for nvim-tree. - Plug 'hrsh7th/nvim-cmp' " Autocompletion plugin. - Plug 'hrsh7th/vim-vsnip' " Snipped engine used by nvim-cmp. Used to insert code snippets. - Plug 'hrsh7th/cmp-nvim-lsp' " LSP source for nvim-cmp. Is required to display lsp content in the autocomplete popover. - Plug 'hrsh7th/cmp-vsnip' " VSnip source for nvim-cmp. - Plug 'hrsh7th/cmp-buffer' " Buffer source for nvim-cmp. - Plug 'ray-x/lsp_signature.nvim' " Shows function signature when you type. - Plug 'onsails/lspkind-nvim' " Adds pictograms to completion popups. - Plug 'lukas-reineke/indent-blankline.nvim' " Display indentation lines. - Plug 'folke/trouble.nvim' " Display diagnostics in a pretty list. - Plug 'voldikss/vim-floaterm' " Use the terminal in a floating/popup window. - Plug 'sindrets/diffview.nvim' " Single tabpage interface for easily cycling through git diffs. - Plug 'rmagatti/auto-session' " Automatically creates sessions on exit & restores them as soon as vim is started. - Plug 'numToStr/Comment.nvim' " Smart and Powerful commenting plugin for neovim - Plug 'catppuccin/nvim' " Theme + Plug 'neovim/nvim-lspconfig' " Used to configure neovim lsp for different lsp servers. + Plug 'nvim-lualine/lualine.nvim' " Statusbar + Plug 'junegunn/vim-peekaboo' " Displays a right buffer to view register content & select the desired register before pasting. + Plug 'windwp/nvim-autopairs' " Automatically inserts matching brackets & quotes. + Plug 'kyazdani42/nvim-tree.lua' " Sidebar which displays the current working-tree (files). + Plug 'kyazdani42/nvim-web-devicons' " Icons for nvim-tree. + Plug 'hrsh7th/nvim-cmp' " Autocompletion plugin. + Plug 'hrsh7th/vim-vsnip' " Snipped engine used by nvim-cmp. Used to insert code snippets. + Plug 'hrsh7th/cmp-nvim-lsp' " LSP source for nvim-cmp. Is required to display lsp content in the autocomplete popover. + Plug 'hrsh7th/cmp-vsnip' " VSnip source for nvim-cmp. + Plug 'hrsh7th/cmp-buffer' " Buffer source for nvim-cmp. + Plug 'ray-x/lsp_signature.nvim' " Shows function signature when you type. + Plug 'onsails/lspkind-nvim' " Adds pictograms to completion popups. + Plug 'lukas-reineke/indent-blankline.nvim' " Display indentation lines. + Plug 'folke/trouble.nvim' " Display diagnostics in a pretty list. + Plug 'voldikss/vim-floaterm' " Use the terminal in a floating/popup window. + Plug 'sindrets/diffview.nvim' " Single tabpage interface for easily cycling through git diffs. + Plug 'rmagatti/auto-session' " Automatically creates sessions on exit & restores them as soon as vim is started. + Plug 'numToStr/Comment.nvim' " Smart and Powerful commenting plugin for neovim + + " Themes + Plug 'catppuccin/nvim' endif call plug#end() From 8dbd31267c38f73195871e6fba8184b336615402 Mon Sep 17 00:00:00 2001 From: Sebastian Limbach Date: Tue, 5 Aug 2025 10:23:29 +0200 Subject: [PATCH 04/11] refactor: move into configs folders --- install.conf.yaml | 2 +- nvim/{ => configs}/base.vim | 26 +++++++++++++++++++++++--- nvim/configs/idea.vim | 31 +++++++++++++++++++++++++++++++ nvim/{ => configs}/neovim.vim | 10 ---------- nvim/{ => configs}/vscode.vim | 6 ------ nvim/idea.vim | 6 ------ nvim/ideavimrc | 4 +++- nvim/init.vim | 15 --------------- nvim/vimrc | 9 +++++++++ 9 files changed, 67 insertions(+), 42 deletions(-) rename nvim/{ => configs}/base.vim (93%) create mode 100644 nvim/configs/idea.vim rename nvim/{ => configs}/neovim.vim (97%) rename nvim/{ => configs}/vscode.vim (92%) delete mode 100644 nvim/idea.vim delete mode 100644 nvim/init.vim create mode 100644 nvim/vimrc diff --git a/install.conf.yaml b/install.conf.yaml index a86a4fe..3d7ce8e 100644 --- a/install.conf.yaml +++ b/install.conf.yaml @@ -12,7 +12,7 @@ - link: ~/.zshrc: zsh/zshrc ~/.ideavimrc: nvim/ideavimrc - ~/.config/nvim/init.vim: nvim/init.vim + ~/.config/nvim/init.vim: nvim/vimrc ~/.gitignore: git/.gitignore ~/.gitconfig: git/.gitconfig ~/.gitconfig-sap: git/.gitconfig-sap diff --git a/nvim/base.vim b/nvim/configs/base.vim similarity index 93% rename from nvim/base.vim rename to nvim/configs/base.vim index 1aeeff9..a9efee8 100644 --- a/nvim/base.vim +++ b/nvim/configs/base.vim @@ -28,8 +28,8 @@ nnoremap Q :qa " Navigate between windows nnoremap :call WinMove('h') -nnoremap :call WinMove('j') -nnoremap :call WinMove('k') +" nnoremap :call WinMove('j') +" nnoremap :call WinMove('k') nnoremap :call WinMove('l') " Line ending/start on home row @@ -55,6 +55,10 @@ nnoremap << vnoremap > vnoremap < +" Remap next/prev in popups +inoremap +inoremap + " LSP keymaps (to be extended in env-specific configs) " -------------- @@ -146,6 +150,7 @@ call plug#begin(stdpath('data') . '/plugged') " Disable certain plugins IdeaVIM if !has('ide') Plug 'm4xshen/hardtime.nvim' "Break bad habits, master Vim motions. + Plug 'numToStr/Comment.nvim' " Smart and Powerful commenting plugin for neovim endif " Disable certain plugins for VSCode and IdeaVIM @@ -172,9 +177,24 @@ call plug#begin(stdpath('data') . '/plugged') Plug 'voldikss/vim-floaterm' " Use the terminal in a floating/popup window. Plug 'sindrets/diffview.nvim' " Single tabpage interface for easily cycling through git diffs. Plug 'rmagatti/auto-session' " Automatically creates sessions on exit & restores them as soon as vim is started. - Plug 'numToStr/Comment.nvim' " Smart and Powerful commenting plugin for neovim " Themes Plug 'catppuccin/nvim' endif call plug#end() + +" Plugin Configs +let g:qs_highlight_on_keys = ['f', 'F', 't', 'T'] +let g:sneak#label = 1 + +if !has('ide') +lua <(QuickJavaDoc) +nmap gd (GotoDeclaration) +nmap gD (GotoTypeDeclaration) +nmap gi (GotoImplementation) +nmap gr (ShowUsages) +nmap gt (GotoTest) +nmap gf (Back) +nmap gb (Forward) + +nmap gcc (CommentByLineComment) + +" File navigation +nmap ff (GotoFile) +nmap fr (RecentFiles) +nmap fc (FindInPath) +nmap (RecentFiles) +nmap fl (RecentLocations) +nmap fs (NewScratchFile) + +" Refactoring +nmap rn (RenameElement) +nmap rm (ExtractMethod) +nmap rv (IntroduceVariable) +nmap rf (IntroduceField) +nmap rs (ChangeSignature) +nmap rr (Refactorings.QuickListPopupAction) + +set highlightedyank diff --git a/nvim/neovim.vim b/nvim/configs/neovim.vim similarity index 97% rename from nvim/neovim.vim rename to nvim/configs/neovim.vim index bed38fb..f3a1c0e 100644 --- a/nvim/neovim.vim +++ b/nvim/configs/neovim.vim @@ -43,19 +43,9 @@ augroup END " -------------- " Plugin config " -------------- -let g:qs_highlight_on_keys = ['f', 'F', 't', 'T'] -let g:sneak#label = 1 let g:floaterm_title = '($1|$2)' lua <lua vim.lsp.buf.definition() nnoremap gD lua vim.lsp.buf.declaration() nnoremap gr lua vim.lsp.buf.references() nnoremap gi lua vim.lsp.buf.implementation() - -lua <(QuickJavaDoc) -map gd (GotoDeclaration) -map gD (GotoTypeDeclaration) -map gr (FindUsages) -map gi (GotoImplementation) diff --git a/nvim/ideavimrc b/nvim/ideavimrc index 3093258..2670afb 100644 --- a/nvim/ideavimrc +++ b/nvim/ideavimrc @@ -1 +1,3 @@ -source ~/.dotfiles/nvim/init.vim +source ~/.dotfiles/nvim/configs/base.vim +source ~/.dotfiles/nvim/configs/idea.vim + diff --git a/nvim/init.vim b/nvim/init.vim deleted file mode 100644 index 5653614..0000000 --- a/nvim/init.vim +++ /dev/null @@ -1,15 +0,0 @@ -" -------------- -" Main init.vim -" -------------- - -" Source base config -source $DOTFILES/nvim/base.vim - -" Source environment-specific config -if exists('g:vscode') - source $DOTFILES/nvim/vscode.vim -elseif has('ide') - source $DOTFILES/nvim/idea.vim -else - source $DOTFILES/nvim/neovim.vim -endif diff --git a/nvim/vimrc b/nvim/vimrc new file mode 100644 index 0000000..fe7d264 --- /dev/null +++ b/nvim/vimrc @@ -0,0 +1,9 @@ +" Source base config +source $DOTFILES/nvim/configs/base.vim + +" Source environment-specific config +if exists('g:vscode') + source $DOTFILES/nvim/configs/vscode.vim +else + source $DOTFILES/nvim/configs/neovim.vim +endif From e4814cf19626efad4501360dc2b15582cdb61254 Mon Sep 17 00:00:00 2001 From: Sebastian Limbach Date: Thu, 21 Aug 2025 15:37:15 +0200 Subject: [PATCH 05/11] feat: add gbu alias --- git/aliases.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/git/aliases.zsh b/git/aliases.zsh index c79028d..483825f 100644 --- a/git/aliases.zsh +++ b/git/aliases.zsh @@ -50,5 +50,6 @@ alias gcob='git checkout -b' alias gcp="git cherry-pick -x" alias gb='git branch' alias gbr='git branch -D' +alias gbu='git branch -u origin/$(git rev-parse --abbrev-ref HEAD)' alias lg='lazygit' From 8f317db7ea71231f71edcb921e6c3b0862903472 Mon Sep 17 00:00:00 2001 From: Sebastian Limbach Date: Thu, 21 Aug 2025 15:37:52 +0200 Subject: [PATCH 06/11] fix: use tpope/vim-commentary for IdeaVIM --- nvim/configs/base.vim | 5 +++++ nvim/configs/idea.vim | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/nvim/configs/base.vim b/nvim/configs/base.vim index a9efee8..1dd9cdd 100644 --- a/nvim/configs/base.vim +++ b/nvim/configs/base.vim @@ -147,6 +147,11 @@ call plug#begin(stdpath('data') . '/plugged') Plug 'unblevable/quick-scope' " Highlight unique character in every word to help with f, F. Plug 'justinmk/vim-sneak' " Jump vertically using two characters. + " Enable certain plugins IdeaVIM + if has('ide') + Plug 'tpope/vim-commentary' " Same as Comment.nvim but written in vimscript and without treesitter + endif + " Disable certain plugins IdeaVIM if !has('ide') Plug 'm4xshen/hardtime.nvim' "Break bad habits, master Vim motions. diff --git a/nvim/configs/idea.vim b/nvim/configs/idea.vim index 28f250d..79d7792 100644 --- a/nvim/configs/idea.vim +++ b/nvim/configs/idea.vim @@ -10,8 +10,6 @@ nmap gt (GotoTest) nmap gf (Back) nmap gb (Forward) -nmap gcc (CommentByLineComment) - " File navigation nmap ff (GotoFile) nmap fr (RecentFiles) From 3ee374446548496432cf67bbdef36cb28adfce56 Mon Sep 17 00:00:00 2001 From: Sebastian Limbach Date: Thu, 21 Aug 2025 15:43:55 +0200 Subject: [PATCH 07/11] feat: new zsh/secrets.zsh & use sapmachine java --- .gitignore | 1 + zsh/zshrc | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7c4c8eb --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +zsh/secrets.zsh diff --git a/zsh/zshrc b/zsh/zshrc index f2b9ca1..9286622 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -17,9 +17,9 @@ export LS_COLORS="di=34:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30 export CLICOLOR=true export PATH="/opt/homebrew/bin:./bin:/usr/local/bin:/usr/local/sbin:$DOTFILES/bin:$PATH" export MANPATH="/usr/local/man:/usr/local/mysql/man:/usr/local/git/man:$MANPATH" -export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/fre" -export PLATIN_JAVA="/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/fre" -export PLUGIN_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/fre" +export JAVA_HOME="/Library/Java/JavaVirtualMachines/sapmachine-17.jdk/Contents/Home" +export PLATIN_JAVA=$JAVA_HOME +export PLUGIN_HOME=$JAVA_HOME # Source ~/.profile if it exists if [ -f ~/.profile ]; then @@ -36,6 +36,11 @@ source $DOTFILES/zsh/config.zsh # Source key-bindings & completions source $DOTFILES/zsh/completions.zsh +# Source secrets if the file exists +if [ -f "$DOTFILES/zsh/secrets.zsh" ]; then + source "$DOTFILES/zsh/secrets.zsh" +fi + # Source aliases for file in $DOTFILES/**/aliases.zsh; do source "$file" From d4de49a1d149139e990979d8b4bcf2cb38a6388d Mon Sep 17 00:00:00 2001 From: Sebastian Limbach Date: Mon, 10 Nov 2025 14:42:33 +0100 Subject: [PATCH 08/11] feat: auto setup git remote --- git/.gitconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/git/.gitconfig b/git/.gitconfig index 4d72b85..c8da04a 100644 --- a/git/.gitconfig +++ b/git/.gitconfig @@ -48,6 +48,7 @@ autoCorrect = 1 [push] default = current + autoSetupRemote = true followTags = true [pull] rebase = merges From 6f414ee16948edfe7ae3230644c8434ae6c729e6 Mon Sep 17 00:00:00 2001 From: Sebastian Limbach Date: Mon, 10 Nov 2025 14:42:49 +0100 Subject: [PATCH 09/11] fix: separate window moving per editor --- nvim/configs/base.vim | 19 ------------------- nvim/configs/idea.vim | 4 ++++ nvim/configs/neovim.vim | 21 +++++++++++++++++++-- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/nvim/configs/base.vim b/nvim/configs/base.vim index 1dd9cdd..acf0450 100644 --- a/nvim/configs/base.vim +++ b/nvim/configs/base.vim @@ -26,12 +26,6 @@ nnoremap w :w nnoremap q :q nnoremap Q :qa -" Navigate between windows -nnoremap :call WinMove('h') -" nnoremap :call WinMove('j') -" nnoremap :call WinMove('k') -nnoremap :call WinMove('l') - " Line ending/start on home row nnoremap H ^ nnoremap L $ @@ -109,19 +103,6 @@ function! Cond(cond, ...) return a:cond ? opts : extend(opts, { 'on': [], 'for': [] }) endfunction -func! WinMove(key) - let t:curwin = winnr() - exec 'wincmd '.a:key - if (t:curwin == winnr()) - if (match(a:key,'[jk]')) - wincmd v - else - wincmd s - endif - exec 'wincmd '.a:key - endif -endfu - " -------------- " Plugins (shared and environment-specific) " -------------- diff --git a/nvim/configs/idea.vim b/nvim/configs/idea.vim index 79d7792..df1ae03 100644 --- a/nvim/configs/idea.vim +++ b/nvim/configs/idea.vim @@ -26,4 +26,8 @@ nmap rf (IntroduceField) nmap rs (ChangeSignature) nmap rr (Refactorings.QuickListPopupAction) +" Window navigation +nmap (PrevSplitter) +nmap (NextSplitter) + set highlightedyank diff --git a/nvim/configs/neovim.vim b/nvim/configs/neovim.vim index f3a1c0e..8c18afc 100644 --- a/nvim/configs/neovim.vim +++ b/nvim/configs/neovim.vim @@ -26,6 +26,25 @@ nnoremap gD lua vim.lsp.buf.declaration() nnoremap gr lua vim.lsp.buf.references() nnoremap gi lua vim.lsp.buf.implementation() +" Navigate between windows +nnoremap :call WinMove('h') +" nnoremap :call WinMove('j') +" nnoremap :call WinMove('k') +nnoremap :call WinMove('l') + +func! WinMove(key) + let t:curwin = winnr() + exec 'wincmd '.a:key + if (t:curwin == winnr()) + if (match(a:key,'[jk]')) + wincmd v + else + wincmd s + endif + exec 'wincmd '.a:key + endif +endf + " -------------- " Autocommands " -------------- @@ -207,8 +226,6 @@ lua <'] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.select_prev_item(), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete(), From 6863113341168cf631f143b9ec937b7d35c08417 Mon Sep 17 00:00:00 2001 From: Sebastian Limbach Date: Mon, 10 Nov 2025 14:43:42 +0100 Subject: [PATCH 10/11] fix: wrong PrevSplitter key --- nvim/configs/idea.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvim/configs/idea.vim b/nvim/configs/idea.vim index df1ae03..72db9e6 100644 --- a/nvim/configs/idea.vim +++ b/nvim/configs/idea.vim @@ -27,7 +27,7 @@ nmap rs (ChangeSignature) nmap rr (Refactorings.QuickListPopupAction) " Window navigation -nmap (PrevSplitter) +nmap (PrevSplitter) nmap (NextSplitter) set highlightedyank From 38d49aebb314664d63d72192690b72e75a1de874 Mon Sep 17 00:00:00 2001 From: Sebastian Limbach Date: Thu, 20 Nov 2025 15:17:42 +0100 Subject: [PATCH 11/11] feat: remove next/prev popup remap --- nvim/configs/base.vim | 4 ---- 1 file changed, 4 deletions(-) diff --git a/nvim/configs/base.vim b/nvim/configs/base.vim index acf0450..3205be9 100644 --- a/nvim/configs/base.vim +++ b/nvim/configs/base.vim @@ -49,10 +49,6 @@ nnoremap << vnoremap > vnoremap < -" Remap next/prev in popups -inoremap -inoremap - " LSP keymaps (to be extended in env-specific configs) " --------------