diff --git a/.config/nvim/after/plugin/coc.vim b/.config/nvim/after/plugin/coc.vim new file mode 100755 index 0000000..c23d253 --- /dev/null +++ b/.config/nvim/after/plugin/coc.vim @@ -0,0 +1,139 @@ +" TextEdit might fail if hidden is not set. +set hidden + +" Some servers have issues with backup files, see #649. +set nobackup +set nowritebackup + +" Give more space for displaying messages. +set cmdheight=2 + +" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable +" delays and poor user experience. +set updatetime=300 + +" Don't pass messages to |ins-completion-menu|. +set shortmess+=c + +" Always show the signcolumn, otherwise it would shift the text each time +" diagnostics appear/become resolved. +if has("patch-8.1.1564") + " Recently vim can merge signcolumn and number column into one + set signcolumn=number +else + set signcolumn=yes +endif + +" Use tab for trigger completion with characters ahead and navigate. +" NOTE: Use command ':verbose imap ' to make sure tab is not mapped by +" other plugin before putting this into your config. +inoremap + \ pumvisible() ? "\" : + \ check_back_space() ? "\" : + \ coc#refresh() +inoremap pumvisible() ? "\" : "\" + +function! s:check_back_space() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' +endfunction + +" Use to trigger completion. +if has('nvim') + inoremap coc#refresh() +else + inoremap coc#refresh() +endif + +" Use to confirm completion, `u` means break undo chain at current +" position. Coc only does snippet and additional edit on confirm. +" could be remapped by other vim plugin, try `:verbose imap `. +if exists('*complete_info') + inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" +else + inoremap pumvisible() ? "\" : "\u\" +endif + +" Use `[g` and `]g` to navigate diagnostics +" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. +nmap [g (coc-diagnostic-prev) +nmap ]g (coc-diagnostic-next) + +" GoTo code navigation. +nmap gd (coc-definition) +nmap gy (coc-type-definition) +nmap gi (coc-implementation) +nmap gr (coc-references) + +" Use K to show documentation in preview window. +nnoremap K :call show_documentation() + +function! s:show_documentation() + if (index(['vim','help'], &filetype) >= 0) + execute 'h '.expand('') + else + call CocAction('doHover') + endif +endfunction + +" Highlight the symbol and its references when holding the cursor. +autocmd CursorHold * silent call CocActionAsync('highlight') + +" Symbol renaming. +nmap rn (coc-rename) + +" Formatting selected code. +xmap f (coc-format-selected) +nmap f (coc-format-selected) + +augroup mygroup + autocmd! + " Setup formatexpr specified filetype(s). + autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') + " Update signature help on jump placeholder. + autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') +augroup end + +" Applying codeAction to the selected region. +" Example: `aap` for current paragraph +xmap a (coc-codeaction-selected) +nmap a (coc-codeaction-selected) + +" Remap keys for applying codeAction to the current buffer. +nmap ac (coc-codeaction) +" Apply AutoFix to problem on the current line. +nmap qf (coc-fix-current) + +" Map function and class text objects +" NOTE: Requires 'textDocument.documentSymbol' support from the language server. +xmap if (coc-funcobj-i) +omap if (coc-funcobj-i) +xmap af (coc-funcobj-a) +omap af (coc-funcobj-a) +xmap ic (coc-classobj-i) +omap ic (coc-classobj-i) +xmap ac (coc-classobj-a) +omap ac (coc-classobj-a) + +" Use CTRL-S for selections ranges. +" Requires 'textDocument/selectionRange' support of LS, ex: coc-tsserver +" nmap (coc-range-select) +" xmap (coc-range-select) +" IMPORTANT: disabled because they interfere with + +" Add `:Format` command to format current buffer. +command! -nargs=0 Format :call CocAction('format') + +" Add `:Fold` command to fold current buffer. +command! -nargs=? Fold :call CocAction('fold', ) + +" Add `:OR` command for organize imports of the current buffer. +command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') + +" Add (Neo)Vim's native statusline support. +" NOTE: Please see `:h coc-status` for integrations with external plugins that +" provide custom statusline: lightline.vim, vim-airline. +" set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} +" IMPORTANT: disabled because the statusline is handled by lightline + +" Mappings for CoCList - see ./after/plugged/keys.vim diff --git a/.config/nvim/after/plugin/commands.vim b/.config/nvim/after/plugin/commands.vim new file mode 100755 index 0000000..f8d773b --- /dev/null +++ b/.config/nvim/after/plugin/commands.vim @@ -0,0 +1,28 @@ +" +" Commands +" + +" use fd --type f to only show files not ignored by VCS +command! ProjectFiles call fzf#run(fzf#wrap({'source': 'fd --type f'})) + + + +" +" AutoCMDs +" +" automatically go into insert mode when entering terminal +:au BufEnter * if &buftype == 'terminal' | :startinsert | endif + +" force lightline update +autocmd User CocStatusChange,CocDiagnosticChange call lightline#update() + +" tsx/jsx filetypes +autocmd BufNewFile,BufRead *.jsx set filetype=javascript.jsx +autocmd BufNewFile,BufRead *.tsx set filetype=typescript.tsx +" autocmd BufNewFile,BufRead *.rs set colorcolumn=80,100 + + +" disable scrolloff in the terminal +autocmd TermOpen,TermEnter * setlocal scrolloff=0 +autocmd TermLeave * setlocal scrolloff=8 +" autocmd TermOpen * setlocal scrolloff=0 diff --git a/.config/nvim/after/plugin/keys.vim b/.config/nvim/after/plugin/keys.vim new file mode 100755 index 0000000..13e8af5 --- /dev/null +++ b/.config/nvim/after/plugin/keys.vim @@ -0,0 +1,123 @@ +" Keybindings +let mapleader=";" + +" use ;; for escape +" http://vim.wikia.com/wiki/Avoid_the_escape_key +inoremap ;; + +" horizontal split with new buffer +nnoremap bh :new + +" vertical split with new buffer +nnoremap bv :vnew + +" improved keyboard navigation +nnoremap h h +nnoremap j j +nnoremap k k +nnoremap l l + +" improved keyboard support for navigation (especially terminal) +" http://neovim.io/doc/user/nvim_terminal_emulator.html +tnoremap +tnoremap h +tnoremap j +tnoremap k +tnoremap l +nnoremap h +nnoremap j +nnoremap k +nnoremap l + +if !exists('g:vscode') + " Auto start NERD tree when opening a directory + autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | wincmd p | endif + + " Auto start NERD tree if no files are specified + autocmd StdinReadPre * let s:std_in=1 + autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | exe 'NERDTree' | endif + + " Let quit work as expected if after entering :q the only window left open is NERD Tree itself + autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif + + " Shortcut to edit THIS configuration file: (e)dit (c)onfiguration + nnoremap ec :e $MYVIMRC + + " Shortcut to source (reload) THIS configuration file after editing it: (s)ource (c)onfiguraiton + nnoremap sc :source $MYVIMRC + + " Toggle NERDTree + " Can't get by itself to work, so this works as Ctrl - space - space + " https://github.com/neovim/neovim/issues/3101 + " http://stackoverflow.com/questions/7722177/how-do-i-map-ctrl-x-ctrl-o-to-ctrl-space-in-terminal-vim#answer-24550772 + "nnoremap :NERDTreeToggle + "nmap + nnoremap :NERDTreeToggle + + " toggle tagbar + nnoremap tb :TagbarToggle + + " toggle line numbers + nnoremap n :set number! number? + + " toggle line wrap + nnoremap w :set wrap! wrap? + + " toggle buffer (switch between current and last buffer) + nnoremap bb + + " go to next buffer + nnoremap bn :bn + nnoremap :bn + + " go to previous buffer + nnoremap bp :bp + " https://github.com/neovim/neovim/issues/2048 + nnoremap :bp + + " close buffer + nnoremap bd :bd + + " kill buffer + nnoremap bk :bd! + + " list buffers + nnoremap bl :ls + " list and select buffer + nnoremap bg :ls:buffer + + + " Start terminal in insert mode + au BufEnter * if &buftype == 'terminal' | :startinsert | endif + nnoremap tt :terminal + nnoremap tv :vnew:terminal + nnoremap th :new:terminal + tnoremap q + + + let s:hidden_all = 0 + function! ToggleHiddenAll() + if s:hidden_all == 0 + let s:hidden_all = 1 + set noshowmode + set noruler + set laststatus=0 + set noshowcmd + TagbarClose + NERDTreeClose + else + let s:hidden_all = 0 + set showmode + set ruler + set laststatus=2 + set showcmd + NERDTree + " NERDTree takes focus, so move focus back to the right + " (note: "l" is lowercase L (mapped to moving right) + wincmd l + TagbarOpen + endif + endfunction + + nnoremap h :call ToggleHiddenAll() +end diff --git a/.config/nvim/after/plugin/settings.vim b/.config/nvim/after/plugin/settings.vim new file mode 100755 index 0000000..15c6dc1 --- /dev/null +++ b/.config/nvim/after/plugin/settings.vim @@ -0,0 +1,30 @@ +set background=dark +set clipboard+=unnamedplus +" set colorcolumn=80 +set ignorecase smartcase +set incsearch +set list listchars=tab:⇒\ ,trail:· +set mouse+=a +set noswapfile +set nowrap +set number +set relativenumber +set scrolloff=8 +set termguicolors + +" hide mode as it's shown in lightline +set noshowmode + +syntax on + +" open new split panes to right and below (as you probably expect) +set splitright +set splitbelow + +" colorscheme nord +" colorscheme dracula +colorscheme challenger_deep + + +" terminal disable linenumber +au TermOpen * setlocal nonumber norelativenumber diff --git a/.config/nvim/coc-settings.json b/.config/nvim/coc-settings.json new file mode 100755 index 0000000..1c3caa6 --- /dev/null +++ b/.config/nvim/coc-settings.json @@ -0,0 +1,22 @@ +{ + "explorer.icon.enableNerdfont": true, + "java.format.enabled": false, + "rust-analyzer.updates.channel": "nightly", + "coc.preferences.formatOnSaveFiletypes": [ + "cs", + "html", + "java", + "javascript", + "json", + "go", + "python", + "rust", + "scala", + "typescript", + "typescript.tsx", + "typescriptreact", + "vue", + "xml" + ], + "languageserver": {} +} \ No newline at end of file diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim new file mode 100755 index 0000000..e0d6ccd --- /dev/null +++ b/.config/nvim/init.vim @@ -0,0 +1,79 @@ + +call plug#begin() + +Plug 'airblade/vim-gitgutter' +Plug 'andymass/vim-matchup' +Plug 'editorconfig/editorconfig-vim' +Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } +Plug 'junegunn/fzf.vim' +Plug 'junegunn/vim-easy-align' +Plug 'mg979/vim-visual-multi', {'branch': 'master'} +Plug 'neoclide/coc.nvim', {'branch': 'release'} +Plug 'tpope/vim-abolish' +Plug 'tpope/vim-commentary' +Plug 'tpope/vim-fugitive' +Plug 'tpope/vim-surround' +Plug 'edkolev/tmuxline.vim' + +Plug 'majutsushi/tagbar' +let g:tagbar_ctags_bin = '/usr/local/Cellar/universal-ctags/HEAD-b743975/bin/ctags' + +Plug 'itchyny/lightline.vim' +let g:lightline = { + \ 'colorscheme': 'challenger_deep', + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], + \ [ 'cocstatus', 'readonly', 'gitbranch', 'filename', 'modified' ] ] + \ }, + \ 'component_function': { + \ 'cocstatus': 'coc#status', + \ 'gitbranch': 'FugitiveHead', + \ }, + \ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" }, + \ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" } + \ } + +Plug 'airblade/vim-rooter' +let g:rooter_manual_only = 1 + +Plug 'justinmk/vim-sneak' +let g:sneak#label = 1 + +Plug 'machakann/vim-highlightedyank' +let g:highlightedyank_highlight_duration = 100 + +" NERD Tree - tree explorer +" https://github.com/scrooloose/nerdtree +" http://usevim.com/2012/07/18/nerdtree/ +" (loaded on first invocation of the command) +Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } + +" nerdtree-git-plugin - show git status in NERD Tree +" https://github.com/Xuyuanp/nerdtree-git-plugin +Plug 'Xuyuanp/nerdtree-git-plugin' + +" Enforce editor settings +" https://github.com/editorconfig/editorconfig-vim +Plug 'editorconfig/editorconfig-vim' + +" languages +Plug 'neoclide/jsonc.vim' + +Plug 'vim-python/python-syntax' +let g:python_highlight_all = 1 + +Plug 'JuliaEditorSupport/julia-vim' +let g:latex_to_unicode_auto = 1 + +" themes & colorschemes +Plug 'challenger-deep-theme/vim', { 'as': 'challenger-deep' } +Plug 'dracula/vim', { 'as': 'dracula' } + +Plug 'arcticicestudio/nord-vim' +let g:nord_cursor_line_number_background = 1 +let g:nord_bold = 1 +let g:nord_italic = 1 +let g:nord_italic_comments = 1 + +call plug#end() + diff --git a/.zshrc b/.zshrc index 2c5b710..87e36af 100644 --- a/.zshrc +++ b/.zshrc @@ -10,6 +10,9 @@ plugins=( export ZSH=$HOME/.oh-my-zsh source $ZSH/oh-my-zsh.sh +# Path settings +export PYENV_ROOT="$HOME/.pyenv" +export PATH="$PYENV_ROOT/bin:$PATH" export GOPATH=$HOME/go export PATH=$PATH:$GOPATH/bin export PATH="$HOME/.cargo/bin:$PATH"