Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set laststatus=2
- set expandtab
- set shiftwidth=4
- set softtabstop=4
- set smarttab
- set expandtab
- set nojoinspaces
- set modeline
- set incsearch
- set hlsearch
- " opening a new file when the current buffer has unsaved changes causes files to be hidden instead of closed
- set hidden
- set iskeyword-=_
- set ttyfast
- set backup
- " in modes with folding, expand everything as much as possible
- set foldlevel=99
- set conceallevel=0
- " controls where new splits appear relative to the current window
- set splitbelow
- set splitright
- set lazyredraw
- set showmatch
- " I hit this a lot
- noremap :W :w
- " switch windows
- nnoremap <C-J> <C-W><C-J>
- nnoremap <C-K> <C-W><C-K>
- nnoremap <C-L> <C-W><C-L>
- nnoremap <C-H> <C-W><C-H>
- nnoremap <leader>D "=strftime("%c")<CR>P
- inoremap <leader>D <C-R>=strftime("%c")<CR>
- autocmd BufRead * let &l:modifiable = !&readonly
- " nmap <leader>bq :bp <BAR> bd #<CR>
- set tags=./TAGS;/
- " Bd works like bd without touching window splits
- command Bd bp | sp | bn | bd
- " remember where I was when reopening the file
- if has("autocmd")
- au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
- endif
- nmap <F1> :TagbarToggle<CR>
- call plug#begin()
- Plug 'rbgrouleff/bclose.vim'
- Plug 'ctrlpvim/ctrlp.vim'
- Plug 'chrisbra/Recover.vim'
- Plug 'tpope/vim-fugitive'
- " Plug 'Vimjas/vim-python-pep8-indent'
- Plug 'majutsushi/tagbar'
- Plug 'vim-scripts/DeleteTrailingWhitespace'
- Plug 'haya14busa/incsearch.vim'
- Plug 'SirVer/ultisnips'
- Plug 'tpope/vim-sensible'
- Plug 'ntpeters/vim-better-whitespace'
- Plug 'stephpy/vim-yaml'
- Plug 'jeetsukumaran/vim-buffergator'
- Plug 'psf/black'
- Plug 'machakann/vim-highlightedyank'
- Plug 'sheerun/vim-polyglot'
- " Plug 'vim-scripts/indentpython.vim'
- Plug 'lukhio/vim-mapping-conflicts'
- Plug 'AndrewRadev/splitjoin.vim'
- Plug 'fisadev/vim-isort'
- Plug 'ngemily/vim-vp4'
- Plug 'airblade/vim-gitgutter'
- Plug 'heavenshell/vim-pydocstring'
- Plug 'neovim/nvim-lspconfig'
- call plug#end()
- syntax on
- filetype plugin indent on
- autocmd BufEnter * set mouse=
- if !has('nvim')
- set ttymouse=sgr
- else
- set nofsync
- endif
- """" tmux-related settings
- " allows cursor change in tmux mode
- if exists('$TMUX')
- let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
- let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
- else
- let &t_SI = "\<Esc>]50;CursorShape=1\x7"
- let &t_EI = "\<Esc>]50;CursorShape=0\x7"
- endif
- function! WrapForTmux(s)
- if !exists('$TMUX')
- return a:s
- endif
- let tmux_start = "\<Esc>Ptmux;"
- let tmux_end = "\<Esc>\\"
- return tmux_start . substitute(a:s, "\<Esc>", "\<Esc>\<Esc>", 'g') . tmux_end
- endfunction
- let g:pydocstring_doq_path = "/home/bailey/.pyenv/shims/doq"
- let &t_SI .= WrapForTmux("\<Esc>[?2004h")
- let &t_EI .= WrapForTmux("\<Esc>[?2004l")
- autocmd VimResized * wincmd =
- let g:loaded_python_provider = 0
- let g:python3_host_prog = "/home/bailey/.pyenv/shims/python3"
- augroup syntax
- autocmd!
- autocmd FileType ruby setlocal shiftwidth=2 softtabstop=2
- autocmd FileType make setlocal noexpandtab tabstop=8 softtabstop=8 shiftwidth=8 autoindent
- autocmd FileType text setlocal wrap linebreak nolist textwidth=80 wrapmargin=0 autoindent
- autocmd FileType python setlocal tabstop=4 softtabstop=4 shiftwidth=4 colorcolumn=89 textwidth=0 wrapmargin=0 expandtab autoindent fileformat=unix
- autocmd FileType markdown setlocal wrap linebreak textwidth=78 wrapmargin=2 autoindent
- autocmd FileType c setlocal cindent cinoptions=>4,(0,W4
- autocmd FileType c setlocal comments=s1:/*,ex:*/
- autocmd FileType cpp setlocal cindent cinoptions=>4,(0,W4
- autocmd FileType cpp setlocal comments=s1:/*,ex:*/
- autocmd FileType gitcommit setlocal autoindent
- augroup END
- augroup filetypes
- autocmd!
- autocmd BufNewFile,BufRead akamake set filetype=make
- autocmd BufNewFile,BufRead host.lib set filetype=perl
- autocmd BufNewFile,BufRead *.mak.in set filetype=make
- autocmd BufNewFile,BufRead *.mak set filetype=make
- autocmd BufNewFile,BufRead akamake.m.* set filetype=make
- autocmd BufNewFile,BufRead akamake-env.mak.* set filetype=make
- autocmd BufNewFile,BufRead akamake*template* set filetype=make
- autocmd BufNewFile,BufRead akamake-bootstrap set filetype=make
- autocmd BufNewFile,BufRead .akamake.conf set filetype=make
- autocmd BufNewFile,BufRead r2.m4 set filetype=make
- autocmd BufNewFile,BufRead *.ronn set filetype=markdown
- autocmd BufNewFile,BufRead /home/bailey/.p4temp/* set filetype=perforce
- autocmd BufNewFile,BufRead .dbattery-profiles set filetype=json
- augroup END
- " automatically set paste when pasting via terminal
- function! XTermPasteBegin()
- set pastetoggle=<Esc>[201~
- set paste
- return ""
- endfunction
- inoremap <special> <expr> <Esc>[200~ XTermPasteBegin()
- highlight ExtraWhitespace ctermbg=red guibg=red
- hi Visual term=reverse cterm=reverse guibg=Grey
- match ExtraWhitespace /\s\+$/
- autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
- autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
- autocmd InsertLeave * match ExtraWhitespace /\s\+$/
- autocmd BufWinLeave * call clearmatches()
- """" ctrl-p settings
- set runtimepath^=~/.vim/plugged/ctrlp.vim
- let g:ctrlp_map = '<c-p>'
- let g:ctrlp_cmd = 'CtrlP'
- " let g:ctrlp_custom_ignore = '\Vvenv\|build/\|~$'
- let g:ctrlp_custom_ignore = {
- \ 'dir': '\.git$\|.tox\|\venv\|build$|debian$|log\|tmp$',
- \ 'file': '\~$\|\.dat$|\.DS_Store$'
- \ }
- let g:ctrlp_mruf_default_order = 1
- " close quickfix automatically if its the last window
- au BufEnter * call MyLastWindow()
- function! MyLastWindow()
- " if the window is quickfix go on
- if &buftype=="quickfix"
- " if this window is last on screen quit without warning
- " if winbufnr(2) == -1
- if winnr('$') < 2
- quit
- endif
- endif
- endfunction
- function! s:Diff_fn()
- let filetype=&ft
- diffthis
- vnew | r # | normal! 1Gdd
- diffthis
- exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
- endfunction
- com! Diff call s:Diff_fn()
- if v:version > 703 || v:version == 703 && has('patch541')
- set formatoptions+=j
- endif
- vnoremap < <gv
- vnoremap > >gv
- function! GitBranch()
- return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
- endfunction
- function! StatuslineGit()
- let l:branchname = GitBranch()
- return strlen(l:branchname) > 0?' '.l:branchname.' ':''
- endfunction
- function! InsertStatuslineColor(mode)
- if a:mode == 'i'
- hi statusline guibg=Cyan ctermfg=6 guifg=Black ctermbg=0
- elseif a:mode == 'r'
- hi statusline guibg=Purple ctermfg=5 guifg=Black ctermbg=0
- else
- hi statusline guibg=DarkRed ctermfg=1 guifg=Black ctermbg=0
- endif
- endfunction
- au InsertEnter * call InsertStatuslineColor(v:insertmode)
- au InsertLeave * hi statusline guibg=DarkGrey ctermfg=8 guifg=White ctermbg=15
- " default the statusline to green when entering Vim
- hi statusline guibg=DarkGrey ctermfg=8 guifg=White ctermbg=15
- " Formats the statusline
- set statusline=%f " file name
- set statusline+=[%{strlen(&fenc)?&fenc:'none'}, "file encoding
- set statusline+=%{&ff}] "file format
- set statusline+=%y "filetype
- set statusline+=%h "help file flag
- set statusline+=%m "modified flag
- set statusline+=%r "read only flag
- " Puts in the current git status
- set statusline+=%{fugitive#statusline()}
- set statusline+=\ %= " align left
- set statusline+=Line:%l/%L[%p%%] " line X of Y [percent of file]
- set statusline+=\ Col:%c " current column
- set statusline+=\ Buf:%n " Buffer number
- set statusline+=\ [%b][0x%B]\ " ASCII and byte code under cursor
- filetype plugin indent on
- let g:UltiSnipsExpandTrigger="<tab>"
- let g:UltiSnipsSnippetDirectories=["/home/bailey/.config/nvim/UltiSnips"]
- " for yaml
- au! BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml foldmethod=indent
- au! BufNewFile,BufReadPost Kptfile set filetype=yaml foldmethod=indent
- autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
- function! SplitLineNicely()
- " Save previous value of last search register
- let saved_last_search_pattern = @/
- " :substitute replaces the content of the search register with the `\s\+`
- " pattern highlighting all whitespaces in the file
- substitute /\s\+/\r/g
- " Restore previous search register
- let @/ = saved_last_search_pattern
- endfunction
- nmap <Leader>c :set cursorline! cursorcolumn!<CR>
- nnoremap <leader>q :execute "set colorcolumn=" . (&colorcolumn == "" ? "88" : "")<CR>
- nmap <Leader>h :nohlsearch<CR>
- nmap <Leader>n :set number relativenumber!<CR>
- nmap <Leader>t :TagbarToggle<CR>
- map <Leader>s :call SplitLineNicely<CR>
- nnoremap <Leader>s :<C-U>call SplitLineNicely()<CR>
- nmap <Leader>p :set paste!<CR>:set paste?<CR>
- " Reflow paragraph
- nnoremap <Leader>f gqip<CR>
- let g:bclose_no_plugin_maps = 1
- nmap <Leader>x :Bclose<CR>
- let g:buffergator_suppress_keymaps = 1
- let g:buffergator_autoexpand_on_split = 0
- let g:buffergator_display_regime = 'parentdir'
- let g:buffergator_vsplit_size = 60
- nmap <silent> <Leader>b :BuffergatorOpen<CR>
- nmap <silent> <Leader>B :BuffergatorClose<CR>
- "Remove all trailing whitespace by pressing F5
- nnoremap <leader>W :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar><CR>
- """" Python
- " python set omnifunc=pythoncomplete#Complete
- au BufRead *.py set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
- " Run when saving py files
- autocmd BufWritePre *.py :%s/\s\+$//e
- autocmd BufWritePre * :%s#\($\n\s*\)\+\%$##e
- " Ignore these files when completing
- set wildignore+=*.o,*.obj,.git,*.pyc
- set wildignore+=eggs/**
- set wildignore+=*.egg-info/**
- " Add the virtualenv's site-packages to vim path
- " if has('python')
- "py << EOF
- "import os.path
- "import sys
- "import vim
- "if 'VIRTUAL_ENV' in os.environ:
- " project_base_dir = os.environ['VIRTUAL_ENV']
- " sys.path.insert(0, project_base_dir)
- " activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
- " execfile(activate_this, dict(__file__=activate_this))
- "EOF
- "endif
- " Load up virtualenv's vimrc if it exists
- "if filereadable($VIRTUAL_ENV . '/.vimrc')
- " source $VIRTUAL_ENV/.vimrc
- "endif
- let g:go_version_warning = 0
- lua <<EOF
- -- See: https://github.com/neovim/nvim-lspconfig/tree/54eb2a070a4f389b1be0f98070f81d23e2b1a715#suggested-configuration
- local opts = { noremap=true, silent=true }
- vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
- vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
- vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
- vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
- -- Use an on_attach function to only map the following keys
- -- after the language server attaches to the current buffer
- local on_attach = function(client, bufnr)
- -- Enable completion triggered by <c-x><c-o>
- vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
- -- Mappings.
- -- See `:help vim.lsp.*` for documentation on any of the below functions
- local bufopts = { noremap=true, silent=true, buffer=bufnr }
- vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
- vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
- vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
- vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
- vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
- vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
- vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
- vim.keymap.set('n', '<space>wl', function()
- print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
- end, bufopts)
- vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
- vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
- vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
- vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
- vim.keymap.set('n', '<space>f', function() vim.lsp.buf.format { async = true } end, bufopts)
- end
- -- Configure `ruff-lsp`.
- -- See: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#ruff_lsp
- -- For the default config, along with instructions on how to customize the settings
- require('lspconfig').ruff_lsp.setup {
- on_attach = on_attach,
- init_options = {
- settings = {
- -- Any extra CLI arguments for `ruff` go here.
- args = {},
- }
- }
- }
- EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement