Skip to content

Instantly share code, notes, and snippets.

@j1ah0ng
Created November 20, 2023 19:11
Show Gist options
  • Save j1ah0ng/69c28b25a778798e05de3b8b29291a49 to your computer and use it in GitHub Desktop.
Save j1ah0ng/69c28b25a778798e05de3b8b29291a49 to your computer and use it in GitHub Desktop.
init.vim
set nocompatible " be iMproved, required
filetype off " required
nnoremap <SPACE> <Nop>
let g:mapleader = " "
set relativenumber
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
let g:polyglot_disabled = ['java']
" plug plugins
" call plug#begin('~/.vim/plugged')
call plug#begin()
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'junegunn/goyo.vim'
Plug 'junegunn/limelight.vim'
Plug 'junegunn/fzf'
Plug 'danilamihailov/beacon.nvim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'reedes/vim-pencil'
Plug 'ruanyl/coverage.vim'
Plug 'ARM9/arm-syntax-vim'
Plug 'lervag/vimtex'
Plug 'arcticicestudio/nord-vim'
Plug 'sheerun/vim-polyglot'
Plug 'andweeb/presence.nvim'
Plug 'nvim-tree/nvim-web-devicons' " optional
Plug 'nvim-tree/nvim-tree.lua'
Plug 'tpope/vim-fugitive'
call plug#end()
" le blinky cursor
let &t_SI = "\<Esc>[5 q"
let &t_EI = "\<Esc>[1 q"
" italics
set t_ZH=^[[3m
set t_ZR=^[[23m
" fix mouse
set mouse=a
" set ttymouse=xterm
" folding
set foldlevel=99
set foldenable
set foldmethod=indent
" nnoremap <space> za
" show lines around search
set so=7
" disable beeps
set noerrorbells
set visualbell
set t_vb=
" fix vimdiff colour fuckery
highlight! link DiffText MatchParen
" nice font changes
highlight Comment cterm=italic gui=italic
highlight Italic cterm=italic gui=italic
highlight markdownItalic cterm=underline gui=italic
highlight markdownBold cterm=bold gui=bold
highlight Title cterm=bold gui=bold
" highlight MarkdownHeadingDelimiter cterm=bold gui=bold
" nice things
" set tw=80
syntax on
set cindent
set autochdir
set ruler
set nu
set backspace=indent,eol,start
set showmatch
set ignorecase
set smartcase
set hlsearch
set incsearch
set wildignorecase
set infercase
" tabs
set tabstop=4
set softtabstop=0 noexpandtab
set shiftwidth=4
set expandtab
set smarttab
" set cursor to unfuck kitty
set guicursor=n-v-c-sm:block,i-ci-ve:ver50,r-cr-o:hor50
" airline
let g:airline_powerline_fonts=1
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols.space = "\ua0"
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#show_buffers = 1
" setup nerdtree
" autocmd StdinReadPre * let s:std_in=1
" autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif
" map <C-n> :NERDTreeToggle<CR>
" pencil
let g:pencil#wrapModeDefault = 'soft'
augroup pencil
autocmd!
autocmd FileType text,markdown,mkd,gitcommit call pencil#init({'wrap': 'soft'})
augroup END
" text editing specifics
let g:tex_flavor = "latex"
au BufRead,BufNewFile COMMIT_EDITMSG,*.txt,*.md set wrap linebreak wrapmargin=0 nocindent
au BufRead,BufNewFile COMMIT_EDITMSG,*.txt,*.md nnoremap j gj
au BufRead,BufNewFile COMMIT_EDITMSG,*.txt,*.md nnoremap k gk
au BufRead,BufNewFile COMMIT_EDITMSG,*.txt,*.md nnoremap 0 g0
au BufRead,BufNewFile COMMIT_EDITMSG,*.txt,*.md nnoremap % g%
au BufRead,BufNewFile COMMIT_EDITMSG,*.txt,*.md nnoremap $ g$
au BufRead,BufNewFile COMMIT_EDITMSG,*.txt,*.md nnoremap <Home> g0
au BufRead,BufNewFile COMMIT_EDITMSG,*.txt,*.md nnoremap <End> g$
au BufRead,BufNewFile COMMIT_EDITMSG,*.txt,*.md set tw=0
au BufRead,BufNewFile COMMIT_EDITMSG,*.txt,*.md set noautoindent
au BufRead,BufNewFile COMMIT_EDITMSG,*.txt,*.md set nocindent
au BufRead,BufNewFile COMMIT_EDITMSG,*.txt,*.md set nosmartindent
" ycm
" let g:ycm_clangd_binary_path = "/usr/bin/clangd-10"
" let g:ycm_autoclose_preview_window_after_insertion = 1
colorscheme nord
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1) :
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
" 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>"
function! CheckBackspace() 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
" 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>
function! ShowDocumentation()
if CocAction('hasProvider', 'hover')
call CocActionAsync('doHover')
else
call feedkeys('K', 'in')
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 = <Plug>(coc-format-selected)
nmap = <Plug>(coc-format-selected)
" FZF
let g:fzf_vim = {}
let g:fzf_vim.preview_window = ['right,50%', 'ctrl-/']
nnoremap <Leader>d :call FZFProjectRoot()<CR>
nnoremap <Leader>f :FZF<CR>
" ...
" search from the git root if we're in a git repo
function! FZFProjectRoot()
let project_root = system('git rev-parse --show-toplevel 2> /dev/null')[:-2]
if strlen(project_root) > 0
call fzf#run(fzf#wrap('FZFProjectRoot', {'dir': project_root}))
else
call fzf#run(fzf#wrap('FZFProjectRoot'))
endif
endfunction
" markdown
autocmd! User GoyoEnter Limelight
autocmd! User GoyoLeave Limelight!
let g:limelight_conceal_ctermfg = 'DarkGray'
nnoremap <Leader>g :Goyo<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment