set nocompatible syn on set maxmempattern=32000 " because https://github.com/vim/vim/issues/6777#issuecomment-684776825 " Because Konsole font size " https://github.com/neovim/neovim/issues/6798 set guicursor= set noautoread set ignorecase set smartcase set modeline set modelines=5 set wildmode=longest:full set wildmenu set hlsearch set textwidth=120 set backspace=eol,indent,start set number set signcolumn=yes "set mouse=a "Disabled "set grepprg=grep\ -nH\ $* set grepprg=rg\ --vimgrep\ $* let g:tex_flavor = "latex" setglobal formatoptions+=j " so that :find and :tabfind work set path=$PWD/** " in visual mode, show count set showcmd set scrolloff=3 " persistent-undo set undodir=~/.vim/undodir set undofile " remove toolbar set guioptions-=T " remove menu set guioptions-=m set formatoptions+=j " Delete comment character when joining commented lines set history=1000 set tabpagemax=50 let mapleader="\" call plug#begin('~/.vim/plugged') Plug 'mileszs/ack.vim' Plug 'airblade/vim-gitgutter' Plug 'vim-scripts/git-time-lapse' Plug 'vim-scripts/ifdef-highlighting' Plug 'jparise/vim-graphql' "Plug 'junegunn/fzf' "Plug 'junegunn/fzf.vim' Plug 'ctrlpvim/ctrlp.vim' Plug 'rust-lang/rust.vim' Plug 'scrooloose/nerdtree' Plug 'majutsushi/tagbar' Plug 'vim-scripts/taglist.vim' Plug 'tpope/vim-fugitive' Plug 'https://gitlab.com/Nate_B/vim-adif' Plug 'hashivim/vim-terraform' "Plug 'airblade/vim-tailwind' Plug 'https://gitlab.com/spade-lang/spade-vim' Plug 'https://git.sr.ht/~sotirisp/vim-tsv' Plug 'prettier/vim-prettier' if has("nvim") Plug 'neovim/nvim-lspconfig' endif "Plug 'neoclide/coc.nvim', {'branch': 'release'} call plug#end() " dotnet tool install -g csharp-ls if has("nvim") lua << EOF local nvim_lsp = require('lspconfig') -- For debugging, use :LspInfo --vim.lsp.set_log_level("debug") -- Retrieve logs using :lua vim.cmd('e'..vim.lsp.get_log_path()) vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( vim.lsp.diagnostic.on_publish_diagnostics, { signs = false, } ) -- 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) local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end -- Enable completion triggered by buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') -- Mappings. local opts = { noremap=true, silent=true } end -- See `:help vim.lsp.*` for documentation on any of the below functions --buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) --buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) --buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) -- Use a loop to conveniently call 'setup' on multiple servers and -- map buffer local keybindings when the language server attaches local servers = { 'clangd', 'rust_analyzer', 'pyright', 'ts_ls', 'verible', 'csharp_ls', 'bashls' } for _, lsp in ipairs(servers) do vim.lsp.config(lsp, { settings = { [lsp] = {} } }) vim.lsp.enable(lsp) --nvim_lsp[lsp].setup { -- on_attach = on_attach, -- flags = { -- debounce_text_changes = 150, -- } --} end EOF noremap gD :lua vim.lsp.buf.declaration() noremap D :lua vim.lsp.buf.type_definition() noremap gd :lua vim.lsp.buf.definition() noremap gK :lua vim.lsp.buf.hover() noremap gi :lua vim.lsp.buf.implementation() noremap :lua vim.lsp.buf.signature_help() noremap :lua vim.lsp.buf.rename() noremap c :lua vim.lsp.buf.code_action() noremap r :lua vim.lsp.buf.references() noremap d :lua vim.diagnostic.open_float() "noremap [d :lua vim.lsp.diagnostic.goto_prev() "noremap ]d :lua vim.lsp.diagnostic.goto_next() noremap q :lua vim.lsp.diagnostic.set_loclist() noremap F :lua vim.lsp.buf.formatting() else set pastetoggle= endif if executable('rg') let g:ackprg = "rg -ui --vimgrep" let g:ack_default_options = " -ui --vimgrep" elseif executable('ag') let g:ackprg = 'ag -u --vimgrep' endif noremap a :LAck! -t rust -t cpp -t c -t py -t ts -t cs -t js noremap A :LAck! noremap p :%!prettier % "Show + - ~ in the margin for vim modification let g:gitgutter_eager = 0 " only update on read/write " Also search tags let g:ctrlp_extensions = ['tag'] noremap b :CtrlPBuffer "let g:ctrlp_working_path_mode = 'a' "rust-lang/rust.vim let g:rust_recommended_style = 0 au FileType rust nmap m :make build au FileType rust nmap C :Cargo check noremap t :TagbarToggle colorscheme bramwombat function! ToggleFullScreen() call system("wmctrl -i -r ".v:windowid." -b toggle,fullscreen") redraw endfunction if has("nvim") set termguicolors set noincsearch tnoremap let g:terminal_color_0 = '#2e3436' let g:terminal_color_1 = '#cc0000' let g:terminal_color_2 = '#4e9a06' let g:terminal_color_3 = '#c4a000' let g:terminal_color_4 = '#4475b4' let g:terminal_color_5 = '#75507b' let g:terminal_color_6 = '#0b939b' let g:terminal_color_7 = '#d3d7cf' let g:terminal_color_8 = '#555753' let g:terminal_color_9 = '#ef2929' let g:terminal_color_10 = '#8ae234' let g:terminal_color_11 = '#fce94f' let g:terminal_color_12 = '#729fcf' let g:terminal_color_13 = '#ad7fa8' let g:terminal_color_14 = '#00f5e9' let g:terminal_color_15 = '#eeeeec' elseif has("gui_running") set guifont="Source Code Pro Medium 15" nnoremap :call ToggleFullScreen() if has("gui_win32") set guifont=Lucida_Console:h10:cANSI endif else set t_Co=256 endif set cursorline "set a sudo vim cmap w!! w !sudo tee % > /dev/null "folding set foldcolumn=2 set foldmethod=marker " tabs are 4 space by default set shiftwidth=4 set tabstop=4 set expandtab "What highlighting group is the current cursor on ? function! SyntaxItem() return synIDattr(synID(line("."),col("."),1),"name") endfunction "Nice statusbar set laststatus=2 set statusline= set statusline+=%-3.3n\ " buffer number set statusline+=%f\ " file name set statusline+=%h%m%r%w " flags set statusline+=\[%{strlen(&ft)?&ft:'none'}, " filetype set statusline+=%{&fileencoding}, " encoding set statusline+=%{&fileformat}, " file format set statusline+=%{((exists(\"+bomb\")\ &&\ &bomb)?\"B,\":\"\")}]\ " BOM set statusline+=%{strftime('%a\ %b\ %e\ %H:%M')}\ " hour "set statusline+=%{SyntaxItem()} " syntax highlight group under cursor set statusline+=%= " right align if !empty(glob("$HOME/.vim/pack/tpope/start/vim-fugitive/plugin/fugitive.vim")) set statusline+=%{fugitive#statusline()}\ " git branch endif set statusline+=0x%-8B\ " current char set statusline+=%-14.(%l,%c%V%)\ %<%P " offset "tags set tags=tags,./tags,../tags,../../tags "ARM Assembler for .s files autocmd BufNewFile,BufRead *.s set filetype=armasm "Markdown, not modula2 autocmd BufNewFile,BufRead *.md set filetype=markdown autocmd BufNewFile,BufRead *.toml set filetype=dosini autocmd BufNewFile,BufRead *.j2 set filetype=jinja set nostartofline "Leader-f switches from C source .c to header .h file "It automatically detects .cpp <-> .h " .c <-> .h " .cpp <-> .hpp function! MPB_Flip_Ext() python3 << endpython import vim import os.path def loadfile(filename): vim.command("e {}".format(filename)) currentfile = vim.eval('expand("%")') c_exts = ["c", "cpp", "cc"] h_exts = ["h", "hpp"] currentfile_split = currentfile.split(".") if len(currentfile_split) > 0: ext = currentfile_split[-1] basename = currentfile[:-(1+len(ext))] if ext in c_exts: for h_ext in h_exts: h_filename = basename + "." + h_ext if os.path.exists(h_filename): loadfile(h_filename) elif ext in h_exts: for c_ext in c_exts: c_filename = basename + "." + c_ext if os.path.exists(c_filename): loadfile(c_filename) endpython endfun noremap :call MPB_Flip_Ext() " Added for QSO logging function! MPB_Prepend_Time() python << endpython import vim import datetime now = datetime.datetime.utcnow() vim.current.line = now.strftime("%Y%m%d %H%M ") + vim.current.line endpython endfun noremap :call MPB_Prepend_Time() noremap m :lmake -j4 noremap M :lmake -C build -j4 "Show trailing whitespace highlight ExtraWhitespace ctermbg=darkgreen guibg=#344011 autocmd BufEnter * exe ':2match ExtraWhitespace /\s\+$\| \+\ze\t\|\t\+\ze /' " F5 sets the search register to the word under cursor, without moving " the cursor noremap :let @/ = expand(''):3match none " F6: Highlight the word under cursor in darkcyan highlight ManualHighlight ctermbg=darkcyan guibg=darkcyan noremap :exe printf('match ManualHighlight /%s/', escape(expand(''), '/\')) "Show tabs set listchars=tab:›\ ,trail:␣ set list set completeopt=menu,menuone,longest noremap R :cscope reset:CtrlPClearAllCaches "some CScope maps noremap fs :cscope f s if has("cscope") " add any database in current directory if filereadable("cscope.out") cs add cscope.out " else add database pointed to by environment elseif $CSCOPE_DB != "" cs add $CSCOPE_DB endif endif "short tag and tselect noremap [ :tselect noremap ] :tag "I use bnext and bprev a lot noremap [b :bprev noremap ]b :bnext "Same for location list noremap [l :lprev noremap ]l :lnext "Error list noremap [e :cNext noremap ]e :cnext noremap [h :GitGutterPrevHunk noremap ]h :GitGutterNextHunk "GIT stuff noremap gt :call TimeLapse() noremap gb :Git blame noremap e :NERDTreeToggle noremap T :set expandtab! " Vim. Live it. noremap noremap noremap noremap inoremap inoremap inoremap inoremap "very magic search noremap / /\v filetype plugin indent on