Skip to content

Instantly share code, notes, and snippets.

@zikosw
Last active October 4, 2022 07:26
Show Gist options
  • Save zikosw/6de52f445bb113156bc3d29640930915 to your computer and use it in GitHub Desktop.
Save zikosw/6de52f445bb113156bc3d29640930915 to your computer and use it in GitHub Desktop.
" Specify a directory for plugins
" - For Neovim:
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.local/share/nvim/plugged')
" Make sure you use single quotes
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'
Plug 'easymotion/vim-easymotion'
Plug 'tpope/vim-surround'
" Any valid git URL is allowed
Plug 'https://github.com/junegunn/vim-github-dashboard.git'
Plug 'tomtom/tcomment_vim'
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
" Plug 'nathanaelkane/vim-indent-guides'
Plug 'airblade/vim-gitgutter'
" Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'dense-analysis/ale', { 'for': 'clojure' }
Plug 'eraserhd/parinfer-rust', { 'for':'clojure', 'do': 'cargo build --release'}
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
Plug 'fatih/vim-go', { 'for': 'go' }
Plug 'ndmitchell/ghcid', { 'rtp': 'plugins/nvim' }
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'wakatime/vim-wakatime'
" Color
"Plug 'Rigellute/rigel'
Plug 'rakr/vim-one'
Plug 'jakwings/vim-pony', { 'for': 'pony' }
Plug 'rhysd/vim-crystal', { 'for': 'crystal' }
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Initialize plugin system
call plug#end()
" general
"" map <Space> as <Leader>, this don't change to current leader's key
"map <Space> <Leader>
" Remap the leader key to signle quote
let mapleader = "'"
" Run commands with semicolon
nnoremap ; :
set number relativenumber
set nu rnu
set termguicolors
" ale syntax checking
let g:ale_sign_column_always = 1
" let g:ale_list_window_size = 20
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-j> <Plug>(ale_next_wrap)
" airline
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#ale#enabled = 1
let g:airline_powerline_fonts = 1
let g:airline_theme = 'one'
"""" enable the theme
syntax enable
set background=light
let g:one_allow_italics = 1
colorscheme one
""""""""""""""""""""
function! ReplHere(...)
if !exists('b:terminal_job_id')
echom 'This buffer is not a terminal.'
return
end
let g:repl_term_id = b:terminal_job_id
echom 'terminal id: ' b:terminal_job_id
endfunction
function! ReplSend(...)
let [l:lnum1, l:col1] = getpos("'<")[1:2]
let [l:lnum2, l:col2] = getpos("'>")[1:2]
if &selection ==# 'exclusive'
let l:col2 -= 1
endif
let l:lines = getline(l:lnum1, l:lnum2)
let l:lines[-1] = l:lines[-1][:l:col2 - 1]
let l:lines[0] = l:lines[0][l:col1 - 1:]
call chansend(g:repl_term_id, join(l:lines+["\n"],""))
endfunction
"" COMMAND
command! ReplHere call ReplHere()
command! -range ReplSend call ReplSend()
nnoremap <C-r><C-h> :ReplHere<cr>
xnoremap <C-r><C-r> :ReplSend<cr>
"" GO
" let g:go_def_mapping_enabled = 1
let g:go_def_mode = 'gopls'
let g:go_info_mode = 'gopls'
let g:go_highlight_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_operators = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_build_constraints = 1
let g:go_highlight_generate_tags = 1
let g:go_highlight_array_whitespace_error = 1
let g:go_highlight_chan_whitespace_error = 1
let g:go_highlight_space_tab_error = 1
let g:go_highlight_operators = 1
let g:go_highlight_function_parameters = 1
let g:go_highlight_format_strings = 1
let g:go_highlight_variable_assignments = 1
let g:go_auto_sameids = 1
" let g:go_auto_type_info = 1
let g:go_fmt_command = "goimports"
autocmd FileType go setlocal ts=2 sts=2 sw=2
"" jump between go symbol/function
autocmd FileType go nnoremap <leader><C-r> :GoDecls<cr>
autocmd FileType go nnoremap <leader>gtf :GoTestFunc<cr>
autocmd FileType go nnoremap <Leader>i :GoInfo<cr>
" Global line completion (not just open buffers. ripgrep required.)
"autocmd FileType go nnoremap <C-i>
"inoremap <expr> <C-i> fzf#vim#complete(fzf#wrap({'source': 'gopkgs','options':'-workDir ./'}))
"nnoremap <C-i> :echo fzf#vim#complete(fzf#wrap({'source': 'gopkgs'}))
autocmd FileType go nnoremap <C-i> :call fzf#run(fzf#wrap({'source':'gopkgs','sink': 'GoImport'}))<cr>
set updatetime=100
" Search
nnoremap <C-p> :call fzf#run(fzf#wrap({'source': 'git ls-files','options': '--preview="bat --color=always {}"'}))<cr>
"" search by buffer name
nnoremap <silent> <leader>bb :call fzf#run(fzf#wrap({'source': map(range(1, bufnr('$')), 'bufname(v:val)'), 'options': '--preview="bat --color=always {}"'}))<cr>
"" Pass current word to :Rg when invoke
nnoremap <silent> <Leader>rg :Rg <C-R><C-W><CR>
nnoremap <silent> <leader>e :call Fzf_dev()<CR>
" ripgrep
if executable('rg')
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
set grepprg=rg\ --vimgrep
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>).'| tr -d "\017"', 1, <bang>0)
endif
" display indent guild
let g:indent_guides_enable_on_vim_startup = 1
" My Define keymap
"" OmniComplete on tab - Change <Tab> in InsertMode to Ctrl-X + Ctrl-O
imap <S-Tab> <C-x><C-o>
map <C-n> :NERDTreeToggle<CR>
"" Easymotion
map <Leader>j <Plug>(easymotion-j)
map <Leader>k <Plug>(easymotion-k)
nmap <Leader>W <Plug>(easymotion-overwin-w)
nmap <Leader>L <Plug>(easymotion-overwin-line)
" Save the current buffer using the leader key
noremap <Leader>w :w<CR>
" Save and exit Vim using the leader key
noremap <Leader>e :wq<CR>
" Exit without saving using the leader key
noremap <Leader>q :q<CR>
" Clipboard functionality (paste from system)
noremap <leader>y "+y
vnoremap <leader>y "+y
noremap <leader>p "+p
vnoremap <leader>p "+p
" Buffer
" close it with out closing window
command! BD :bn|:bd#
noremap <Leader>bd :BD<CR>
noremap <Leader>bn :bn<CR>
noremap <Leader>bp :bp<CR>
" Terminal
tnoremap <Esc> <C-\><C-n>
" VIM COC
" if hidden is not set, TextEdit might fail.
set hidden
" Some servers have issues with backup files, see #649
set nobackup
set nowritebackup
" Better display for messages
set cmdheight=2
" You will have bad experience for diagnostic messages when it's default 4000.
set updatetime=300
" don't give |ins-completion-menu| messages.
set shortmess+=c
" always show signcolumns
set signcolumn=yes
"
" " Use tab for trigger completion with characters ahead and navigate.
" " Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
" 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.
" inoremap <silent><expr> <c-space> coc#refresh()
"
" " Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
" " Coc only does snippet and additional edit on confirm.
" inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" " Or use `complete_info` if your vim support it, like:
" " inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
"
" " Use `[g` and `]g` to navigate diagnostics
" nmap <silent> [g <Plug>(coc-diagnostic-prev)
" nmap <silent> ]g <Plug>(coc-diagnostic-next)
"
" " Remap keys for gotos
" 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>')
" else
" call CocAction('doHover')
" endif
" endfunction
"
" " Highlight symbol under cursor on CursorHold
" " autocmd CursorHold * silent call CocActionAsync('highlight')
"
" " Remap for rename current word
" nmap <leader>rn <Plug>(coc-rename)
"
" " Remap for format selected region
" 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
"
" " Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
" xmap <leader>a <Plug>(coc-codeaction-selected)
" nmap <leader>a <Plug>(coc-codeaction-selected)
"
" " Remap for do codeAction of current line
" nmap <leader>ac <Plug>(coc-codeaction)
" " Fix autofix problem of current line
" nmap <leader>qf <Plug>(coc-fix-current)
"
" " Create mappings for function text object, requires document symbols feature of languageserver.
" xmap if <Plug>(coc-funcobj-i)
" xmap af <Plug>(coc-funcobj-a)
" omap if <Plug>(coc-funcobj-i)
" omap af <Plug>(coc-funcobj-a)
"
" " Use <C-d> for select selections ranges, needs server support, like: coc-tsserver, coc-python
" nmap <silent> <C-d> <Plug>(coc-range-select)
" xmap <silent> <C-d> <Plug>(coc-range-select)
"
" " Use `:Format` to format current buffer
" command! -nargs=0 Format :call CocAction('format')
"
" " Use `:Fold` to fold current buffer
" command! -nargs=? Fold :call CocAction('fold', <f-args>)
"
" " use `:OR` for organize import of current buffer
" command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
"
" " Add status line support, for integration with other plugin, checkout `:h coc-status`
" set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
"
" " Using CocList
" " Show all diagnostics
" nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
" " Manage extensions
" nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
" " Show commands
" nnoremap <silent> <space>c :<C-u>CocList commands<cr>
" " Find symbol of current document
" nnoremap <silent> <space>o :<C-u>CocList outline<cr>
" " Search workspace symbols
" nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
" " Do default action for next item.
" nnoremap <silent> <space>j :<C-u>CocNext<CR>
" " Do default action for previous item.
" nnoremap <silent> <space>k :<C-u>CocPrev<CR>
" " Resume latest coc list
" nnoremap <silent> <space>p :<C-u>CocListResume<CR>
"
let g:parinfer_logfile='/Users/supakornwarodom/.parinfer.log'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment