From fcaf13a267b7bacd26ad8b2e952a793645e42bba Mon Sep 17 00:00:00 2001 From: Akshay Date: Mon, 15 Feb 2021 14:22:32 +0530 Subject: init --- .gitignore | 3 + after/syntax/python.vim | 6 ++ after/syntax/scheme.vim | 19 ++++ ftdetect/kotlin.vim | 2 + ftplugin/asm.vim | 1 + ftplugin/go.vim | 4 + ftplugin/haskell.vim | 30 +++++++ ftplugin/javascript.vim | 8 ++ ftplugin/kotlin.vim | 19 ++++ ftplugin/python.vim | 8 ++ ftplugin/rust.vim | 1 + ftplugin/scheme.vim | 17 ++++ ftplugin/tex.vim | 6 ++ ftplugin/typescript.vim | 7 ++ ftplugin/wiki.vim | 1 + init.vim | 224 ++++++++++++++++++++++++++++++++++++++++++++++++ lua/lsp.lua | 59 +++++++++++++ lua/treesitter.lua | 18 ++++ plugin/help.vim | 16 ++++ plugin/ignores.vim | 11 +++ plugin/maps.vim | 46 ++++++++++ plugin/statusline.vim | 139 ++++++++++++++++++++++++++++++ syntax/kotlin.vim | 139 ++++++++++++++++++++++++++++++ syntax/proto.vim | 106 +++++++++++++++++++++++ 24 files changed, 890 insertions(+) create mode 100644 .gitignore create mode 100644 after/syntax/python.vim create mode 100644 after/syntax/scheme.vim create mode 100644 ftdetect/kotlin.vim create mode 100644 ftplugin/asm.vim create mode 100644 ftplugin/go.vim create mode 100644 ftplugin/haskell.vim create mode 100644 ftplugin/javascript.vim create mode 100644 ftplugin/kotlin.vim create mode 100644 ftplugin/python.vim create mode 100644 ftplugin/rust.vim create mode 100644 ftplugin/scheme.vim create mode 100644 ftplugin/tex.vim create mode 100644 ftplugin/typescript.vim create mode 100644 ftplugin/wiki.vim create mode 100644 init.vim create mode 100644 lua/lsp.lua create mode 100644 lua/treesitter.lua create mode 100644 plugin/help.vim create mode 100644 plugin/ignores.vim create mode 100644 plugin/maps.vim create mode 100644 plugin/statusline.vim create mode 100644 syntax/kotlin.vim create mode 100644 syntax/proto.vim diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e883c08 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.netrwhist +after/.netrwhist +autoload/ diff --git a/after/syntax/python.vim b/after/syntax/python.vim new file mode 100644 index 0000000..278cdc2 --- /dev/null +++ b/after/syntax/python.vim @@ -0,0 +1,6 @@ +syntax keyword pyNiceLambda lambda conceal cchar=λ +highlight link pyNiceLambda secondAccent + +highlight! link Conceal Noise + +setlocal conceallevel=1 diff --git a/after/syntax/scheme.vim b/after/syntax/scheme.vim new file mode 100644 index 0000000..9a2972b --- /dev/null +++ b/after/syntax/scheme.vim @@ -0,0 +1,19 @@ +syntax keyword scmNiceLambda lambda conceal cchar=λ + +syntax clear schemeFunction + +syntax match scmNiceOperator "<=" conceal cchar=≤ +syntax match scmNiceOperator ">=" conceal cchar=≥ + +syn region scmNiceQuote matchgroup=secondAccent start=/'[`']*/ end=/[ \t\n()\[\]";]/me=e-1 +syn region scmNiceQuote matchgroup=secondAccent start=/'['`]*"/ skip=/\\[\\"]/ end=/"/ +syn region scmNiceQuote matchgroup=secondAccent start=/'['`]*|/ skip=/\\[\\|]/ end=/|/ +syn region scmNiceQuote matchgroup=secondAccent start=/'['`]*#\?(/ end=/)/ contains=ALLBUT,schemeQuasiquote,schemeQuasiquoteForm,schemeUnquote,schemeForm,schemeDatumCommentForm,schemeImport,@schemeImportCluster,@schemeSyntaxCluster + +highlight link scmNiceLambda schemeSyntax +highlight link scmNiceOperator Noise +highlight link scmNiceQuote secondAccent + +highlight! link Conceal Noise + +setlocal conceallevel=1 diff --git a/ftdetect/kotlin.vim b/ftdetect/kotlin.vim new file mode 100644 index 0000000..6d5ebb7 --- /dev/null +++ b/ftdetect/kotlin.vim @@ -0,0 +1,2 @@ +autocmd BufNewFile,BufRead *.kt setfiletype kotlin +autocmd BufNewFile,BufRead *.kts setfiletype kotlin diff --git a/ftplugin/asm.vim b/ftplugin/asm.vim new file mode 100644 index 0000000..dde370b --- /dev/null +++ b/ftplugin/asm.vim @@ -0,0 +1 @@ +syntax off diff --git a/ftplugin/go.vim b/ftplugin/go.vim new file mode 100644 index 0000000..6efd1fe --- /dev/null +++ b/ftplugin/go.vim @@ -0,0 +1,4 @@ +setlocal noexpandtab +setlocal autoindent +setlocal smarttab +setlocal formatoptions=croql diff --git a/ftplugin/haskell.vim b/ftplugin/haskell.vim new file mode 100644 index 0000000..651f033 --- /dev/null +++ b/ftplugin/haskell.vim @@ -0,0 +1,30 @@ +function! s:OverwriteBuffer(output) + let winview = winsaveview() + silent! undojoin + normal! gg"_dG + call append(0, split(a:output, '\v\n')) + normal! G"_dd + call winrestview(winview) +endfunction + +function! s:RunStylishHaskell() + let output = system("stylish-haskell" . " " . bufname("%")) + let errors = matchstr(output, '\(Language\.Haskell\.Stylish\.Parse\.parseModule:[^\x0]*\)') + if v:shell_error != 0 + echom output + elseif empty(errors) + call s:OverwriteBuffer(output) + write + else + echom errors + endif +endfunction + +set formatprg=stylish-haskell +set makeprg=hlint + +augroup HaskellLint + autocmd! + autocmd BufWritePost *.hs | call s:RunStylishHaskell() | silent make! | silent redraw! + autocmd QuickFixCmdPost [^l]* cwindow +augroup END diff --git a/ftplugin/javascript.vim b/ftplugin/javascript.vim new file mode 100644 index 0000000..454c153 --- /dev/null +++ b/ftplugin/javascript.vim @@ -0,0 +1,8 @@ +setlocal tabstop=2 +setlocal shiftwidth=2 +setlocal softtabstop=2 +setlocal formatoptions=croq +setlocal expandtab +setlocal autoindent +setlocal smarttab + diff --git a/ftplugin/kotlin.vim b/ftplugin/kotlin.vim new file mode 100644 index 0000000..d001ac1 --- /dev/null +++ b/ftplugin/kotlin.vim @@ -0,0 +1,19 @@ +setlocal tabstop=4 +setlocal softtabstop=4 +setlocal shiftwidth=4 +setlocal expandtab +setlocal autoindent +setlocal smarttab +setlocal formatoptions=croql + +setlocal comments=:// +setlocal commentstring=//\ %s + +setlocal makeprg=ktlint + +augroup KtLint + autocmd! + autocmd BufWritePost *.kt silent make! | silent redraw + autocmd QuickFixCmdPost [^l]* cwindow +augroup END + diff --git a/ftplugin/python.vim b/ftplugin/python.vim new file mode 100644 index 0000000..89b7508 --- /dev/null +++ b/ftplugin/python.vim @@ -0,0 +1,8 @@ +setlocal tabstop=4 +setlocal softtabstop=4 +setlocal shiftwidth=4 +setlocal expandtab +setlocal autoindent +setlocal smarttab +setlocal formatoptions=croql +setlocal formatprg=yapf diff --git a/ftplugin/rust.vim b/ftplugin/rust.vim new file mode 100644 index 0000000..cfd90ec --- /dev/null +++ b/ftplugin/rust.vim @@ -0,0 +1 @@ +setlocal ts=4 sts=4 sw=4 expandtab diff --git a/ftplugin/scheme.vim b/ftplugin/scheme.vim new file mode 100644 index 0000000..4af180c --- /dev/null +++ b/ftplugin/scheme.vim @@ -0,0 +1,17 @@ +setlocal tabstop=2 +setlocal softtabstop=2 +setlocal shiftwidth=2 +setlocal expandtab +setlocal autoindent +setlocal smarttab +setlocal formatoptions=croql + +setlocal makeprg=guile-lint + +augroup SchemeLint + autocmd! + autocmd BufWritePost *.scm silent make! | silent redraw + autocmd QuickFixCmdPost [^l]* cwindow +augroup END + +CocDisable diff --git a/ftplugin/tex.vim b/ftplugin/tex.vim new file mode 100644 index 0000000..515fb7a --- /dev/null +++ b/ftplugin/tex.vim @@ -0,0 +1,6 @@ +setlocal wrap +setlocal number +nnoremap j gj +nnoremap k gk +let g:tex_conceal="abdmgs" +let g:tex_fold_enabled=1 diff --git a/ftplugin/typescript.vim b/ftplugin/typescript.vim new file mode 100644 index 0000000..c6132bb --- /dev/null +++ b/ftplugin/typescript.vim @@ -0,0 +1,7 @@ +setlocal tabstop=2 +setlocal shiftwidth=2 +setlocal softtabstop=2 +setlocal formatoptions=croq +setlocal expandtab +setlocal autoindent +setlocal smarttab diff --git a/ftplugin/wiki.vim b/ftplugin/wiki.vim new file mode 100644 index 0000000..88a5339 --- /dev/null +++ b/ftplugin/wiki.vim @@ -0,0 +1 @@ +set textwidth=72 diff --git a/init.vim b/init.vim new file mode 100644 index 0000000..8eb7889 --- /dev/null +++ b/init.vim @@ -0,0 +1,224 @@ +let &t_ZM = "\e[3m" + +call plug#begin('~/.local/share/nvim/plugged') + +Plug 'airblade/vim-gitgutter' +Plug 'godlygeek/tabular' +Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } +Plug 'junegunn/fzf.vim' +Plug 'vimwiki/vimwiki' + +" tpope +Plug 'tpope/vim-repeat' +Plug 'tpope/vim-surround' +Plug 'tpope/vim-unimpaired' +Plug 'tpope/vim-fugitive' + +" syntax and friends +Plug 'rust-lang/rust.vim', {'for': 'rust'} +Plug 'lervag/vimtex', {'for': 'tex'} +Plug 'neovimhaskell/haskell-vim', {'for': ['haskell', 'cabal']} +Plug 'elmcast/elm-vim' +Plug 'LnL7/vim-nix' + +" my stuff +Plug 'git@ferrn:vim/vim-colors-plain' +Plug 'git@ferrn:vim/better-text-objs' + +" nvim only +Plug 'hrsh7th/nvim-compe' +Plug 'neovim/nvim-lspconfig' +Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} + +call plug#end() + + +" augroups + +augroup plaintext + autocmd! + autocmd FileType text,markdown setlocal ts=2 sts=2 sw=2 expandtab textwidth=60 +augroup END + +augroup webdev + autocmd! + autocmd FileType less,css,html,js?,ts? setlocal ts=2 sts=2 sw=2 expandtab + autocmd FileType less,css,html nnoremap s viB:sort +augroup END + +augroup restorecursor + autocmd BufReadPost * + \ if line("'\"") > 1 && line("'\"") <= line("$") | + \ execute "normal! g`\"" | + \ endif +augroup END + +augroup vimrc-incsearch-highlight + autocmd! + autocmd CmdlineEnter /,\? :set hlsearch + autocmd CmdlineLeave /,\? :set nohlsearch +augroup END + +augroup fzfstatus + if has('nvim') && !exists('g:fzf_layout') + autocmd! FileType fzf + autocmd FileType fzf set laststatus=0 noshowmode noruler + \| autocmd BufLeave set laststatus=2 showmode ruler + endif +augroup END + +" general settings +set nobackup +set nowritebackup +set noswapfile " get rid of swapfiles everywhere +set dir=/tmp + +syntax on + +set omnifunc=syntaxcomplete#Complete +set completefunc=LanguageClient#complete +set list +filetype off +filetype plugin indent on +set laststatus=2 +set nowrap +set noshowmode +set listchars=tab:┊\ ,nbsp:␣,trail:·,extends:>,precedes:< +set fillchars=vert:\│,stl:\ ,stlnc:\ +set ignorecase +set smartcase +set sidescroll=40 +set incsearch +set undofile +set undodir=~/tmp +set path+=** +set backspace=indent,eol,start +set hidden +set wildmenu +set complete=.,w,b,i,u,t, +set background=dark +set mouse=a +set conceallevel=0 +set nonumber +set grepprg=rg\ --vimgrep\ --no-heading +set grepformat=%f:%l:%c:%m,%f:%l:%m +set cmdheight=2 +set shortmess+=c +set updatetime=300 +set signcolumn=yes +set inccommand=split +set showmatch +set diffopt+=vertical +set completeopt=menuone,noinsert,noselect + +let g:netrw_browsex_viewer= "xdg-open" + +colorscheme plain + +set shiftwidth=4 " indent = 4 spaces +set expandtab +set tabstop=4 " tab = 4 spaces +set softtabstop=4 " backspace through spaces + +" Functions +function! GetTabber() " a lil function that integrates well with Tabular.vim + let c = nr2char(getchar()) + :execute 'Tabularize /' . c +endfunction + +" Ugh +command! WQ wq +command! Wq wq +command! Wqa wqa +command! WQa wqa +command! W w +command! Q q + +" abbreviations +abclear +iab #i #include +iab #d #define +cab dst put =strftime('%d %a, %b %Y') +cab vg vimgrep +cab vga vimgrepadd +cab bfd bufdo + +" man pages +let g:ft_man_open_mode = 'tab' + +let g:gitgutter_override_sign_column_highlight = 0 +let g:gitgutter_sign_added = '+' +let g:gitgutter_sign_modified = '~' +let g:gitgutter_sign_removed = '-' +let g:gitgutter_sign_removed_first_line = '-' +let g:gitgutter_sign_modified_removed = '~' + +let g:fzf_colors = + \ { 'fg': ['fg', 'Noise'], + \ 'bg': ['bg', 'Noise'], + \ 'hl': ['fg', 'Statement'], + \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], + \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], + \ 'hl+': ['fg', 'Statement'], + \ 'info': ['fg', 'PreProc'], + \ 'border': ['fg', 'Ignore'], + \ 'prompt': ['fg', 'Conditional'], + \ 'pointer': ['fg', 'Exception'], + \ 'marker': ['fg', 'Keyword'], + \ 'spinner': ['fg', 'Label'], + \ 'header': ['fg', 'Comment'] } +let g:fzf_layout = { 'down': '40%' } +let g:fzf_preview_window = [] + +highlight GitGutterAdd ctermfg=8 +highlight GitGutterChange ctermfg=8 +highlight GitGutterDelete ctermfg=8 + +let g:rustfmt_autosave = 1 + +let g:latex_view_general_viewer = "zathura" +let g:vimtex_view_method = "zathura" +let g:tex_flavor = 'latex' + +let g:elm_setup_keybindings = 0 + +let g:completion_enable_auto_hover = 0 +let g:completion_matching_strategy_list = ['exact', 'substring', 'fuzzy', 'all'] +let g:completion_trigger_on_delete = 1 + +let g:compe = {} +let g:compe.enabled = v:true +let g:compe.autocomplete = v:true +let g:compe.debug = v:false +let g:compe.min_length = 1 +let g:compe.preselect = 'enable' +let g:compe.throttle_time = 80 +let g:compe.source_timeout = 200 +let g:compe.incomplete_delay = 400 +let g:compe.max_abbr_width = 100 +let g:compe.max_kind_width = 100 +let g:compe.max_menu_width = 100 +let g:compe.documentation = v:true + +let g:compe.source = {} +let g:compe.source.path = v:true +let g:compe.source.buffer = v:true +let g:compe.source.calc = v:true +let g:compe.source.vsnip = v:false +let g:compe.source.nvim_lsp = v:true +let g:compe.source.nvim_lua = v:false +let g:compe.source.spell = v:true +let g:compe.source.tags = v:true +let g:compe.source.snippets_nvim = v:false +let g:compe.source.treesitter = v:true +let g:compe.source.omni = v:true + +sign define LspDiagnosticsSignError text=× texthl=LspDiagnosticsSignError linehl= numhl= +sign define LspDiagnosticsSignWarning text=\! texthl=LspDiagnosticsSignWarning linehl= numhl= +sign define LspDiagnosticsSignInformation text=i texthl=LspDiagnosticsSignInformation linehl= numhl= +sign define LspDiagnosticsSignHint text=\~ texthl=LspDiagnosticsSignHint linehl= numhl= + +lua << EOF +require 'lsp' +require 'treesitter' +EOF diff --git a/lua/lsp.lua b/lua/lsp.lua new file mode 100644 index 0000000..f921c70 --- /dev/null +++ b/lua/lsp.lua @@ -0,0 +1,59 @@ +local nvim_lsp = require('lspconfig') +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 + + buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings. + local opts = { noremap=true, silent=true } + buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) + buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) + buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) + buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) + buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) + buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) + buf_set_keymap('n', 'e', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) + buf_set_keymap('n', '[g', 'lua vim.lsp.diagnostic.goto_prev()', opts) + buf_set_keymap('n', ']g', 'lua vim.lsp.diagnostic.goto_next()', opts) + buf_set_keymap('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) + + -- Set some keybinds conditional on server capabilities + if client.resolved_capabilities.document_formatting then + buf_set_keymap("n", "f", "lua vim.lsp.buf.formatting()", opts) + elseif client.resolved_capabilities.document_range_formatting then + buf_set_keymap("n", "f", "lua vim.lsp.buf.range_formatting()", opts) + end +end + +local servers = { "hls", "rnix", "bashls", "pyls" } +for _, lsp in ipairs(servers) do + nvim_lsp[lsp].setup { on_attach = on_attach } +end + +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities.textDocument.completion.completionItem.snippetSupport = true + +nvim_lsp.rust_analyzer.setup { + capabilities = capabilities, + settings = { + ["rust-analyzer"] = { + procMacro = { + enable = true + }, + }, + }, +} + +nvim_lsp.ccls.setup { + init_options = { + index = { + threads = 0; + }; + clang = { + excludeArgs = { "-frounding-math"} ; + }; + } +} diff --git a/lua/treesitter.lua b/lua/treesitter.lua new file mode 100644 index 0000000..d503b46 --- /dev/null +++ b/lua/treesitter.lua @@ -0,0 +1,18 @@ +require'nvim-treesitter.configs'.setup { + highlight = { + enable = true, + + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "gnn", + node_incremental = "g}", + scope_incremental = "grc", + node_decremental = "g{", + }, + }, + indent = { + enable = false + } +} diff --git a/plugin/help.vim b/plugin/help.vim new file mode 100644 index 0000000..9e1c998 --- /dev/null +++ b/plugin/help.vim @@ -0,0 +1,16 @@ +" Only apply to .txt files... +augroup HelpInTabs + autocmd! + autocmd BufEnter *.txt call HelpInNewTab() +augroup END + +" Only apply to help files... +function! HelpInNewTab () + if &buftype == 'help' && g:help_in_tabs + "Convert the help window to a tab... + execute "normal \T" + endif +endfunction + +let g:help_in_tabs = 1 + diff --git a/plugin/ignores.vim b/plugin/ignores.vim new file mode 100644 index 0000000..3ab37f0 --- /dev/null +++ b/plugin/ignores.vim @@ -0,0 +1,11 @@ +set wildignore+=.git,.hg,.svn +set wildignore+=*.aux,*.out,*.toc +set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest,*.rbc,*.class +set wildignore+=*.ai,*.bmp,*.gif,*.ico,*.jpg,*.jpeg,*.png,*.psd,*.webp +set wildignore+=*.avi,*.divx,*.mp4,*.webm,*.mov,*.m2ts,*.mkv,*.vob,*.mpg,*.mpeg +set wildignore+=*.mp3,*.oga,*.ogg,*.wav,*.flac +set wildignore+=*.eot,*.otf,*.ttf,*.woff +set wildignore+=*.doc,*.pdf,*.cbr,*.cbz +set wildignore+=*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz,*.kgb +set wildignore+=*.swp,.lock,.DS_Store,._* + diff --git a/plugin/maps.vim b/plugin/maps.vim new file mode 100644 index 0000000..188cb69 --- /dev/null +++ b/plugin/maps.vim @@ -0,0 +1,46 @@ +mapclear + +let mapleader=' ' + +" clipboard +map cc :w !xclip -sel c + +" normal +nnoremap o : only +" nnoremap l : Lines +nnoremap b : Buffers +nnoremap n : bnext +nnoremap p : bprev +nnoremap z : FZF +nnoremap l : Lines +nnoremap w : MtaJumpToOtherTag +nnoremap t : call GetTabber() +nnoremap : nohlsearch +nnoremap :nohlsearch:diffupdate:syntax sync fromstart +nnoremap H H:exec 'norm! '. &scrolloff . 'k' +nnoremap L L:exec 'norm! '. &scrolloff . 'j' +nnoremap gb '`[' . strpart(getregtype(), 0, 1) . '`]' + + +nnoremap :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' + \ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" + \ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">" + +cmap w!! %!sudo -S tee > /dev/null % + +" visual +vnoremap > >gv +vnoremap < +xnoremap - g + +" completions +inoremap compe#complete() +inoremap compe#confirm('') +inoremap compe#close('') diff --git a/plugin/statusline.vim b/plugin/statusline.vim new file mode 100644 index 0000000..5465d40 --- /dev/null +++ b/plugin/statusline.vim @@ -0,0 +1,139 @@ +scriptencoding utf-8 + +" statusline + +let g:currentmode={ + \ 'n' : 'NORMAL ', + \ 'no' : 'N·OPERATOR PENDING ', + \ 'v' : 'VISUAL ', + \ 'V' : 'V·LINE ', + \ '' : 'V·BLOCK ', + \ 's' : 'SELECT ', + \ 'S' : 'S·LINE ', + \ '' : 'S·BLOCK ', + \ 'i' : 'INSERT ', + \ 'R' : 'REPLACE ', + \ 'Rv' : 'V·REPLACE ', + \ 'c' : 'COMMAND ', + \ 'cv' : 'VIM EX ', + \ 'ce' : 'EX ', + \ 'r' : 'PROMPT ', + \ 'rm' : 'MORE ', + \ 'r?' : 'CONFIRM ', + \ '!' : 'SHELL ', + \ 't' : 'TERMINAL '} + +hi PrimaryBlock ctermfg=00 ctermbg=6 +hi SecondaryBlock ctermfg=07 ctermbg=10 +hi Blanks ctermfg=08 ctermbg=0 + +hi User1 ctermfg=01 ctermbg=0 +hi User2 ctermfg=02 ctermbg=0 +hi User3 ctermfg=03 ctermbg=0 +hi User4 ctermfg=12 ctermbg=0 +hi User5 ctermfg=05 ctermbg=0 +hi User6 ctermfg=06 ctermbg=0 +hi User7 ctermfg=07 ctermbg=0 +hi User8 ctermfg=08 ctermbg=0 +hi User9 ctermfg=00 ctermbg=0 + +highlight EndOfBuffer ctermfg=black ctermbg=black + +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! ReadOnly() abort + if !&modifiable && &readonly + return ' RO' + elseif &modifiable && &readonly + return 'RO' + elseif !&modifiable && !&readonly + return '' + else + return '' + endif +endfunction + +function! Filepath() abort + let l:basename = expand('%:h') + let l:filename = expand('%:t') + let l:extension = expand('%:e') + let l:prefix = (l:basename ==# '' || l:basename ==# '.') ? + \ '' : substitute(l:basename . '/', '\C^' . $HOME, '~', '') + + if empty(l:prefix) && empty(l:filename) + return printf('%%4*%%f%%*%s %%m%%*', '%4*') + elseif empty(l:prefix) + return printf('%%4*%%f%%*%s %%m%%*', '%6*') + else + return printf('%%4*%s%%*%s%s%%*', l:prefix, &modified ? '%6*' : '%4*', l:filename) + endif +endfunction + +function! LinterStatus() abort + let sl = '' + let msgs = [] + if luaeval('not vim.tbl_isempty(vim.lsp.buf_get_clients(0))') + let errs = luaeval("vim.lsp.diagnostic.get_count(0, [[Error]])") + let warns = luaeval("vim.lsp.diagnostic.get_count(0, [[Warning]])") + if errs != 0 + call add(msgs, printf('%%5*%s×%%* ', errs)) + endif + if warns != 0 + call add(msgs, printf('%%3*%s!%%* ', warns)) + endif + return join(msgs, '') + else + return '' + endif +endfunction + +function! StatusLine(mode) abort + let l:line='' + + " help or man pages + if &filetype ==# 'help' || &filetype ==# 'man' + let l:line.=' %#StatusLineNC# ['. &filetype .'] %f ' + return l:line + endif + + " active + if a:mode ==# 'active' + let l:line.='%6*·%*' . ' ' + let l:line.='%7*%{StatuslineGit()}' + let l:line.='%<' + let l:line.=Filepath() + + let l:line.='%5*' + let l:line.=' %{ReadOnly()} %w%*' + let l:line.='%9* %=%*' + + let l:line.=' ' . '%7*%l,%c%*' . ' ' + let l:line.=LinterStatus() + let l:line.='%4*'. &filetype + + else + " inactive + let l:line.='%5*·%*' . ' ' + let l:line.='%#Blanks#' + let l:line.='%f %5*%m%*' + let l:line.='%#Blanks# %=%*' + endif + + let l:line.='%*' + + return l:line +endfunction + +set statusline=%!StatusLine('active') +augroup MyStatusLine + autocmd! + autocmd WinEnter * setl statusline=%!StatusLine('active') + autocmd WinLeave * setl statusline=%!StatusLine('inactive') +augroup END diff --git a/syntax/kotlin.vim b/syntax/kotlin.vim new file mode 100644 index 0000000..48fc6ce --- /dev/null +++ b/syntax/kotlin.vim @@ -0,0 +1,139 @@ +" Vim syntax file +" Language: Kotlin +" Maintainer: Alexander Udalov +" Latest Revision: 13 July 2020 + +if exists('b:current_syntax') + finish +endif + +syn keyword ktStatement break continue return +syn keyword ktConditional if else when +syn keyword ktRepeat do for while +syn keyword ktOperator in is by +syn keyword ktKeyword get set out super this where +syn keyword ktException try catch finally throw + +syn keyword ktInclude import package + +" The following is generated by generate-stdlib-class-names.main.kts +syn keyword ktType AbstractCollection AbstractCoroutineContextElement AbstractCoroutineContextKey AbstractDoubleTimeSource AbstractIterator AbstractList AbstractLongTimeSource +syn keyword ktType AbstractMap AbstractMutableCollection AbstractMutableList AbstractMutableMap AbstractMutableSet AbstractSet AccessDeniedException Accessor Annotation +syn keyword ktType AnnotationRetention AnnotationTarget Any Appendable ArithmeticException Array ArrayDeque ArrayList AssertionError Boolean BooleanArray BooleanIterator +syn keyword ktType BuilderInference Byte ByteArray ByteIterator CallsInPlace CancellationException Char CharArray CharCategory CharDirectionality CharIterator CharProgression +syn keyword ktType CharRange CharSequence CharacterCodingException Charsets ClassCastException Cloneable ClosedFloatingPointRange ClosedRange Collection Comparable Comparator +syn keyword ktType ConcurrentModificationException ConditionalEffect Continuation ContinuationInterceptor ContractBuilder CoroutineContext DeepRecursiveFunction DeepRecursiveScope +syn keyword ktType Delegates Deprecated DeprecatedSinceKotlin DeprecationLevel Destructured Double DoubleArray DoubleIterator DslMarker Duration DurationUnit Effect Element +syn keyword ktType EmptyCoroutineContext Entry Enum Error Exception Experimental ExperimentalContracts ExperimentalJsExport ExperimentalMultiplatform ExperimentalStdlibApi +syn keyword ktType ExperimentalTime ExperimentalTypeInference ExperimentalUnsignedTypes ExtensionFunctionType FileAlreadyExistsException FileSystemException FileTreeWalk +syn keyword ktType FileWalkDirection Float FloatArray FloatIterator Function Function0 Function1 Function10 Function11 Function12 Function13 Function14 Function15 Function16 +syn keyword ktType Function17 Function18 Function19 Function2 Function20 Function21 Function22 Function3 Function4 Function5 Function6 Function7 Function8 Function9 FunctionN +syn keyword ktType Getter Grouping HashMap HashSet IllegalArgumentException IllegalStateException IndexOutOfBoundsException IndexedValue Int IntArray IntIterator IntProgression +syn keyword ktType IntRange InvocationKind Iterable Iterator JsExport JsName JvmDefault JvmDefaultWithoutCompatibility JvmField JvmMultifileClass JvmName JvmOverloads JvmStatic +syn keyword ktType JvmSuppressWildcards JvmSynthetic JvmWildcard KAnnotatedElement KCallable KClass KClassifier KDeclarationContainer KFunction KMutableProperty KMutableProperty0 +syn keyword ktType KMutableProperty1 KMutableProperty2 KParameter KProperty KProperty0 KProperty1 KProperty2 KType KTypeParameter KTypeProjection KVariance KVisibility Key Kind +syn keyword ktType KotlinNullPointerException KotlinReflectionNotSupportedError KotlinVersion Lazy LazyThreadSafetyMode Level LinkedHashMap LinkedHashSet List ListIterator Long +syn keyword ktType LongArray LongIterator LongProgression LongRange Map MatchGroup MatchGroupCollection MatchNamedGroupCollection MatchResult Metadata Monotonic MustBeDocumented +syn keyword ktType MutableCollection MutableEntry MutableIterable MutableIterator MutableList MutableListIterator MutableMap MutableSet NoSuchElementException NoSuchFileException +syn keyword ktType NoWhenBranchMatchedException NotImplementedError Nothing NullPointerException Number NumberFormatException ObservableProperty OnErrorAction OptIn +syn keyword ktType OptionalExpectation OverloadResolutionByLambdaReturnType Pair ParameterName PropertyDelegateProvider PublishedApi PurelyImplements Random RandomAccess +syn keyword ktType ReadOnlyProperty ReadWriteProperty Regex RegexOption Repeatable ReplaceWith RequiresOptIn RestrictsSuspension Result Retention Returns ReturnsNotNull +syn keyword ktType RuntimeException Sequence SequenceScope Set Setter SharedImmutable Short ShortArray ShortIterator SimpleEffect SinceKotlin Strictfp String StringBuilder Suppress +syn keyword ktType Synchronized Target TestTimeSource ThreadLocal Throwable Throws TimeMark TimeSource TimedValue Transient Triple TypeCastException Typography UByte UByteArray +syn keyword ktType UByteIterator UInt UIntArray UIntIterator UIntProgression UIntRange ULong ULongArray ULongIterator ULongProgression ULongRange UShort UShortArray UShortIterator +syn keyword ktType UninitializedPropertyAccessException Unit UnsafeVariance UnsupportedOperationException UseExperimental Volatile + +syn keyword ktModifier annotation companion enum inner internal private protected public abstract final open override sealed vararg dynamic expect actual +syn keyword ktStructure class object interface typealias fun val var constructor init + +syn keyword ktReservedKeyword typeof + +syn keyword ktBoolean true false +syn keyword ktConstant null + +syn keyword ktModifier data tailrec lateinit reified external inline noinline crossinline const operator infix suspend + +syn match ktOperator "\v\?:|::|\<\=? | \>\=?|[!=]\=\=?|\??|[-!%&*+/|]" + +syn keyword ktTodo TODO FIXME XXX contained +syn match ktShebang "\v^#!.*$" +syn match ktLineComment "\v//.*$" contains=ktTodo,@Spell +syn region ktComment matchgroup=ktCommentMatchGroup start="/\*" end="\*/" contains=ktComment,ktTodo,@Spell + +syn region ktDocComment start="/\*\*" end="\*/" contains=ktDocTag,ktTodo,@Spell +syn match ktDocTag "\v\@(author|constructor|receiver|return|since|suppress)>" contained +syn match ktDocTag "\v\@(exception|param|property|throws|see|sample)>\s*\S+" contains=ktDocTagParam contained +syn match ktDocTagParam "\v(\s|\[)\S+" contained +syn match ktComment "/\*\*/" + +syn match ktSpecialCharError "\v\\." contained +syn match ktSpecialChar "\v\\([tbnr'"$\\]|u\x{4})" contained +syn region ktString start='"' skip='\\"' end='"' contains=ktSimpleInterpolation,ktComplexInterpolation,ktSpecialChar,ktSpecialCharError +syn region ktString start='"""' end='""""*' contains=ktSimpleInterpolation,ktComplexInterpolation +syn match ktCharacter "\v'[^']*'" contains=ktSpecialChar,ktSpecialCharError +syn match ktCharacter "\v'\\''" contains=ktSpecialChar +syn match ktCharacter "\v'[^\\]'" + +" TODO: highlight label in 'this@Foo' +syn match ktAnnotation "\v(\w)@" + +hi def link ktStatement Statement +hi def link ktConditional Conditional +hi def link ktRepeat Repeat +hi def link ktOperator Operator +hi def link ktKeyword Keyword +hi def link ktException Exception +hi def link ktReservedKeyword Error + +hi def link ktInclude Include + +hi def link ktType Type +hi def link ktModifier StorageClass +hi def link ktStructure Structure +hi def link ktTypedef Typedef + +hi def link ktBoolean Boolean +hi def link ktConstant Constant + +hi def link ktTodo Todo +hi def link ktShebang Comment +hi def link ktLineComment Comment +hi def link ktComment Comment +hi def link ktCommentMatchGroup Comment +hi def link ktDocComment Comment +hi def link ktDocTag Special +hi def link ktDocTagParam Identifier + +hi def link ktSpecialChar SpecialChar +hi def link ktSpecialCharError Error +hi def link ktString String +hi def link ktCharacter Character + +hi def link ktAnnotation Identifier +hi def link ktLabel Identifier + +hi def link ktSimpleInterpolation Identifier +hi def link ktComplexInterpolationBrace Identifier + +hi def link ktNumber Number +hi def link ktFloat Float + +hi def link ktExclExcl Special +hi def link ktArrow Structure + +let b:current_syntax = 'kotlin' + diff --git a/syntax/proto.vim b/syntax/proto.vim new file mode 100644 index 0000000..8545631 --- /dev/null +++ b/syntax/proto.vim @@ -0,0 +1,106 @@ +" Protocol Buffers - Google's data interchange format +" Copyright 2008 Google Inc. All rights reserved. +" https://developers.google.com/protocol-buffers/ +" +" Redistribution and use in source and binary forms, with or without +" modification, are permitted provided that the following conditions are +" met: +" +" * Redistributions of source code must retain the above copyright +" notice, this list of conditions and the following disclaimer. +" * Redistributions in binary form must reproduce the above +" copyright notice, this list of conditions and the following disclaimer +" in the documentation and/or other materials provided with the +" distribution. +" * Neither the name of Google Inc. nor the names of its +" contributors may be used to endorse or promote products derived from +" this software without specific prior written permission. +" +" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +" This is the Vim syntax file for Google Protocol Buffers. +" +" Usage: +" +" 1. cp proto.vim ~/.vim/syntax/ +" 2. Add the following to ~/.vimrc: +" +" augroup filetype +" au! BufRead,BufNewFile *.proto setfiletype proto +" augroup end +" +" Or just create a new file called ~/.vim/ftdetect/proto.vim with the +" previous lines on it. + +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +syn case match + +syn keyword pbTodo contained TODO FIXME XXX +syn cluster pbCommentGrp contains=pbTodo + +syn keyword pbSyntax syntax import option +syn keyword pbStructure package message group oneof +syn keyword pbRepeat optional required repeated +syn keyword pbDefault default +syn keyword pbExtend extend extensions to max reserved +syn keyword pbRPC service rpc returns + +syn keyword pbType int32 int64 uint32 uint64 sint32 sint64 +syn keyword pbType fixed32 fixed64 sfixed32 sfixed64 +syn keyword pbType float double bool string bytes +syn keyword pbTypedef enum +syn keyword pbBool true false + +syn match pbInt /-\?\<\d\+\>/ +syn match pbInt /\<0[xX]\x+\>/ +syn match pbFloat /\<-\?\d*\(\.\d*\)\?/ +syn region pbComment start="\/\*" end="\*\/" contains=@pbCommentGrp +syn region pbComment start="//" skip="\\$" end="$" keepend contains=@pbCommentGrp +syn region pbString start=/"/ skip=/\\./ end=/"/ +syn region pbString start=/'/ skip=/\\./ end=/'/ + +if version >= 508 || !exists("did_proto_syn_inits") + if version < 508 + let did_proto_syn_inits = 1 + command -nargs=+ HiLink hi link + else + command -nargs=+ HiLink hi def link + endif + + HiLink pbTodo Todo + + HiLink pbSyntax Include + HiLink pbStructure Structure + HiLink pbRepeat Repeat + HiLink pbDefault Keyword + HiLink pbExtend Keyword + HiLink pbRPC Keyword + HiLink pbType Type + HiLink pbTypedef Typedef + HiLink pbBool Boolean + + HiLink pbInt Number + HiLink pbFloat Float + HiLink pbComment Comment + HiLink pbString String + + delcommand HiLink +endif + +let b:current_syntax = "proto" + -- cgit v1.2.3