Created
March 16, 2022 17:42
-
-
Save cfsanderson-fulcrum/bda8db5e990f2d541c1d0e355023d72c to your computer and use it in GitHub Desktop.
Neovim config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" ~/.config/nvim/plug-config/ | |
let g:coc_global_extensions = ['coc-snippets', 'coc-scssmodules', 'coc-prettier', 'coc-pairs', 'coc-tsserver', 'coc-eslint', 'coc-prettier', 'coc-json', 'coc-marketplace', 'coc-markdownlint', 'coc-html'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"coc.preferences.formatOnSaveFiletypes": [ | |
"css", | |
"markdown", | |
"javascript", | |
"html", | |
"yaml", | |
"json", | |
"python" | |
], | |
"markdownlint.config": { | |
"line_length": false | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" ~/.config/nvim/plug-config/ | |
" | |
" 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 <tab>' to make sure tab is not mapped by | |
" other plugin before putting this into your config. | |
inoremap <silent><expr> <TAB> | |
\ pumvisible() ? "\<C-n>" : | |
\ <SID>check_back_space() ? "\<TAB>" : | |
\ coc#refresh() | |
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" | |
function! s:check_back_space() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~# '\s' | |
endfunction | |
" Use <c-space> to trigger completion. | |
if has('nvim') | |
inoremap <silent><expr> <c-space> coc#refresh() | |
else | |
inoremap <silent><expr> <c-@> coc#refresh() | |
endif | |
" Make <CR> auto-select the first completion item and notify coc.nvim to | |
" format on enter, <cr> could be remapped by other vim plugin | |
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm() | |
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>" | |
" Use `[g` and `]g` to navigate diagnostics | |
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. | |
nmap <silent> [g <Plug>(coc-diagnostic-prev) | |
nmap <silent> ]g <Plug>(coc-diagnostic-next) | |
" GoTo code navigation. | |
nmap <silent> gd <Plug>(coc-definition) | |
nmap <silent> gy <Plug>(coc-type-definition) | |
nmap <silent> gi <Plug>(coc-implementation) | |
nmap <silent> gr <Plug>(coc-references) | |
" Use K to show documentation in preview window. | |
nnoremap <silent> K :call <SID>show_documentation()<CR> | |
function! s:show_documentation() | |
if (index(['vim','help'], &filetype) >= 0) | |
execute 'h '.expand('<cword>') | |
elseif (coc#rpc#ready()) | |
call CocActionAsync('doHover') | |
else | |
execute '!' . &keywordprg . " " . expand('<cword>') | |
endif | |
endfunction | |
" Highlight the symbol and its references when holding the cursor. | |
autocmd CursorHold * silent call CocActionAsync('highlight') | |
" Symbol renaming. | |
nmap <leader>rn <Plug>(coc-rename) | |
" Formatting selected code. | |
xmap <leader>f <Plug>(coc-format-selected) | |
nmap <leader>f <Plug>(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: `<leader>aap` for current paragraph | |
xmap <leader>a <Plug>(coc-codeaction-selected) | |
nmap <leader>a <Plug>(coc-codeaction-selected) | |
" Remap keys for applying codeAction to the current buffer. | |
nmap <leader>ac <Plug>(coc-codeaction) | |
" Apply AutoFix to problem on the current line. | |
nmap <leader>qf <Plug>(coc-fix-current) | |
" Map function and class text objects | |
" NOTE: Requires 'textDocument.documentSymbol' support from the language server. | |
xmap if <Plug>(coc-funcobj-i) | |
omap if <Plug>(coc-funcobj-i) | |
xmap af <Plug>(coc-funcobj-a) | |
omap af <Plug>(coc-funcobj-a) | |
xmap ic <Plug>(coc-classobj-i) | |
omap ic <Plug>(coc-classobj-i) | |
xmap ac <Plug>(coc-classobj-a) | |
omap ac <Plug>(coc-classobj-a) | |
" Remap <C-f> and <C-b> for scroll float windows/popups. | |
" Note coc#float#scroll works on neovim >= 0.4.0 or vim >= 8.2.0750 | |
nnoremap <nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>" | |
nnoremap <nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" | |
inoremap <nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>" | |
inoremap <nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>" | |
" NeoVim-only mapping for visual mode scroll | |
" Useful on signatureHelp after jump placeholder of snippet expansion | |
if has('nvim') | |
vnoremap <nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#nvim_scroll(1, 1) : "\<C-f>" | |
vnoremap <nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#nvim_scroll(0, 1) : "\<C-b>" | |
endif | |
" Use CTRL-S for selections ranges. | |
" Requires 'textDocument/selectionRange' support of language server. | |
nmap <silent> <C-s> <Plug>(coc-range-select) | |
xmap <silent> <C-s> <Plug>(coc-range-select) | |
" 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', <f-args>) | |
" 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','')} | |
" Mappings for CoCList | |
" Show all diagnostics. | |
nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr> | |
" Manage extensions. | |
nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr> | |
" Show commands. | |
nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr> | |
" Find symbol of current document. | |
nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr> | |
" Search workspace symbols. | |
nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr> | |
" Do default action for next item. | |
nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR> | |
" Do default action for previous item. | |
nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR> | |
" Resume latest coc list. | |
nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR> | |
" Explorer | |
let g:coc_explorer_global_presets = { | |
\ 'floating': { | |
\ 'position': 'floating', | |
\ }, | |
\ 'floatingLeftside': { | |
\ 'position': 'floating', | |
\ 'floating-position': 'left-center', | |
\ 'floating-width': 30, | |
\ }, | |
\ 'floatingRightside': { | |
\ 'position': 'floating', | |
\ 'floating-position': 'right-center', | |
\ 'floating-width': 30, | |
\ }, | |
\ 'simplify': { | |
\ 'file.child.template': '[selection | clip | 1] [indent][icon | 1] [filename omitCenter 1]' | |
\ } | |
\ } | |
"nmap <silent> <space>e :CocCommand explorer<CR> | |
" nnoremap <silent> <leader>e :CocCommand explorer<CR> | |
" nmap <space>f :CocCommand explorer --preset floatingRightside<CR> | |
autocmd BufEnter * if (winnr("$") == 1 && &filetype == 'coc-explorer') | q | endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"=============================================================================== | |
" _ | |
" ____ _ __(_)___ ___ | |
" / __ \ | / / / __ `__ \ | |
" / / / / |/ / / / / / / / | |
" /_/ /_/|___/_/_/ /_/ /_/ | |
" | |
"=============================================================================== | |
" @cfsanderson | |
source $HOME/.config/nvim/plug-config/coc.vim | |
syntax on | |
set belloff=all | |
set display+=lastline | |
set incsearch | |
set noerrorbells | |
set noswapfile | |
set nowrap | |
set number relativenumber | |
set scrolloff=5 | |
set sidescrolloff=5 | |
set shiftwidth=2 | |
set smartindent | |
set smartcase | |
set splitbelow | |
set splitright | |
set tabstop=2 softtabstop=2 expandtab | |
set undodir=~/.vim/undodir | |
highlight Comment cterm=italic | |
" NERDTREE | |
autocmd StdinReadPre * let s:std_in=1 | |
" Open NERDTree by default when vim starts up if no files specified | |
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif | |
" Automatically close a tab if NerdTree is the last thing running | |
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | |
" If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree. | |
"autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | | |
" \ let buf=bufnr() | buffer# | execute "normal! \<C-W>w" | execute 'buffer'.buf | endif | |
call plug#begin('~/.vim/plugged') | |
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' } | |
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } | |
Plug 'junegunn/fzf.vim' | |
Plug 'junegunn/goyo.vim' | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
Plug 'preservim/nerdtree' | |
Plug 'sheerun/vim-polyglot' | |
Plug 'tpope/vim-commentary' | |
Plug 'tpope/vim-fugitive' | |
Plug 'tpope/vim-sensible' | |
Plug '~/.vim/unmanaged-plugins/gruvbox-material' | |
Plug 'vim-airline/vim-airline' | |
Plug 'tiagofumo/vim-nerdtree-syntax-highlight' | |
Plug 'ryanoasis/vim-devicons' | |
Plug '~/.vim/unmanaged-plugins/vim-css-color' | |
call plug#end() | |
syntax enable | |
if has('termguicolors') | |
set termguicolors | |
endif | |
" ------------------------------------------------------------------------------ | |
" Python | |
" ------------------------------------------------------------------------------ | |
let g:python2_host_prog = '$HOME/.asdf/shims/python2' | |
let g:python3_host_prog = '$HOME/.asdf/shims/python3' | |
" ------------------------------------------------------------------------------ | |
" MarkdownPreview | |
" ------------------------------------------------------------------------------ | |
" set to 1, nvim will open the preview window after entering the markdown buffer | |
" default: 0 | |
let g:mkdp_auto_start = 0 | |
" set to 1, the nvim will auto close current preview window when change | |
" from markdown buffer to another buffer | |
" default: 1 | |
let g:mkdp_auto_close = 1 | |
" set to 1, the vim will refresh markdown when save the buffer or | |
" leave from insert mode, default 0 is auto refresh markdown as you edit or | |
" move the cursor | |
" default: 0 | |
let g:mkdp_refresh_slow = 0 | |
" set to 1, the MarkdownPreview command can be use for all files, | |
" by default it can be use in markdown file | |
" default: 0 | |
let g:mkdp_command_for_global = 0 | |
" set to 1, preview server available to others in your network | |
" by default, the server listens on localhost (127.0.0.1) | |
" default: 0 | |
let g:mkdp_open_to_the_world = 0 | |
" use custom IP to open preview page | |
" useful when you work in remote vim and preview on local browser | |
" more detail see: https://github.com/iamcco/markdown-preview.nvim/pull/9 | |
" default empty | |
let g:mkdp_open_ip = '' | |
" specify browser to open preview page | |
" default: '' | |
let g:mkdp_browser = '' | |
" set to 1, echo preview page url in command line when open preview page | |
" default is 0 | |
let g:mkdp_echo_preview_url = 0 | |
" a custom vim function name to open preview page | |
" this function will receive url as param | |
" default is empty | |
let g:mkdp_browserfunc = '' | |
" options for markdown render | |
" mkit: markdown-it options for render | |
" katex: katex options for math | |
" uml: markdown-it-plantuml options | |
" maid: mermaid options | |
" disable_sync_scroll: if disable sync scroll, default 0 | |
" sync_scroll_type: 'middle', 'top' or 'relative', default value is 'middle' | |
" middle: mean the cursor position alway show at the middle of the preview page | |
" top: mean the vim top viewport alway show at the top of the preview page | |
" relative: mean the cursor position alway show at the relative positon of the preview page | |
" hide_yaml_meta: if hide yaml metadata, default is 1 | |
" sequence_diagrams: js-sequence-diagrams options | |
" content_editable: if enable content editable for preview page, default: v:false | |
" disable_filename: if disable filename header for preview page, default: 0 | |
let g:mkdp_preview_options = { | |
\ 'mkit': {}, | |
\ 'katex': {}, | |
\ 'uml': {}, | |
\ 'maid': {}, | |
\ 'disable_sync_scroll': 0, | |
\ 'sync_scroll_type': 'middle', | |
\ 'hide_yaml_meta': 1, | |
\ 'sequence_diagrams': {}, | |
\ 'flowchart_diagrams': {}, | |
\ 'content_editable': v:false, | |
\ 'disable_filename': 0 | |
\ } | |
" use a custom markdown style must be absolute path | |
" like '/Users/username/markdown.css' or expand('~/markdown.css') | |
let g:mkdp_markdown_css = '' | |
" use a custom highlight style must absolute path | |
" like '/Users/username/highlight.css' or expand('~/highlight.css') | |
let g:mkdp_highlight_css = '' | |
" use a custom port to start server or random for empty | |
let g:mkdp_port = '' | |
" preview page title | |
" ${name} will be replace with the file name | |
let g:mkdp_page_title = '「${name}」' | |
" recognized filetypes | |
" these filetypes will have MarkdownPreview... commands | |
let g:mkdp_filetypes = ['markdown'] | |
"" Markdown Preview | |
let g:mkdp_auto_start = 0 | |
let g:mkdp_refresh_slow = 0 | |
let g:mkdp_browser = 'Google Chrome' | |
" ------------------------------------------------------------------------------ | |
" Goyo settings | |
" ------------------------------------------------------------------------------ | |
let g:goyo_width = 120 | |
function! s:goyo_enter() | |
set wrap | |
set linebreak | |
set noshowmode | |
set noshowcmd | |
set scrolloff=999 | |
execute "MarkdownPreview" | |
endfunction | |
function! s:goyo_leave() | |
set nowrap | |
set nolinebreak | |
set showmode | |
set showcmd | |
set scrolloff=5 | |
execute "MarkdownPreviewStop" | |
endfunction | |
autocmd! User GoyoEnter nested call <SID>goyo_enter() | |
autocmd! User GoyoLeave nested call <SID>goyo_leave() | |
"" flash yank highlight = great visual feedback | |
augroup highlight_yank | |
autocmd! | |
autocmd TextYankPost * silent! lua require'vim.highlight'.on_yank() | |
augroup END | |
" Gruvbox Material theme | |
let g:gruvbox_material_background = 'hard' | |
let g:gruvbox_material_enable_italic = 1 | |
let g:gruvbox_material_disable_italic_comment = 0 | |
let g:gruvbox_material_menu_selection_background = 'green' | |
let g:gruvbox_material_palette = 'material' | |
let g:gruvbox_material_sign_column_background = 'none' | |
colorscheme gruvbox-material | |
set background=dark | |
" jsx syntax highlighting | |
" dark red | |
hi tsxTagName guifg=#E06C75 | |
hi tsxComponentName guifg=#E06C75 | |
hi tsxCloseComponentName guifg=#E06C75 | |
" orange | |
hi tsxCloseString guifg=#F99575 | |
hi tsxCloseTag guifg=#F99575 | |
hi tsxCloseTagName guifg=#F99575 | |
hi tsxAttributeBraces guifg=#F99575 | |
hi tsxEqual guifg=#F99575 | |
" yellow | |
hi tsxAttrib guifg=#F8BD7F cterm=italic | |
"FZF settings | |
let g:fzf_layout = { 'window': { 'width': 0.8, 'height': 0.8 } } | |
let $FZF_DEFAULT_OPTS='--reverse' | |
"" Airline theme | |
let g:airline_theme = 'gruvbox_material' | |
" REMAPS | |
" Leader | |
let mapleader = "\<Space>" | |
" make return and shift+return open up new lines above and below respectively | |
" without going into insert mode. | |
nmap <C-o> O<Esc> | |
nmap <CR> o<Esc> | |
" ------------------ | |
" Coc config in ~/.config/nvim/plug-config/ | |
" ------------------ | |
" `gc` comments out a selection | |
" " Coc-rename | |
nmap <leader>rr <Plug>(coc-rename) | |
nnoremap <leader>prw :CocSearch <C-R>=expand("<cword>")<CR><CR> | |
" toggle NERDTree | |
map <leader>n :NERDTreeToggle<cr> | |
" open FZF | |
map <leader>f :FZF | |
" using * to search or visual selection this enters the replace command and | |
" puts your cursor in line to accept the term to replace | |
nnoremap <leader>r :%s///g<left><left> | |
nnoremap <leader>rc :%s///gc<left><left> | |
" source current file | |
nnoremap <leader>so :source %<cr> | |
" save current file | |
nnoremap <leader>w :w<cr> | |
" remap normal copy/paste keys to vim registers | |
vnoremap <C-c> "+y | |
noremap <C-p> "+p | |
" vim-fugitive - git workflow | |
nmap <leader>gs :G<CR> | |
nmap <leader>gj :diffget //3<CR> | |
nmap <leader>gf :diffget //2<CR> | |
" toggle search highlight | |
nnoremap <F3> :set hlsearch!<CR> | |
" clear search pattern | |
:command C let @/ = "" | |
" remap change split to just ctrl + {h,j,k,l} | |
map <C-H> <C-W><C-H> | |
map <C-J> <C-W><C-J> | |
map <C-K> <C-W><C-K> | |
map <C-L> <C-W><C-L> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment