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