Created
January 19, 2023 13:02
-
-
Save abishekk92/fc6a3c229d878c940887c358fc47a07e to your computer and use it in GitHub Desktop.
Neovim Config
This file contains 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
let mapleader="," | |
syntax enable | |
set nobackup | |
set nowritebackup | |
set background=dark | |
colorscheme desert | |
set nocompatible | |
filetype plugin on | |
syntax on | |
set autoread " Auto reload file on changes | |
set hlsearch " highlight all search results | |
set ignorecase " do case insensitive search | |
set incsearch " show incremental search results as you type | |
set number " display line number | |
set noswapfile " disable swap file | |
set showmatch " Show matching brackets. | |
set formatoptions+=o " Continue comment marker in new lines. | |
set backspace= | |
set foldmethod=indent | |
set foldnestmax=3 | |
filetype plugin indent on | |
set smartindent | |
set tabstop=4 | |
set shiftwidth=4 | |
set expandtab | |
set mouse=a | |
" Easy splits | |
set splitbelow | |
set splitright | |
"Set relative number by default | |
set rnu | |
function! NumberToggle() | |
if(&relativenumber == 1) | |
set nornu | |
set number | |
else | |
set rnu | |
endif | |
endfunc | |
" Remove trailing whitespace | |
au BufWrite * FixWhitespace | |
nmap <C-P> :FZF<CR> | |
autocmd FileType json set syntax=jsonc | |
" Setup plugins | |
call plug#begin('~/.vim/plugged') | |
Plug 'junegunn/vim-easy-align' | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
Plug 'SirVer/ultisnips' | |
Plug 'honza/vim-snippets' | |
Plug 'dhruvasagar/vim-table-mode' | |
Plug 'lfilho/cosco.vim' | |
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } | |
Plug 'junegunn/fzf.vim' | |
Plug 'vimwiki/vimwiki' | |
Plug 'michal-h21/vim-zettel' | |
Plug 'preservim/tagbar' | |
Plug 'tpope/vim-surround' | |
Plug 'tpope/vim-fugitive' | |
Plug 'tpope/vim-rhubarb' | |
Plug 'tpope/vim-sensible' | |
Plug 'tpope/vim-commentary' | |
Plug 'tpope/vim-repeat' | |
Plug 'vim-airline/vim-airline' | |
Plug 'jpalardy/vim-slime' | |
Plug 'ap/vim-css-color' | |
Plug 'bronson/vim-trailing-whitespace' | |
Plug 'mxw/vim-jsx' | |
Plug 'rust-lang/rust.vim' | |
Plug 'lilyinstarlight/vim-sonic-pi' | |
Plug 'jordwalke/vim-reasonml' | |
Plug 'junegunn/goyo.vim' | |
Plug 'ianks/vim-tsx' | |
Plug 'leafgarland/typescript-vim' | |
Plug 'jiangmiao/auto-pairs' | |
Plug 'hashivim/vim-terraform' | |
Plug 'neoclide/jsonc.vim' | |
Plug 'jparise/vim-graphql' | |
Plug 'lifepillar/pgsql.vim' | |
Plug 'github/copilot.vim' | |
call plug#end() | |
"Comma or SemiColon | |
nmap <silent> <Leader>; <Plug>(cosco-commaOrSemiColon) | |
imap <silent> <Leader>; <Plug>(cosco-commaOrSemiColon) | |
let g:cosco_filetype_whitelist = ['rust', 'javascript', 'typescript'] | |
"Run format on save | |
let g:rustfmt_autosave = 1 | |
"Slime target for repl debugging | |
let g:slime_target = "tmux" | |
let g:slime_default_config = {"socket_name": "default", "target_pane": "{last}"} | |
let g:coc_global_extensions = ['coc-json', 'coc-git', 'coc-tsserver', 'coc-rust-analyzer', 'coc-snippets', 'coc-pairs', 'coc-go', 'coc-prettier'] | |
" Make <CR> to accept selected completion item or notify coc.nvim to format | |
" <C-g>u breaks current undo, please make your own choice. | |
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm() | |
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>" | |
" 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 ShowDocumentation()<CR> | |
"vimwiki config | |
let g:vimwiki_list = [{'path': '~/vimwiki/', | |
\ 'syntax': 'markdown', 'ext': '.md'}] | |
"Set up ultisnips directory | |
let g:UltiSnipsSnippetsDir = "~/.vim/bundle/ultisnips/UltiSnips" | |
autocmd BufWritePre *.go :silent call CocAction('runCommand', 'editor.action.organizeImport') | |
"Set up syntax highlighting for prisma | |
au BufNewFile,BufRead *.prisma setfiletype graphql | |
"Set defualt sql to postgres | |
let g:sql_type_default = 'pgsql' | |
command! Diary VimwikiDiaryIndex | |
augroup vimwikigroup | |
autocmd! | |
" automatically update links on read diary | |
autocmd BufRead,BufNewFile diary.wiki VimwikiDiaryGenerateLinks | |
autocmd FileType vimwiki nnoremap <buffer> <Leader>wx :VimwikiToggleListItem<CR> | |
augroup end | |
" Start interactive EasyAlign in visual mode (e.g. vipga) | |
xmap ga <Plug>(EasyAlign) | |
" Start interactive EasyAlign for a motion/text object (e.g. gaip) | |
nmap ga <Plug>(EasyAlign) | |
" Use <C-l> for trigger snippet expand. | |
imap <C-l> <Plug>(coc-snippets-expand) | |
" Use <C-j> for select text for visual placeholder of snippet. | |
vmap <C-j> <Plug>(coc-snippets-select) | |
" Use <C-j> for jump to next placeholder, it's default of coc.nvim | |
let g:coc_snippet_next = '<c-j>' | |
" Use <C-k> for jump to previous placeholder, it's default of coc.nvim | |
let g:coc_snippet_prev = '<c-k>' | |
" Use <C-j> for both expand and jump (make expand higher priority.) | |
imap <C-j> <Plug>(coc-snippets-expand-jump) | |
" Use <leader>x for convert visual selected code to snippet | |
xmap <leader>x <Plug>(coc-convert-snippet) | |
xmap <leader>a <Plug>(coc-codeaction-selected) | |
nmap <leader>a <Plug>(coc-codeaction-selected) | |
"Apply autofix on the current issue | |
nmap <leader>qf <Plug>(coc-fix-current) | |
" 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) | |
" Show tagbar | |
nmap <leader>t :TagbarToggle<cr> | |
nnoremap <leader>v :vnew<CR> | |
nnoremap <leader>bs :new<CR> | |
nnoremap <leader>ew <C-w>= | |
nnoremap <leader>w :w<CR> | |
nnoremap <leader>n :noh<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment