Skip to content

Instantly share code, notes, and snippets.

@araml
Last active November 14, 2024 23:37
Show Gist options
  • Save araml/e24f7f173aa51346be0d to your computer and use it in GitHub Desktop.
Save araml/e24f7f173aa51346be0d to your computer and use it in GitHub Desktop.
My vimrc for neovim
if $SHELL =~ 'bin/fish'
set shell=/bin/sh
endif
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
call plug#begin('~/.local/share/nvim/plugged')
" " alternatively, pass a path where Vundle should install plugins
" " call vundle#begin('~/some/path/here')
"
" " let Vundle manage Vundle, required
Plug 'octol/vim-cpp-enhanced-highlight'
Plug 'flazz/vim-colorschemes'
Plug 'scrooloose/nerdtree'
Plug 'terryma/vim-multiple-cursors'
Plug 'rhysd/vim-clang-format'
Plug 'Yggdroot/indentLine'
Plug 'tikhomirov/vim-glsl'
Plug 'araml/ldpl.vim'
" Plug 'xuhdev/vim-latex-live-preview', { 'for': 'tex' }
Plug 'dylanaraps/crayon'
Plug 'xolox/vim-colorscheme-switcher'
Plug 'xolox/vim-misc'
Plug 'arzg/vim-colors-xcode'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' }
Plug 'sotte/presenting.vim'
Plug 'tpope/vim-fugitive'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'lervag/vimtex'
" Plugin 'yaymukund/vim-haxe'
" " All of your Plugins must be added before the following line
call plug#end() " required
filetype plugin indent on " required
syntax on
" Rust and C/C++/ObjC formatters
let g:formatdef_clangformat = '"clang-format-12 -style=file"'
let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py'
let g:ycm_clangd_args=['--header-insertion=never']
let g:ycm_collect_identifiers_from_tag_files = 1
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_auto_trigger = 1
let g:ycm_confirm_extra_conf = 0
nmap <Leader>f :Autoformat<CR>
map <C-l> :NERDTreeToggle<CR>
map <C-K> :pyf ~/clang-format.py<cr>
imap <C-K> <c-o>:pyf ~/clang-format.py<cr>
" Enables syntax coloring
syntax enable
syntax on
" Set .rs files to use the syntax in rust file in ~/.vim/syntax/ folder
filetype on
fun! DontRemoveTrailingWhitespaceFromTypes()
" Don't strip on these filetypes
if &ft =~ 'markdown' || &ft =~'text'
return
endif
%s/\s\+$//e
endfun
" Removes trailing white space when saving
" autocmd BufWritePre * call DontRemoveTrailingWhitespaceFromTypes() " :%s/\s\+$//e
"
au BufNewFile,BufRead *.rs set filetype=rust
" fortran syntax
au BufNewFile,BufRead *.f90 set filetype=fortran
au BufNewFile,BufRead *.f08 set filetype=fortran
" c++
au BufNewFile,BufRead *.inl set filetype=cpp
au BufNewFile,BufRead *.cpp set filetype=cpp
au BufNewFile,BufRead *.h set filetype=cpp
au BufNewFile,BufRead *.c set filetype=cpp
" nasm
au BufNewFile,BufRead *.asm set filetype=nasm
au BufNewFile,BufRead *.s set filetype=nasm
" haxe
au BufNewFile,BufRead *.hx set filetype=haxe
" Indenting
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
"set noexpandtab
set expandtab
" set line numbers
set number
" autoindent
set autoindent
" mouse
set mouse=a
" hide mouse after typing
set mousehide
" highlight trail
"set list " Show tabs
"set lcs=trail:~
"set list
"set listchars=tab:>-
" word wrapping and highlight the 81th column
set tw=81
set textwidth=80
set colorcolumn=81
set formatoptions+=t
set laststatus=2
hi MatchParen cterm=bold ctermbg=none
if $TERM == "xterm-256color"
set t_Co=256
endif
set undofile
set undodir=$HOME/.vim/undo
"au VimEnter * NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
"autocmd! VimEnter * NERDTree | wincmd w
"set termguicolors
colorscheme SerialExperimentsLain
"let g:livepreview_engine = 'lualatex'
let g:livepreview_previewer = 'open -a Preview'
set conceallevel=0
let g:tex_conceal=""
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files']
" use <tab> to trigger completion and navigate to the next complete item
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
inoremap <silent><expr> <Tab>
\ coc#pum#visible() ? coc#pum#next(1) :
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment