filetype plugin indent on filetype on syntax on set nocompatible hidden laststatus=2 set backspace=indent,eol,start let g:mapleader=" " let g:just_installed = 0 function! InstallPlug() if !filereadable(expand("~/.vim/autoload/plug.vim")) " try to install plug using curl and wget " If installation succeeds, we should source vim plug. if !executable('git') echom 'git not found.' finish endif if executable('curl') let result = system('curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim') if v:shell_error == 0 let g:just_installed = 1 return endif endif echom 'curl failed, trying wget. ' . result if executable('wget') && executable('mkdir') let result = system('mkdir -p ~/.vim/autoload && wget -O ~/.vim/autoload/plug.vim https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim') if v:shell_error == 0 let g:just_installed = 1 return endif endif echom 'wget failed too. ' . result finish endif endfu call InstallPlug() if g:just_installed == 1 source ~/.vim/autoload/plug.vim endif call plug#begin() if has('termguicolors') Plug 'catppuccin/vim' else Plug 'junegunn/seoul256.vim' endif Plug 'prabirshrestha/vim-lsp' Plug 'mattn/vim-lsp-settings' Plug 'prabirshrestha/asyncomplete.vim' Plug 'prabirshrestha/asyncomplete-lsp.vim' Plug 'Townk/vim-autoclose' Plug 'tpope/vim-fugitive' Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' Plug 'junegunn/goyo.vim' Plug 'junegunn/limelight.vim' call plug#end() " options set nu set rnu set mouse+=a set linebreak set shiftwidth=2 set tabstop=2 set softtabstop=2 set expandtab set smarttab set shiftround set autoindent set textwidth=80 set colorcolumn=80 set nowrap set undodir=~/.vim/undofiles set undofile nohlsearch incsearch set scrolloff=7 set wildmode=longest,list,full set wildmenu autocmd FileType tex,text set nosmarttab autoindent autocmd Filetype python set textwidth=0 formatprg=autopep8 shiftwidth=4 tabstop=4 softtabstop=4 autocmd FileType c,cpp,slang set nosmarttab autoindent autocmd Filetype markdown set nosmarttab shiftwidth=4 tabstop=4 softtabstop=4 autoindent autocmd BufReadPost * \ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit' \ | exe "normal! g`\"" \ | endif " Remaps nnoremap j gj nnoremap k gk nnoremap h nnoremap j nnoremap k nnoremap l nnoremap h nnoremap j nnoremap k nnoremap l inoremap ā inoremap ē inoremap ī inoremap ō inoremap ū nnoremap :w:!texbld run compile nnoremap :w:!./test.sh vnoremap J :m '>+1gv=gv vnoremap K :m '<-2gv=gv nnoremap J mzJ`z nnoremap zz nnoremap zz nnoremap n nzzzv nnoremap N Nzzzv xnoremap p _dP vnoremap y +y nnoremap y +y nnoremap Y +Y nnoremap x :!chmod +x %:p nnoremap X :!chmod -x % nnoremap e :! %:p nnoremap 1 1gt nnoremap 2 2gt nnoremap 3 3gt nnoremap 4 4gt nnoremap 5 5gt nnoremap 6 6gt nnoremap 7 7gt nnoremap 8 8gt nnoremap 9 9gt nnoremap c :tabclose nnoremap b :wprev nnoremap n :wnext " netrw nnoremap :20Lexplore nnoremap pv :Explore au FileType netrw nmap t " Plugin options must go at the bottom of the file. " install plugins if g:just_installed == 1 echom 'Installing Plugins...' PlugInstall endif " Goyo and themes if has('termguicolors') set termguicolors set background=dark colorscheme catppuccin_mocha let g:airline_theme = "catppuccin_mocha" else let g:seoul256_background = 234 let g:airline_theme = "seoul256" set background=dark colorscheme seoul256 endif autocmd! User GoyoEnter Limelight autocmd! User GoyoLeave Limelight! let g:airline_powerline_fonts = 1 let g:airline#extensions#tabline#enabled = 1 nnoremap z :Goyo nnoremap gs :Git " lsp set cot+=preview function! s:on_lsp_buffer_enabled() abort setlocal omnifunc=lsp#complete setlocal signcolumn=yes if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif nmap gd (lsp-definition) nmap gs (lsp-document-symbol-search) nmap gS (lsp-workspace-symbol-search) nmap gr (lsp-references) nmap gi (lsp-implementation) nmap gt (lsp-type-definition) nmap rn (lsp-rename) nmap [g (lsp-previous-diagnostic) nmap ]g (lsp-next-diagnostic) nmap K (lsp-hover) nnoremap ft :LspDocumentFormat let g:lsp_format_sync_timeout = 1000 endfunction if exists('*prop_add') && has('patch-9.0.0178') let g:lsp_diagnostics_virtual_text_enabled = 1 let g:lsp_diagnostics_virtual_text_align = "after" let g:lsp_diagnostics_virtual_text_padding_left = 5 endif augroup lsp_install au! autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() augroup END imap (asyncomplete_force_refresh) inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\\" : "\" autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif