From: Sergey Matveev Date: Thu, 30 Jun 2022 16:02:28 +0000 (+0300) Subject: Move to vim9script X-Git-Url: http://www.git.stargrave.org/?p=dotfiles.git;a=commitdiff_plain;h=9cbfa59ca421fac5422cbf0c2c52f48f8f2adb4c Move to vim9script --- diff --git a/vim/.vim/after/ftplugin/c/autos.vim b/vim/.vim/after/ftplugin/c/autos.vim new file mode 100644 index 0000000..96369aa --- /dev/null +++ b/vim/.vim/after/ftplugin/c/autos.vim @@ -0,0 +1 @@ +set commentstring=//\ %s diff --git a/vim/.vim/autoload/go/jump.vim b/vim/.vim/autoload/go/jump.vim new file mode 100644 index 0000000..90c00d8 --- /dev/null +++ b/vim/.vim/autoload/go/jump.vim @@ -0,0 +1,9 @@ +vim9script + +export def Do(motion: string) + var saved = @/ + mark ' + execute motion + call histdel("/", -1) + @/ = saved +enddef diff --git a/vim/.vim/autoload/mutt.vim b/vim/.vim/autoload/mutt.vim new file mode 100644 index 0000000..367c6d7 --- /dev/null +++ b/vim/.vim/autoload/mutt.vim @@ -0,0 +1,9 @@ +vim9script + +export def KillSignature() + cursor(1, 1) + search('^[>|] \?-- \?$') + if getpos(".")[1] != 1 + normal d} + endif +enddef diff --git a/vim/.vim/ftdetect/hjson.vim b/vim/.vim/ftdetect/hjson.vim index 8181fc2..65ed946 100644 --- a/vim/.vim/ftdetect/hjson.vim +++ b/vim/.vim/ftdetect/hjson.vim @@ -1,2 +1 @@ -autocmd BufNewFile,BufRead *.hjson setlocal shiftwidth=2 -autocmd BufNewFile,BufRead *.hjson setlocal commentstring=#\ %s +autocmd BufNewFile,BufRead *.hjson set filetype=hjson diff --git a/vim/.vim/ftdetect/mutt.vim b/vim/.vim/ftdetect/mutt.vim index e706174..4e4dc75 100644 --- a/vim/.vim/ftdetect/mutt.vim +++ b/vim/.vim/ftdetect/mutt.vim @@ -1,12 +1 @@ -function! s:KillSignature() abort - call cursor(1, 1) - call search('^[>|] \?-- \?$') - if getpos(".")[1] != 1 - normal d} - endif -endfunction - -autocmd BufRead /tmp/mutt-* call s:KillSignature() -autocmd BufRead /tmp/mutt-* setlocal textwidth=72 -autocmd BufRead /tmp/mutt-* setlocal commentstring=>%s -autocmd BufRead /tmp/mutt-* silent %substitute /^> */>/e | set nohlsearch +autocmd BufRead,BufNewFile /tmp/mutt-* set filetype=mutt diff --git a/vim/.vim/ftdetect/tex.vim b/vim/.vim/ftdetect/tex.vim deleted file mode 100644 index 19517da..0000000 --- a/vim/.vim/ftdetect/tex.vim +++ /dev/null @@ -1,3 +0,0 @@ -autocmd BufNewFile,BufRead *.tex abbreviate framedo \begin{frame}\frametitle{TODO}\end{frame}k>>wwlcw -autocmd BufNewFile,BufRead *.tex abbreviate itemdo \begin{itemize}\item \end{itemize}k>>$a -autocmd BufNewFile,BufRead *.tex abbreviate cnter \begin{center}\end{center}k$o diff --git a/vim/.vim/ftplugin/c/autos.vim b/vim/.vim/ftplugin/c/autos.vim index 5b93526..6a804db 100644 --- a/vim/.vim/ftplugin/c/autos.vim +++ b/vim/.vim/ftplugin/c/autos.vim @@ -1,4 +1,3 @@ -set commentstring=//\ %s let @e = "ywoassert(pA!= NULL);" nmap [cl O// clang-format off nmap ]cl o// clang-format on diff --git a/vim/.vim/ftplugin/go/motion.vim b/vim/.vim/ftplugin/go/motion.vim index 041347c..410ce9a 100644 --- a/vim/.vim/ftplugin/go/motion.vim +++ b/vim/.vim/ftplugin/go/motion.vim @@ -1,18 +1,6 @@ -nnoremap ]] :call Go_jump('/^\(func\\|type\)') -nnoremap [[ :call Go_jump('?^\(func\\|type\)') -nnoremap ]m :call Go_jump('/^\s*\(func\\|type\)') -nnoremap [m :call Go_jump('?^\s*\(func\\|type\)') - -if exists('*Go_jump') | finish | endif - -fun! Go_jump(motion) range - let cnt = v:count1 - let save = @/ " save last search pattern - mark ' - while cnt > 0 - silent! exe a:motion - let cnt = cnt - 1 - endwhile - call histdel('/', -1) - let @/ = save " restore last search pattern -endfun +vim9script +if exists("*go#jump#Do") | finish | endif +nnoremap ]] :call go#jump#Do(':/^\(func\\|type\)') +nnoremap [[ :call go#jump#Do(':?^\(func\\|type\)') +nnoremap ]m :call go#jump#Do(':/^\s*\(func\\|type\)') +nnoremap [m :call go#jump#Do(':?^\s*\(func\\|type\)') diff --git a/vim/.vim/ftplugin/hjson/autos.vim b/vim/.vim/ftplugin/hjson/autos.vim new file mode 100644 index 0000000..069cc1c --- /dev/null +++ b/vim/.vim/ftplugin/hjson/autos.vim @@ -0,0 +1,2 @@ +set shiftwidth=2 +set commentstring=#\ %s diff --git a/vim/.vim/ftplugin/mutt/autos.vim b/vim/.vim/ftplugin/mutt/autos.vim new file mode 100644 index 0000000..7708164 --- /dev/null +++ b/vim/.vim/ftplugin/mutt/autos.vim @@ -0,0 +1,6 @@ +vim9script +mutt#KillSignature() +set textwidth=72 +set commentstring=>%s +set syntax=mail +silent :%substitute /^> */>/e | set nohlsearch diff --git a/vim/.vim/ftplugin/plaintex/autos.vim b/vim/.vim/ftplugin/plaintex/autos.vim new file mode 100644 index 0000000..42d80e6 --- /dev/null +++ b/vim/.vim/ftplugin/plaintex/autos.vim @@ -0,0 +1,3 @@ +abbreviate framedo \begin{frame}\frametitle{TODO}\end{frame}k>>wwlcw +abbreviate itemdo \begin{itemize}\item \end{itemize}k>>$a +abbreviate cnter \begin{center}\end{center}k$o diff --git a/vim/.vim/ftplugin/python/autos.vim b/vim/.vim/ftplugin/python/autos.vim index e956d2b..916b503 100644 --- a/vim/.vim/ftplugin/python/autos.vim +++ b/vim/.vim/ftplugin/python/autos.vim @@ -7,6 +7,4 @@ iabbrev kargs *args, **kwargs iabbrev pyldis # pylint: disable= iabbrev deff def () -> None:F(i nmap ss :set lazyredrawvip:sort u:'<,'>sort i:set nolazyredraw -let @b = ">gvctry:<>k>>kP" -let @n = "ddV/except.*: v9 vim9script diff --git a/vim/.vim/pack/stargrave/start/align/autoload/align.vim b/vim/.vim/pack/stargrave/start/align/autoload/align.vim index f08ae81..d31e1a1 100644 --- a/vim/.vim/pack/stargrave/start/align/autoload/align.vim +++ b/vim/.vim/pack/stargrave/start/align/autoload/align.vim @@ -1,13 +1,14 @@ -" something that won't be met anywhere -let s:sep = "₀◎○ë" +vim9script -function! align#do(first, last, sep) abort - let in = [] - for n in range(a:first, a:last) - let in = add(in, substitute(getline(n), a:sep, "\t" . s:sep, "g")) +const Sep = "₀◎○ë" # something that won't be met anywhere + +export def Do(first: number, last: number, sep: string) + var in: list + for n in range(first, last) + in = add(in, substitute(getline(n), sep, "\t" .. Sep, "g")) endfor - let out = systemlist("column -t -s \"\t\"", add(in, "")) - for n in range(a:first, a:last) - call setline(n, substitute(out[n - a:first], " " . s:sep, escape(a:sep, "&"), "g")) + var out = systemlist("column -t -s \"\t\"", add(in, "")) + for n in range(first, last) + setline(n, substitute(out[n - first], " " .. Sep, escape(sep, "&"), "g")) endfor -endfunction +enddef diff --git a/vim/.vim/pack/stargrave/start/align/plugin/align.vim b/vim/.vim/pack/stargrave/start/align/plugin/align.vim index 5d95b11..82d5370 100644 --- a/vim/.vim/pack/stargrave/start/align/plugin/align.vim +++ b/vim/.vim/pack/stargrave/start/align/plugin/align.vim @@ -1,2 +1,2 @@ -if exists("*align#do") | finish | endif -command! -nargs=1 -range Align call align#do(, , ) +if exists("*align#Do") | finish | endif +command! -nargs=1 -range Align call align#Do(, , ) diff --git a/vim/.vim/pack/stargrave/start/buftabline/autoload/buftabline.vim b/vim/.vim/pack/stargrave/start/buftabline/autoload/buftabline.vim index 7098d7b..d4c6efc 100644 --- a/vim/.vim/pack/stargrave/start/buftabline/autoload/buftabline.vim +++ b/vim/.vim/pack/stargrave/start/buftabline/autoload/buftabline.vim @@ -1,18 +1,27 @@ -function! buftabline#do() - let bufsRaw = execute("buffers", "silent") - let bufs = [] - for buf in split(bufsRaw, "\n")[:16] - let leftIdx = stridx(buf, '"') - let rightIdx = strridx(buf, '"') - let filename = substitute(buf[leftIdx + 1 : rightIdx - 1], "%", "%%", "g") - let linenum = split(buf[rightIdx:], " ")[-1] - let attrs = split(buf[:leftIdx-1], '\s\+') - let attrs = map(attrs, 'substitute(v:val, "%", "%%", "g")') - let attrs = (len(attrs) == 1) ? attrs[0] : attrs[0] . ":" . join(attrs[1:], "") - let attrs = "%#TabLine#" . attrs . "%*" - if len(filename) > 20 | let filename = "<" . filename[-(20-1):] | endif - let hl = (match(attrs, "%%") == -1) ? "%#TabLine#:" : "%#TabLineSel#" - let bufs = add(bufs, attrs . hl . filename . ":" . linenum . "%*") +vim9script + +export def Do(): string + var bufsRaw = execute("buffers", "silent") + var bufs: list + var leftIdx: number + var rightIdx: number + var filename: string + var linenum: string + var attrs: list + var attr: string + var hl: string + for buf in split(bufsRaw, "\n")[ : 16] + leftIdx = stridx(buf, '"') + rightIdx = strridx(buf, '"') + filename = substitute(buf[leftIdx + 1 : rightIdx - 1], "%", "%%", "g") + linenum = split(buf[rightIdx : ], " ")[-1] + attrs = split(buf[ : leftIdx - 1], '\s\+') + attrs = map(attrs, 'substitute(v:val, "%", "%%", "g")') + attr = (len(attrs) == 1) ? attrs[0] : attrs[0] .. ":" .. join(attrs[1 :], "") + attr = "%#TabLine#" .. attr .. "%*" + if len(filename) > 20 | filename = "<" .. filename[-(20 - 1) :] | endif + hl = (match(attr, "%%") == -1) ? "%#TabLine#:" : "%#TabLineSel#" + bufs = add(bufs, attr .. hl .. filename .. ":" .. linenum .. "%*") endfor return join(bufs, " ") -endfunction +enddef diff --git a/vim/.vim/pack/stargrave/start/buftabline/plugin/buftabline.vim b/vim/.vim/pack/stargrave/start/buftabline/plugin/buftabline.vim index 60c067b..99c444e 100644 --- a/vim/.vim/pack/stargrave/start/buftabline/plugin/buftabline.vim +++ b/vim/.vim/pack/stargrave/start/buftabline/plugin/buftabline.vim @@ -1,3 +1,3 @@ -if exists("*buftabline#do") | finish | endif +if exists("*buftabline#Do") | finish | endif set showtabline=2 -set tabline=%!buftabline#do() +set tabline=%!buftabline#Do() diff --git a/vim/.vim/pack/stargrave/start/chnglstnav/autoload/chnglstnav.vim b/vim/.vim/pack/stargrave/start/chnglstnav/autoload/chnglstnav.vim index 9bdf840..cfd5ab6 100644 --- a/vim/.vim/pack/stargrave/start/chnglstnav/autoload/chnglstnav.vim +++ b/vim/.vim/pack/stargrave/start/chnglstnav/autoload/chnglstnav.vim @@ -1,4 +1,6 @@ -function! chnglstnav#do(...) - if a:0 == 0 | return | endif - execute "normal " . a:1 . (a:1 > 0 ? "g;" : "g,") -endfunction +vim9script + +export def Do(...args: list) + if len(args) == 0 | return | endif + execute "normal " .. args[0] .. (args[0] > 0 ? "g;" : "g,") +enddef diff --git a/vim/.vim/pack/stargrave/start/chnglstnav/plugin/chnglstnav.vim b/vim/.vim/pack/stargrave/start/chnglstnav/plugin/chnglstnav.vim index 699fdd0..01ef650 100644 --- a/vim/.vim/pack/stargrave/start/chnglstnav/plugin/chnglstnav.vim +++ b/vim/.vim/pack/stargrave/start/chnglstnav/plugin/chnglstnav.vim @@ -1,2 +1,2 @@ -if exists("*chnglstnav#do") | finish | endif -nmap :changes:call chnglstnav#do() +if exists("*chnglstnav#Do") | finish | endif +nmap :changes:call chnglstnav#Do() diff --git a/vim/.vim/pack/stargrave/start/ctags/autoload/ctags.vim b/vim/.vim/pack/stargrave/start/ctags/autoload/ctags.vim index dc6f90e..0119014 100644 --- a/vim/.vim/pack/stargrave/start/ctags/autoload/ctags.vim +++ b/vim/.vim/pack/stargrave/start/ctags/autoload/ctags.vim @@ -1,35 +1,37 @@ -" Universal Ctags creator -" Maintainer: Sergey Matveev -" License: GNU General Public License version 3 of the License or later -" -" Create "tags" file in your project's root first. -" Then :Ctags LANG to fill it. +vim9script -function! ctags#do(lang, onlyCmd, verbose) abort - let dst = tagfiles() - if len(dst) == 0 +# Universal Ctags creator +# Maintainer: Sergey Matveev +# License: GNU General Public License version 3 of the License or later +# +# Create "tags" file in your project's root first. +# Then :Ctags LANG to fill it. + +export def Do(lang: string, onlyCmd: bool, verbose: bool) + var dsts = tagfiles() + if len(dsts) == 0 echohl WarningMsg | echomsg "No tagfiles" | echohl None return endif - let dst = sort(dst, {a, b -> len(a) > len(b) ? 1 : len(a) == len(b) ? 0 : -1})[0] - let src = "/" . join(split(dst, "/")[:-3], "/") + var dst = sort(dsts, (a, b) => len(a) > len(b) ? 1 : len(a) == len(b) ? 0 : -1)[0] + var src = "/" .. join(split(dst, "/")[: -3], "/") if dst[0] != "/" - let dst = getcwd() . "/.tags/tags" - let src = getcwd() + dst = getcwd() .. "/.tags/tags" + src = getcwd() endif - let cmdline = [ - \"uctags", - \"--languages=" . a:lang, - \"--python-kinds=-i", - \"--c++-kinds=+p", - \"--recurse", - \] - if a:verbose == v:true | let cmdline += ["--verbose"] | endif - let cmdline += ["-f", dst, src] - if a:onlyCmd == v:true + var cmdline = [ + "uctags", + "--languages=" .. lang, + "--python-kinds=-i", + "--c++-kinds=+p", + "--recurse", + ] + if verbose == v:true | cmdline += ["--verbose"] | endif + cmdline += ["-f", dst, src] + if onlyCmd == v:true echo join(cmdline, " ") return endif - execute "!" . join(cmdline, " ") - if a:verbose != v:true | redraw! | endif -endfunction + execute "!" .. join(cmdline, " ") + if verbose != v:true | redraw! | endif +enddef diff --git a/vim/.vim/pack/stargrave/start/ctags/plugin/ctags.vim b/vim/.vim/pack/stargrave/start/ctags/plugin/ctags.vim index 644e50a..0f63d9e 100644 --- a/vim/.vim/pack/stargrave/start/ctags/plugin/ctags.vim +++ b/vim/.vim/pack/stargrave/start/ctags/plugin/ctags.vim @@ -1,4 +1,4 @@ -if exists("*ctags#do") | finish | endif -command! -nargs=1 Ctags silent call ctags#do(, v:false, v:false) -command! -nargs=1 Ctagsv silent call ctags#do(, v:true, v:false) -command! -nargs=1 Ctagscmd call ctags#do(, v:true, v:true) +if exists("*ctags#Do") | finish | endif +command! -nargs=1 Ctags silent call ctags#Do(, v:false, v:false) +command! -nargs=1 Ctagsv silent call ctags#Do(, v:true, v:false) +command! -nargs=1 Ctagscmd call ctags#Do(, v:true, v:true) diff --git a/vim/.vim/pack/stargrave/start/defsplit/autoload/defsplit.vim b/vim/.vim/pack/stargrave/start/defsplit/autoload/defsplit.vim index a159007..74337e8 100644 --- a/vim/.vim/pack/stargrave/start/defsplit/autoload/defsplit.vim +++ b/vim/.vim/pack/stargrave/start/defsplit/autoload/defsplit.vim @@ -1,92 +1,97 @@ -" Python function call splitter -" Maintainer: Sergey Matveev -" License: GNU General Public License version 3 of the License or later -" -" This plugin splits Python function call on several lines. -" -" def foobar(self, foo: str, bar: Some[thing, too]) -> None: -" to -" def foobar( -" self, -" foo: str, -" bar: Some[thing, too], -" ) -> None: -" -" foo(bar, baz)[0] -" to -" foo( -" bar, -" baz, -" )[0] -" -" You can un-split it using :Undefsplit command on the line where -" splitting starts. -" -" :Defsplit has optional argument specifying how many opening round -" parenthesis must be skipped. -" :Defsplit 1 on foo(baz(baz(...))) produces -" foo(baz( -" baz(...), -" )) -" -" Also there is :Brsplit command behaving similarly, but it splits other -" types of brackets: "{}", "[]". +vim9script -function! s:bracket_find(brs_allowable, line, offset) - let possible = [] - for bracket in a:brs_allowable - let found = stridx(a:line, bracket, a:offset) - if found != -1 | let possible += [found] | endif +# Python function call splitter +# Maintainer: Sergey Matveev +# License: GNU General Public License version 3 of the License or later +# +# This plugin splits Python function call on several lines. +# +# def foobar(self, foo: str, bar: Some[thing, too]) -> None: +# to +# def foobar( +# self, +# foo: str, +# bar: Some[thing, too], +# ) -> None: +# +# foo(bar, baz)[0] +# to +# foo( +# bar, +# baz, +# )[0] +# +# You can un-split it using :Undefsplit command on the line where +# splitting starts. +# +# :Defsplit has optional argument specifying how many opening round +# parenthesis must be skipped. +# :Defsplit 1 on foo(baz(baz(...))) produces +# foo(baz( +# baz(...), +# )) +# +# Also there is :Brsplit command behaving similarly, but it splits other +# types of brackets: "{}", "[]". + +def BracketFind(brsAllowable: list, line: string, offset: number): number + var possible: list + var found: number + for bracket in brsAllowable + found = stridx(line, bracket, offset) + if found != -1 | possible += [found] | endif endfor return min(possible) -endfunction +enddef + +const Brs = {"(": ")", "[": "]", "{": "}"} -function! defsplit#do(brs_allowable, single_line_comma, ...) abort - if a:0 == 0 | let skip = 0 | else | let skip = str2nr(a:1) | endif - let shift = get(b:, "defsplit_shift", " ") - let line = getline(".") +export def Do(brsAllowable: list, singleLineComma: bool, ...args: list) + var skip = len(args) == 0 ? 0 : args[1] + var shift = get(b:, "defsplit_shift", " ") + var line = getline(".") + var prfx: string for i in range(len(line)) if line[i] != shift[0] - let prfx = strpart(line, 0, i) - if line[i : i+3] ==# "def " || - \line[i : i+5] ==# "class " || - \line[i : i+9] ==# "async def " - let shift .= shift + prfx = strpart(line, 0, i) + if line[i : i + 3] ==# "def " || + line[i : i + 5] ==# "class " || + line[i : i + 9] ==# "async def " + shift ..= shift endif break endif endfor - let brs = {"(": ")", "[": "]", "{": "}"} - let brfirst = s:bracket_find(a:brs_allowable, line, 0) - let brlast = strridx(line, brs[line[brfirst]]) + var brfirst = BracketFind(brsAllowable, line, 0) + var brlast = strridx(line, Brs[line[brfirst]]) while skip > 0 - let brfirst = s:bracket_find(a:brs_allowable, line, brfirst + 1) - let brlast = strridx(line, brs[line[brfirst]], brlast - 1) - let skip -= 1 + brfirst = BracketFind(brsAllowable, line, brfirst + 1) + brlast = strridx(line, Brs[line[brfirst]], brlast - 1) + skip -= 1 endwhile - let [curly, round, squar, outbuf] = [0, 0, 0, ""] - let ready = [strpart(line, 0, brfirst + 1)] - let trailing_comma = 1 - for c in split(line[brfirst + 1 : brlast-1], '\zs') - if c ==# "*" | let trailing_comma = 0 | endif + var [curly, round, squar, outbuf] = [0, 0, 0, ""] + var ready = [strpart(line, 0, brfirst + 1)] + var trailingComma = v:true + for c in split(line[brfirst + 1 : brlast - 1], '\zs') + if c ==# "*" | trailingComma = v:false | endif if outbuf ==# "" && c ==# " " | continue | endif - let outbuf .= c + outbuf ..= c if c ==# "," && !curly && !round && !squar - let ready = add(ready, prfx . shift . outbuf) - let outbuf = "" - elseif c ==# "[" | let squar += 1 - elseif c ==# "]" | let squar -= 1 - elseif c ==# "(" | let round += 1 - elseif c ==# ")" | let round -= 1 - elseif c ==# "{" | let curly += 1 - elseif c ==# "}" | let curly -= 1 + ready = add(ready, prfx .. shift .. outbuf) + outbuf = "" + elseif c ==# "[" | squar += 1 + elseif c ==# "]" | squar -= 1 + elseif c ==# "(" | round += 1 + elseif c ==# ")" | round -= 1 + elseif c ==# "{" | curly += 1 + elseif c ==# "}" | curly -= 1 endif endfor - if trailing_comma && !(a:single_line_comma == v:true && len(ready) == 1) - let outbuf = outbuf . "," + if trailingComma && !(singleLineComma == v:true && len(ready) == 1) + outbuf = outbuf .. "," endif - let ready = add(ready, prfx . shift . outbuf) - let ready = add(ready, prfx . strpart(line, brlast)) - call append(line("."), ready) + ready = add(ready, prfx .. shift .. outbuf) + ready = add(ready, prfx .. strpart(line, brlast)) + append(line("."), ready) normal "_dd -endfunction +enddef diff --git a/vim/.vim/pack/stargrave/start/defsplit/plugin/defsplit.vim b/vim/.vim/pack/stargrave/start/defsplit/plugin/defsplit.vim index 876599d..f01362b 100644 --- a/vim/.vim/pack/stargrave/start/defsplit/plugin/defsplit.vim +++ b/vim/.vim/pack/stargrave/start/defsplit/plugin/defsplit.vim @@ -1,6 +1,6 @@ -if exists("*defsplit#do") | finish | endif -command! -nargs=? Defsplit call defsplit#do(["("], v:false, ) -command! -nargs=? Brsplit call defsplit#do(["(", "[", "{"], v:false, ) -command! -nargs=? Defsplits call defsplit#do(["("], v:true, ) -command! -nargs=? Brsplits call defsplit#do(["(", "[", "{"], v:true, ) +if exists("*defsplit#Do") | finish | endif +command! -nargs=? Defsplit call defsplit#Do(["("], v:false, ) +command! -nargs=? Brsplit call defsplit#Do(["(", "[", "{"], v:false, ) +command! -nargs=? Defsplits call defsplit#Do(["("], v:true, ) +command! -nargs=? Brsplits call defsplit#Do(["(", "[", "{"], v:true, ) command! Undefsplit normal ^v%$J:keepp s/^\(.*\)\([([{]\) \(.*[^,]\),\?\([)\]}]\)\(.*\)$/\1\2\3\4\5:keepp s/, \?\([)\]}]\+\)$/\1/e: diff --git a/vim/.vim/pack/stargrave/start/fileline/autoload/fileline.vim b/vim/.vim/pack/stargrave/start/fileline/autoload/fileline.vim index 193328c..d5b1d9a 100644 --- a/vim/.vim/pack/stargrave/start/fileline/autoload/fileline.vim +++ b/vim/.vim/pack/stargrave/start/fileline/autoload/fileline.vim @@ -1,17 +1,19 @@ -" Simplified version of http://www.vim.org/scripts/script.php?script_id=2184 -" that does not replace current window +vim9script -function! fileline#goto() abort - let file = bufname("%") +# Simplified version of http://www.vim.org/scripts/script.php?script_id=2184 +# that does not replace current window + +export def Goto() + var file = bufname("%") if filereadable(file) | return | endif - let names = matchlist(file, '\(.\{-1,}\):\%(\(\d\+\)\%(:\(\d*\):\?\)\?\)\?$') + var names = matchlist(file, '\(.\{-1,}\):\%(\(\d\+\)\%(:\(\d*\):\?\)\?\)\?$') if empty(names) | return | endif - let file_name = names[1] - let line_num = names[2] == "" ? "0" : names[2] - let col_num = names[3] == "" ? "0" : names[3] - if !filereadable(file_name) | return | endif - let nr = bufnr("%") - exec "keepalt edit +" . line_num . " " . file_name - exec "normal! " . col_num . "|" - exec "bdelete " . nr -endfunction + var fileName = names[1] + var lineNum = names[2] == "" ? "0" : names[2] + var colNum = names[3] == "" ? "0" : names[3] + if !filereadable(fileName) | return | endif + var nr = bufnr("%") + execute "keepalt edit +" .. lineNum .. " " .. fileName + execute "normal! " .. colNum .. "|" + execute "bdelete " .. nr +enddef diff --git a/vim/.vim/pack/stargrave/start/fileline/plugin/fileline.vim b/vim/.vim/pack/stargrave/start/fileline/plugin/fileline.vim index 62bf31a..6dc2c07 100644 --- a/vim/.vim/pack/stargrave/start/fileline/plugin/fileline.vim +++ b/vim/.vim/pack/stargrave/start/fileline/plugin/fileline.vim @@ -1,3 +1,3 @@ -if exists("*fileline#goto") | finish | endif -autocmd! BufNewFile *:* nested call fileline#goto() -autocmd! BufRead *:* nested call fileline#goto() +if exists("*fileline#Goto") | finish | endif +autocmd! BufNewFile *:* nested call fileline#Goto() +autocmd! BufRead *:* nested call fileline#Goto() diff --git a/vim/.vim/pack/stargrave/start/go-gogetdoc/autoload/go/getdoc.vim b/vim/.vim/pack/stargrave/start/go-gogetdoc/autoload/go/getdoc.vim index 922c9cd..6c5555e 100644 --- a/vim/.vim/pack/stargrave/start/go-gogetdoc/autoload/go/getdoc.vim +++ b/vim/.vim/pack/stargrave/start/go-gogetdoc/autoload/go/getdoc.vim @@ -1,34 +1,36 @@ -" Popup documentation of specified object under the cursor -" Requires github.com/zmb3/gogetdoc in the $PATH +vim9script -function! go#getdoc#status() +# Popup documentation of specified object under the cursor +# Requires github.com/zmb3/gogetdoc in the $PATH + +export def Status(): string if exists("b:gogetdoc_job") && job_status(b:gogetdoc_job) == "run" | return "GD" | endif return "" -endfunction +enddef -function! go#getdoc#got(ch) abort - let msgs = [] - while ch_status(a:ch) == "buffered" - let msgs = add(msgs, ch_read(a:ch)) +export def Got(ch: channel) + var msgs: list + while ch_status(ch) == "buffered" + msgs = add(msgs, ch_read(ch)) endwhile - if exists("b:godocid") | call popup_close(b:godocid) | endif + if exists("b:godocid") | popup_close(b:godocid) | endif if len(msgs) == 0 echohl WarningMsg | echomsg "No go doc" | echohl None return endif - let msgs = msgs[2:] - let b:godocid = popup_atcursor(msgs[2:-2], - \ {"wrap": 0, "title": msgs[0], "move": "word"}) -endfunction + msgs = msgs[2 :] + b:godocid = popup_atcursor(msgs[2 : -2], + {"wrap": 0, "title": msgs[0], "move": "word"}) +enddef -function! go#getdoc#do() abort +export def Do() if exists("b:gogetdoc_job") && job_status(b:gogetdoc_job) == "run" | return | endif - let pos = line2byte(line(".")) + col(".") - 2 - let cmdline = "gogetdoc -pos " . expand("%p") . ":#" . pos + var pos = line2byte(line(".")) + col(".") - 2 + var cmdline = "gogetdoc -pos " .. expand("%p") .. ":#" .. pos echomsg cmdline - let b:gogetdoc_job = job_start(cmdline, { - \"in_mode": "nl", - \"err_io": "null", - \"close_cb": "go#getdoc#got", - \}) -endfunction + b:gogetdoc_job = job_start(cmdline, { + "in_mode": "nl", + "err_io": "null", + "close_cb": "go#getdoc#Got", + }) +enddef diff --git a/vim/.vim/pack/stargrave/start/go-gogetdoc/ftplugin/go/gogetdoc.vim b/vim/.vim/pack/stargrave/start/go-gogetdoc/ftplugin/go/gogetdoc.vim index eedec71..a93c58f 100644 --- a/vim/.vim/pack/stargrave/start/go-gogetdoc/ftplugin/go/gogetdoc.vim +++ b/vim/.vim/pack/stargrave/start/go-gogetdoc/ftplugin/go/gogetdoc.vim @@ -1,3 +1,3 @@ -if exists("*go#getdoc#do") | finish | endif -let b:mein_status_func=function("go#getdoc#status") -nmap :call go#getdoc#do() +if exists("*go#getdoc#Do") | finish | endif +let b:mein_status_func=function("go#getdoc#Status") +nmap :call go#getdoc#Do() diff --git a/vim/.vim/pack/stargrave/start/nonhumanhl/autoload/nonhumanhl.vim b/vim/.vim/pack/stargrave/start/nonhumanhl/autoload/nonhumanhl.vim index c2ac7fc..038b8c4 100644 --- a/vim/.vim/pack/stargrave/start/nonhumanhl/autoload/nonhumanhl.vim +++ b/vim/.vim/pack/stargrave/start/nonhumanhl/autoload/nonhumanhl.vim @@ -1,5 +1,5 @@ -function! nonhumanhl#load() +vim9script +export def Load() highlight nonhuman ctermbg=blue ctermfg=red - autocmd BufReadPost * syntax match nonhuman - \ "[^\u0000-\u007Fа-яА-ЯёЁäÄöÖüÜßẞ]" containedin=ALL -endfunction + autocmd BufReadPost * syntax match nonhuman "[^\u0000-\u007Fа-яА-ЯёЁäÄöÖüÜßẞ]" containedin=ALL +enddef diff --git a/vim/.vim/pack/stargrave/start/nonhumanhl/plugin/nonhumanhl.vim b/vim/.vim/pack/stargrave/start/nonhumanhl/plugin/nonhumanhl.vim index 7d4e88b..38a0ff4 100644 --- a/vim/.vim/pack/stargrave/start/nonhumanhl/plugin/nonhumanhl.vim +++ b/vim/.vim/pack/stargrave/start/nonhumanhl/plugin/nonhumanhl.vim @@ -1,2 +1,3 @@ -if exists("*nonhumanhl#load") | finish | endif -call nonhumanhl#load() +vim9script +if exists("*nonhumanhl#Load") | finish | endif +nonhumanhl#Load() diff --git a/vim/.vim/pack/stargrave/start/py-importcompl/autoload/python/importcompl.vim b/vim/.vim/pack/stargrave/start/py-importcompl/autoload/python/importcompl.vim index e516ad6..48c166a 100644 --- a/vim/.vim/pack/stargrave/start/py-importcompl/autoload/python/importcompl.vim +++ b/vim/.vim/pack/stargrave/start/py-importcompl/autoload/python/importcompl.vim @@ -1,72 +1,75 @@ -" Python imports insert completion -" Maintainer: Sergey Matveev -" License: GNU General Public License version 3 of the License or later -" -" This plugin is intended for quick import-line insertion. -" For example you have got "from foo.bar import Baz" import somewhere in -" your Git-versioned code. In another file you can write "Baz" and then -" press in insert mode. Completion menu will show you suggestions -" of all import lines from your code containing Baz import. -" -" If you have Pylint or Pyflakes output in quickfix window, containing -" unfedined variables errors, then you can you :call python#importcompl#all() -" function. It will go through the quickfix list and find all possible -" imports, sort them and insert under current cursor position. -" -" It uses external "git grep" call and assumes that "canonical" Python -" import format is used (single import per line). -" You can use http://www.git.stargrave.org/?p=pyimportcan.git;a=blob;f=pyimportcan.pl -" utility to convert existing imports to that format. +vim9script -let s:git_grep_cmd = "git grep -H --line-number --ignore-case --no-color " +# Python imports insert completion +# Maintainer: Sergey Matveev +# License: GNU General Public License version 3 of the License or later +# +# This plugin is intended for quick import-line insertion. +# For example you have got "from foo.bar import Baz" import somewhere in +# your Git-versioned code. In another file you can write "Baz" and then +# press in insert mode. Completion menu will show you suggestions +# of all import lines from your code containing Baz import. +# +# If you have Pylint or Pyflakes output in quickfix window, containing +# unfedined variables errors, then you can you :call python#importcompl#all() +# function. It will go through the quickfix list and find all possible +# imports, sort them and insert under current cursor position. +# +# It uses external "git grep" call and assumes that "canonical" Python +# import format is used (single import per line). +# You can use http://www.git.stargrave.org/?p=pyimportcan.git;a=blob;f=pyimportcan.pl +# utility to convert existing imports to that format. -function! python#importcompl#sortByLen(s1, s2) - if len(a:s1) == len(a:s2) | return a:s1 > a:s2 | endif - return 1 ? len(a:s1) > len(a:s2) : -1 -endfunction +const gitGrepCmd = "git grep -H --line-number --ignore-case --no-color " -function! python#importcompl#do() abort +export def Do(): string normal diw - let output = system(s:git_grep_cmd . '"^from .* import .*' . @" . '" -- "*.py" "**/*.py"') - let suggestions = [] + var output = system(gitGrepCmd .. '"^from .* import .*' .. @" .. '" -- "*.py" "**/*.py"') + var suggestions: list + var m: list for line in split(output, "\n") if stridx(line, "unused-import") != -1 | continue | endif - let m = matchlist(line, '^.*:\d\+:\(.*\)$') + m = matchlist(line, '^.*:\d\+:\(.*\)$') if len(m) == 0 | continue | endif - call insert(suggestions, m[1]) + insert(suggestions, m[1]) endfor - call sort(suggestions, "python#importcompl#sortByLen") - call uniq(suggestions) - call reverse(suggestions) - call complete(col('.'), suggestions) - return '' -endfunction + sort(suggestions, (s1: string, s2: string): number => { + if len(s1) == len(s2) | return 0 | endif + if len(s1) > len(s2) | return 1 | endif + return -1 + }) + uniq(suggestions) + reverse(suggestions) + complete(col("."), suggestions) + return "" +enddef -function! python#importcompl#all() abort - let output = system(s:git_grep_cmd . '"^from .* import" -- "*.py" "**/*.py"') - let imports = {} +export def All() + var output = system(gitGrepCmd .. '"^from .* import" -- "*.py" "**/*.py"') + var imports = {} + var ms: list for line in split(output, "\n") if stridx(line, "unused-import") != -1 | continue | endif for regexp in [ - \'^.*:\d\+:\(from .* import \(\w\+\).*\)$', - \'^.*:\d\+:\(from .* import \w\+ as \(\w\+\).*\)$', - \] - let m = matchlist(line, regexp) - if len(m) == 0 | break | endif - let imports[m[2]] = m[1] + '^.*:\d\+:\(from .* import \(\w\+\).*\)$', + '^.*:\d\+:\(from .* import \w\+ as \(\w\+\).*\)$', + ] + ms = matchlist(line, regexp) + if len(ms) == 0 | break | endif + imports[ms[2]] = ms[1] endfor endfor - - let lines = getloclist(winnr()) - if len(lines) == 0 | let lines = getqflist() | endif - let result = [] + var lines = getloclist(winnr()) + if len(lines) == 0 | lines = getqflist() | endif + var result: list + var m: string for line in lines if line.text !~ "^undefined name" | continue | endif - let m = line.text[strridx(line.text[:-2], "'")+1:-2] + m = line.text[strridx(line.text[: -2], "'") + 1 : -2] if len(m) == 0 || !has_key(imports, m) | continue | endif - call insert(result, imports[m]) + insert(result, imports[m]) endfor - call sort(result, "i") - call uniq(result) - call append(".", result) -endfunction + sort(result, "i") + uniq(result) + append(".", result) +enddef diff --git a/vim/.vim/pack/stargrave/start/py-importcompl/autoload/python/unused.vim b/vim/.vim/pack/stargrave/start/py-importcompl/autoload/python/unused.vim index a44a021..25ef8cb 100644 --- a/vim/.vim/pack/stargrave/start/py-importcompl/autoload/python/unused.vim +++ b/vim/.vim/pack/stargrave/start/py-importcompl/autoload/python/unused.vim @@ -1,6 +1,8 @@ -function! python#unused#remove() abort - call setqflist(filter(getqflist(), {idx, val -> - \ stridx(val.text, "unused-import") != -1 || - \ stridx(val.text, "imported but unused") != -1})) +vim9script + +export def Remove() + setqflist(filter(getqflist(), (idx, val) => + stridx(val.text, "unused-import") != -1 || + stridx(val.text, "imported but unused") != -1)) cdo d -endfunction +enddef diff --git a/vim/.vim/pack/stargrave/start/py-importcompl/ftplugin/python/importcompl.vim b/vim/.vim/pack/stargrave/start/py-importcompl/ftplugin/python/importcompl.vim index 956d522..25cf83e 100644 --- a/vim/.vim/pack/stargrave/start/py-importcompl/ftplugin/python/importcompl.vim +++ b/vim/.vim/pack/stargrave/start/py-importcompl/ftplugin/python/importcompl.vim @@ -1,4 +1,4 @@ -if exists("*python#importcompl#do") | finish | endif -inoremap =python#importcompl#do() -cnoremap call python#importcompl#all() -cnoremap call python#unused#remove() +if exists("*python#importcompl#Do") | finish | endif +inoremap =python#importcompl#Do() +cnoremap call python#importcompl#All() +cnoremap call python#unused#Remove() diff --git a/vim/.vim/pack/stargrave/start/py-pep8/autoload/python/pep8.vim b/vim/.vim/pack/stargrave/start/py-pep8/autoload/python/pep8.vim index 389e2ec..5075c35 100644 --- a/vim/.vim/pack/stargrave/start/py-pep8/autoload/python/pep8.vim +++ b/vim/.vim/pack/stargrave/start/py-pep8/autoload/python/pep8.vim @@ -1,18 +1,21 @@ -" PEP8 caller -" Maintainer: Sergey Matveev -" License: GNU General Public License version 3 of the License or later -" -" Call pycodestyle utility and fill quickfix window with its results. +vim9script -function! python#pep8#do() abort +# PEP8 caller +# Maintainer: Sergey Matveev +# License: GNU General Public License version 3 of the License or later +# +# Call pycodestyle utility and fill quickfix window with its results. + +export def Do() set makeprg=PATH=$PATH\ pycodestyle\ --select=E,W\ % silent make sign unplace * - let l:id = 1 + var _id = 1 for item in getqflist() - execute(':sign place '.l:id.' name=P8 line='.l:item.lnum.' buffer='.l:item.bufnr) - let l:id = l:id + 2 + execute(":sign place " .. _id .. " name=P8 line=" .. item.lnum .. + " buffer=" .. item.bufnr) + _id = _id + 2 endfor redraw! copen -endfunction +enddef diff --git a/vim/.vim/pack/stargrave/start/py-pep8/ftplugin/python/pep8.vim b/vim/.vim/pack/stargrave/start/py-pep8/ftplugin/python/pep8.vim index 8340721..0115125 100644 --- a/vim/.vim/pack/stargrave/start/py-pep8/ftplugin/python/pep8.vim +++ b/vim/.vim/pack/stargrave/start/py-pep8/ftplugin/python/pep8.vim @@ -1,3 +1,3 @@ -if exists("*python#pep8#do") | finish | endif +if exists("*python#pep8#Do") | finish | endif sign define P8 text=P8 texthl=Error -map :call python#pep8#do() +map :call python#pep8#Do() diff --git a/vim/.vim/pack/stargrave/start/py-testname/autoload/python/testname.vim b/vim/.vim/pack/stargrave/start/py-testname/autoload/python/testname.vim index 66610dc..921321a 100644 --- a/vim/.vim/pack/stargrave/start/py-testname/autoload/python/testname.vim +++ b/vim/.vim/pack/stargrave/start/py-testname/autoload/python/testname.vim @@ -1,19 +1,21 @@ -" Nose-compatible test name preparer -" Maintainer: Sergey Matveev -" License: GNU General Public License version 3 of the License or later -" -" When standing inside TestCase's test method, type t and full -" Python (your.project.tests:TestCaseName.test_method_name) path will be -" copied to clipboard ("*) register. +vim9script -function! python#testname#get() abort - let l:pos = getpos(".") - let l:postfix = matchstr(getline(search(".*\s*def .*[Tt]est", "b")), '\w\+(')[:-2] - let l:postfix = matchstr(getline(search("^\s*class", "bn")), '\w\+(')[:-2] . "." . l:postfix - call setpos(".", l:pos) - let l:base = join([""] + split(getcwd(), "/")[:-1], "/") - let l:prefix = substitute(expand("%:p:r")[len(l:base)+1:], "/", ".", "g") - let l:name = l:prefix . ":" . l:postfix - let @* = l:name - echomsg l:name -endfunction +# Nose-compatible test name preparer +# Maintainer: Sergey Matveev +# License: GNU General Public License version 3 of the License or later +# +# When standing inside TestCase's test method, type t and full +# Python (your.project.tests:TestCaseName.test_method_name) path will be +# copied to clipboard ("*) register. + +export def Get() + var pos = getpos(".") + var postfix = matchstr(getline(search(".*\s*def .*[Tt]est", "b")), '\w\+(')[: -2] + postfix = matchstr(getline(search("^\s*class", "bn")), '\w\+(')[: -2] .. "." .. postfix + setpos(".", pos) + var base = join([""] + split(getcwd(), "/")[: -1], "/") + var prefix = substitute(expand("%:p:r")[len(base) + 1 :], "/", ".", "g") + var name = prefix .. ":" .. postfix + @* = name + echomsg name +enddef diff --git a/vim/.vim/pack/stargrave/start/py-testname/ftplugin/python/testname.vim b/vim/.vim/pack/stargrave/start/py-testname/ftplugin/python/testname.vim index 7ec7802..e3d8f87 100644 --- a/vim/.vim/pack/stargrave/start/py-testname/ftplugin/python/testname.vim +++ b/vim/.vim/pack/stargrave/start/py-testname/ftplugin/python/testname.vim @@ -1,2 +1,2 @@ -if exists("*python#testname#get") | finish | endif -nmap t :call python#testname#get() +if exists("*python#testname#Get") | finish | endif +nmap t :call python#testname#Get() diff --git a/vim/.vim/pack/stargrave/start/whereami/autoload/whereami.vim b/vim/.vim/pack/stargrave/start/whereami/autoload/whereami.vim index 5b5b1d8..ba888d4 100644 --- a/vim/.vim/pack/stargrave/start/whereami/autoload/whereami.vim +++ b/vim/.vim/pack/stargrave/start/whereami/autoload/whereami.vim @@ -1,14 +1,16 @@ -function! whereami#pwdLoad() - let g:whereami_pwdL=trim(system("pwd -L")) - let g:whereami_pwdP=trim(system("pwd -P")) -endfunction +vim9script -function! whereami#do(fmt) abort - let fullpath = expand("%:p") - if fullpath[:len(g:whereami_pwdP)-1] ==# g:whereami_pwdP - let fullpath = g:whereami_pwdL . fullpath[len(g:whereami_pwdP):] +export def PwdLoad() + g:whereami_pwdL = trim(system("pwd -L")) + g:whereami_pwdP = trim(system("pwd -P")) +enddef + +export def Do(fmt: string) + var fullpath = expand("%:p") + if fullpath[ : len(g:whereami_pwdP) - 1] ==# g:whereami_pwdP + fullpath = g:whereami_pwdL .. fullpath[len(g:whereami_pwdP) : ] endif - let where = printf(a:fmt, fullpath, line(".")) - let @* = where + var where = printf(fmt, fullpath, line(".")) + @* = where echomsg where -endfunction +enddef diff --git a/vim/.vim/pack/stargrave/start/whereami/plugin/whereami.vim b/vim/.vim/pack/stargrave/start/whereami/plugin/whereami.vim index 3398134..c3c972b 100644 --- a/vim/.vim/pack/stargrave/start/whereami/plugin/whereami.vim +++ b/vim/.vim/pack/stargrave/start/whereami/plugin/whereami.vim @@ -1,4 +1,4 @@ if exists("*whereami#pwdLoad") | finish | endif -autocmd VimEnter * call whereami#pwdLoad() -nmap w :call whereami#do("%s:%d") -nmap W :call whereami#do("breakpoint set --file %s --line %d") +autocmd VimEnter * call whereami#PwdLoad() +nmap w :call whereami#Do("%s:%d") +nmap W :call whereami#Do("breakpoint set --file %s --line %d") diff --git a/vim/.vim/pack/stargrave/start/zshfe/autoload/zshfe.vim b/vim/.vim/pack/stargrave/start/zshfe/autoload/zshfe.vim new file mode 100644 index 0000000..bb94dd6 --- /dev/null +++ b/vim/.vim/pack/stargrave/start/zshfe/autoload/zshfe.vim @@ -0,0 +1,7 @@ +vim9script + +export def Do(query: string, opencmd: string) + silent var result = systemlist(g:zshfe_path .. " " .. query) + if len(result) == 0 | return | endif + execute opencmd .. " " .. result[0][: -2] +enddef diff --git a/vim/.vim/pack/stargrave/start/zshfe/plugin/zshfe.vim b/vim/.vim/pack/stargrave/start/zshfe/plugin/zshfe.vim index d85d531..cb05d99 100644 --- a/vim/.vim/pack/stargrave/start/zshfe/plugin/zshfe.vim +++ b/vim/.vim/pack/stargrave/start/zshfe/plugin/zshfe.vim @@ -1,21 +1,17 @@ -" zsh file completion caller -" Maintainer: Sergey Matveev -" License: GNU General Public License version 3 of the License or later +vim9script -if exists("*zshfe") | finish | endif +# zsh file completion caller +# Maintainer: Sergey Matveev +# License: GNU General Public License version 3 of the License or later + +if exists("*zshfe#Do") | finish | endif if !exists("g:zshfe_path") - let g:zshfe_path=expand(":p:h") . "/zshfe.zsh" + g:zshfe_path = expand(":p:h") .. "/zshfe.zsh" endif -function! s:zshfe(query, opencmd) - silent let result = systemlist(g:zshfe_path . " " . a:query) - if len(result) == 0 | return | endif - exec a:opencmd . " " . result[0][:-2] -endfunction - -command! -nargs=1 Fe call s:zshfe(, "edit") -command! -nargs=1 Fsp call s:zshfe(, "split") -command! -nargs=1 Fvs call s:zshfe(, "vsplit") +command! -nargs=1 Fe call zshfe#Do(, "edit") +command! -nargs=1 Fsp call zshfe#Do(, "split") +command! -nargs=1 Fvs call zshfe#Do(, "vsplit") nmap e :Fe nmap :Fsp diff --git a/vim/.vim/plugin/disables.vim b/vim/.vim/plugin/disables.vim index a412e42..bb39d02 100644 --- a/vim/.vim/plugin/disables.vim +++ b/vim/.vim/plugin/disables.vim @@ -1,7 +1,9 @@ -let g:loaded_2html_plugin = 1 -let g:loaded_getscriptPlugin = 1 -let g:loaded_logipat = 1 -let g:loaded_rrhelper = 1 -let g:loaded_spellfile_plugin = 1 -let g:loaded_vimballPlugin = 1 -let g:loaded_vimball = 1 +vim9script + +g:loaded_2html_plugin = 1 +g:loaded_getscriptPlugin = 1 +g:loaded_logipat = 1 +g:loaded_rrhelper = 1 +g:loaded_spellfile_plugin = 1 +g:loaded_vimballPlugin = 1 +g:loaded_vimball = 1 diff --git a/vim/.vim/plugin/exted.vim b/vim/.vim/plugin/exted.vim index e24524e..e0f0079 100644 --- a/vim/.vim/plugin/exted.vim +++ b/vim/.vim/plugin/exted.vim @@ -1,7 +1,2 @@ -if exists("*exted") | finish | endif - -function! s:exted(ext) - execute "edit %<." . a:ext -endfunction - -command! -nargs=1 Ee silent call s:exted() +vim9script +command -nargs=1 Ee execute "edit %<." .. diff --git a/vim/.vim/plugin/ggrep.vim b/vim/.vim/plugin/ggrep.vim index e2f43fb..26f3d17 100644 --- a/vim/.vim/plugin/ggrep.vim +++ b/vim/.vim/plugin/ggrep.vim @@ -1,9 +1,6 @@ -if exists("*Vmg") | finish | endif +vim9script -function! s:Vmg(pattern) - silent execute 'Ggrep "' . a:pattern . '"' +command! -nargs=* -complete=file Vmg { + silent execute "Ggrep \"" .. .. '"' copen - redraw! -endfunction - -command! -nargs=* -complete=file Vmg call s:Vmg() +} diff --git a/vim/.vim/plugin/grep.vim b/vim/.vim/plugin/grep.vim index 140f8fc..333a9d7 100644 --- a/vim/.vim/plugin/grep.vim +++ b/vim/.vim/plugin/grep.vim @@ -1,10 +1,8 @@ -if exists("*Vim") | finish | endif +vim9script -function! s:Vim(pattern) +command! -nargs=* -complete=file Vim { set grepprg=grep\ -Rns\ --binary-files=without-match\ --exclude-dir=.git\ --exclude-dir=.tags\ $*\ /dev/null\ . - execute "silent grep \"" . a:pattern . "\"" + execute "silent grep \"" .. .. "\"" copen redraw! -endfunction - -command! -nargs=* -complete=file Vim call s:Vim() +} diff --git a/vim/.vim/plugin/lsp.vim b/vim/.vim/plugin/lsp.vim index 1928046..1f5586b 100644 --- a/vim/.vim/plugin/lsp.vim +++ b/vim/.vim/plugin/lsp.vim @@ -1,27 +1,29 @@ -" go get golang.org/x/tools/gopls@latest -" pip install 'python-language-server[all]' +vim9script -let g:lsc_enable_autocomplete = v:false -let g:lsc_server_commands = { - \ "c": {"command": "clangd --log=error"}, - \ "cpp": {"command": "clangd --log=error"}, - \ "go": {"command": "gopls", "log_level": -1}, - \ "python": { - \ "command": "pyls", - \ "workspace_config": {"pyls": { - \ "configurationSources": ["flake8"], - \ "plugins": { - \ "mccabe": {"enabled": v:false}, - \ }, - \ }}, - \ "enabled": v:false, - \ }, -\ } -let g:lsc_auto_map = { - \ "GoToDefinition": "gd", - \ "GoToDefinitionSplit": "gd", - \ "ShowHover": v:true, - \ "Completion": "omnifunc", -\ } +# go get golang.org/x/tools/gopls@latest +# pip install 'python-language-server[all]' + +g:lsc_enable_autocomplete = v:false +g:lsc_server_commands = { + c: {command: "clangd --log=error"}, + cpp: {command: "clangd --log=error"}, + go: {command: "gopls", log_level: -1}, + python: { + command: "pyls", + workspace_config: {pyls: { + configurationSources: ["flake8"], + plugins: { + mccabe: {enabled: v:false}, + }, + }}, + enabled: v:false, + }, +} +g:lsc_auto_map = { + GoToDefinition: "gd", + GoToDefinitionSplit: "gd", + ShowHover: v:true, + Completion: "omnifunc", +} map :LSClientAllDiagnostics diff --git a/vim/.vim/plugin/netrw.vim b/vim/.vim/plugin/netrw.vim index a724061..9b71a8d 100644 --- a/vim/.vim/plugin/netrw.vim +++ b/vim/.vim/plugin/netrw.vim @@ -1,12 +1,14 @@ +vim9script if exists("g:loaded_mein_netrw") | finish | endif -let g:loaded_mein_netrw = 1 +g:loaded_mein_netrw = 1 -let g:netrw_banner = 0 -let g:netrw_bufsettings = "noma nomod nowrap ro nobl" +g:netrw_banner = 0 +g:netrw_bufsettings = "noma nomod nowrap ro nobl" -function! WinClose(islocal) +def g:WinClose(islocal: number): string close -endfunction -let g:Netrw_UserMaps = [["", "WinClose"]] + return "" +enddef +g:Netrw_UserMaps = [["", "g:WinClose"]] autocmd VimLeave * call delete("/home/stargrave/.vim/.netrwhist")