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/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 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' 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/configs/base.vim b/nvim/configs/base.vim new file mode 100644 index 0000000..3205be9 --- /dev/null +++ b/nvim/configs/base.vim @@ -0,0 +1,182 @@ +" -------------- +" 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 + +" 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 + +" -------------- +" 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 + +" 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. + + " 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. + Plug 'numToStr/Comment.nvim' " Smart and Powerful commenting plugin for neovim + 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. + + " 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) + +" 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) + +" Window navigation +nmap (PrevSplitter) +nmap (NextSplitter) + +set highlightedyank diff --git a/nvim/configs/neovim.vim b/nvim/configs/neovim.vim new file mode 100644 index 0000000..8c18afc --- /dev/null +++ b/nvim/configs/neovim.vim @@ -0,0 +1,376 @@ +" 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() + +" 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 +" -------------- +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 +" -------------- +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' }, + } + + -- 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.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 + +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/configs/vscode.vim b/nvim/configs/vscode.vim new file mode 100644 index 0000000..97b9a3a --- /dev/null +++ b/nvim/configs/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() 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 6ed598d..0000000 --- a/nvim/init.vim +++ /dev/null @@ -1,600 +0,0 @@ -" -------------- -" Keymaps -" -------------- -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 -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() -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 -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 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"