vim9script # Auto-install vim-plug var plugPath = "~/.config/vim/autoload/plug.vim" var vimrcPath = "~/.config/vim/vimrc" if empty(glob(plugPath)) silent execute '!curl -fLo ' .. plugPath .. ' --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' autocmd VimEnter * PlugInstall --sync | source vimrcPath endif # Install plugins only if vim-plug is available if filereadable(expand(plugPath)) call plug#begin() Plug 'airblade/vim-gitgutter' Plug 'ctrlpvim/ctrlp.vim' Plug 'dense-analysis/ale' Plug 'github/copilot.vim' Plug 'preservim/nerdtree' Plug 'rhysd/vim-healthcheck' Plug 'schickling/vim-bufonly' Plug 'tpope/vim-commentary' Plug 'vim-airline/vim-airline' call plug#end() endif # colorscheme charmtone g:mapleader = " " # Options set nocompatible set nobackup set nowritebackup set noswapfile set shell=bash set number set nowrap set expandtab set shiftwidth=4 set tabstop=4 set softtabstop=4 set termguicolors set showmatch set autoread set colorcolumn=80 set mouse=a set nospell set spelllang=en_us set cursorline set ruler set signcolumn=yes set listchars=tab:▸\ ,trail:·,eol:¶ set fillchars+=vert:│ set splitbelow set splitright set scrolloff=8 set sidescrolloff=5 set foldmethod=marker set equalalways set conceallevel=0 set pumheight=20 # Cursor shape set ttimeout set ttimeoutlen=1 set timeoutlen=3000 &t_SI = "\e[6 q" &t_EI = "\e[2 q" &t_SR = "\e[4 q" # Search set nohlsearch set ignorecase set incsearch set wrapscan # Persistent undo set undofile set undodir=~/.config/vim/undo # Text formatting options. See :help fo-table. set formatoptions=tcroq1]jp # Key mappings nnoremap gs ^ nnoremap gl $ nnoremap gn :bnext nnoremap gp :bprev nnoremap BO :BufOnly nnoremap f :find nnoremap g :grep nnoremap w :write nnoremap n :noautocmd write nnoremap gcc nnoremap y "+y # Visual Mode Blockwise Indent. This keeps the current visual block selection # active after changing indent with '<' or '>'. Usually the visual block # selection is lost after you shift it, which is incredibly annoying. # # See: http://vim.wikia.com/wiki/Short_mappings_for_common_tasks vnoremap > >gv vnoremap < indents in normal mode as well? nnoremap > >> nnoremap < << # Toggles nnoremap i :set invlist nnoremap S :set hlsearch! hlsearch? nnoremap W :set wrap! wrap? # Autocommands augroup fileTypeSettings autocmd! autocmd FileType lua setlocal noexpandtab augroup END augroup trimWhitespace autocmd! autocmd BufWritePre * :%s/\s\+$//e augroup END augroup cursorLine autocmd! autocmd WinEnter,BufEnter * setlocal cursorline autocmd WinLeave * setlocal nocursorline augroup END augroup windowResize autocmd! autocmd VimResized * wincmd = augroup END augroup markdownSpell autocmd! autocmd FileType markdown setlocal spell autocmd BufRead,BufNewFile *.md setlocal spell augroup END # CtrlP nnoremap ; :CtrlPBuffer g:ctrlp_max_height = 25 g:ctrlp_min_height = 25 g:ctrlp_custom_ignore = 'vendor\|node_modules\|.git\|\.cache' if executable('rg') g:ctrlp_use_ripgrep = 1 g:ctrlp_use_caching = 0 endif # BufOnly nnoremap BO :BufOnly # Commentary noremap CommentaryLine # NerdTree nnoremap t :NERDTreeToggle nnoremap f :NERDTreeFind # ALE #g:ale_open_list = 1 g:ale_set_highlights = 1 g:ale_set_signs = 1 g:ale_fix_on_save = 1 g:ale_completion_enabled = 1 g:ale_completion_delay = 100 g:ale_completion_autoimport = 1 g:ale_fixers = { go: ['gofumpt', 'golangci_lint'], haskell: ['fourmolu'], html: ['prettier'], json: ['prettier'], scss: ['prettier'], toml: ['taplo'], } nnoremap gd :ALEGoToDefinition nnoremap gs :ALESymbolSearch function ToggleALEList() if get(getloclist(0, {'winid':0}), 'winid', 0) lclose else lopen endif endfunction command! ALEToggleList call ToggleALEList() nnoremap E :ALEToggleList