Fri, 15 May 2020 22:55:03 -0500
Load vim-lsp if gopls is present alone
631
8e07c29f2672
fix viewdoc abbrevs and cabbrevs in general
Meredith Howard <mhoward@roomag.org>
parents:
619
diff
changeset
|
1 | func! vimrc#CommandAlias(abbrev, expand) abort |
632
9a87ce42aa3c
getcmdpos is cursor position in expr mode here, wont work
Meredith Howard <mhoward@roomag.org>
parents:
631
diff
changeset
|
2 | execute printf('cnoreabbrev <expr> %s (getcmdtype()==":" && getcmdline()=="%s") ? "%s" : "%s"', a:abbrev, a:abbrev, a:expand, a:abbrev) |
631
8e07c29f2672
fix viewdoc abbrevs and cabbrevs in general
Meredith Howard <mhoward@roomag.org>
parents:
619
diff
changeset
|
3 | endfunc |
470 | 4 | |
580 | 5 | func! vimrc#AutoFmtToggle() abort |
641 | 6 | if &formatoptions =~# 'a' |
640
f8985ae54969
avoid abbreviated options
Meredith Howard <mhoward@roomag.org>
parents:
632
diff
changeset
|
7 | setl formatoptions-=a | echo '-a' |
470 | 8 | else |
640
f8985ae54969
avoid abbreviated options
Meredith Howard <mhoward@roomag.org>
parents:
632
diff
changeset
|
9 | setl formatoptions+=a | echo '+a' |
470 | 10 | endif |
580 | 11 | endfunc |
470 | 12 | |
586 | 13 | func! vimrc#Ltag(term) abort |
14 | exe "ltag " . a:term | |
15 | lopen | |
16 | endfunc | |
17 | ||
470 | 18 | " Make paths when writing, as necessary |
580 | 19 | func! vimrc#MkNonExDir(file, buf) abort |
470 | 20 | if empty(getbufvar(a:buf, '&buftype')) && a:file!~#'\v^\w+\:\/' |
21 | let dir=fnamemodify(a:file, ':h') | |
22 | if !isdirectory(dir) | |
23 | call mkdir(dir, 'p') | |
24 | endif | |
25 | endif | |
580 | 26 | endfunc |
470 | 27 | |
805 | 28 | func! vimrc#AutoSessionCheck() abort |
583 | 29 | if strlen(v:servername) > 0 && match(v:servername, 'VIM') == -1 |
805 | 30 | let sessionfile = g:vimcache . "/session/" . tolower(v:servername) . ".vim" |
31 | ||
32 | if filereadable(sessionfile) | |
33 | execute "source " . sessionfile | |
34 | endif | |
583 | 35 | endif |
36 | endfunc | |
728
60df63f03873
I don't really use these except for the cd shortcuts
Meredith Howard <mhoward@roomag.org>
parents:
725
diff
changeset
|
37 | |
803
ffc6f9c140cd
Move this Ag stuff into a function, remove flickers
Meredith Howard <mhoward@roomag.org>
parents:
750
diff
changeset
|
38 | func! vimrc#Ag(args) abort |
ffc6f9c140cd
Move this Ag stuff into a function, remove flickers
Meredith Howard <mhoward@roomag.org>
parents:
750
diff
changeset
|
39 | let orig_t_ti = &t_ti |
ffc6f9c140cd
Move this Ag stuff into a function, remove flickers
Meredith Howard <mhoward@roomag.org>
parents:
750
diff
changeset
|
40 | let orig_t_te = &t_te |
ffc6f9c140cd
Move this Ag stuff into a function, remove flickers
Meredith Howard <mhoward@roomag.org>
parents:
750
diff
changeset
|
41 | let orig_shellpipe = &shellpipe |
ffc6f9c140cd
Move this Ag stuff into a function, remove flickers
Meredith Howard <mhoward@roomag.org>
parents:
750
diff
changeset
|
42 | |
ffc6f9c140cd
Move this Ag stuff into a function, remove flickers
Meredith Howard <mhoward@roomag.org>
parents:
750
diff
changeset
|
43 | set t_ti= t_te= |
ffc6f9c140cd
Move this Ag stuff into a function, remove flickers
Meredith Howard <mhoward@roomag.org>
parents:
750
diff
changeset
|
44 | let &shellpipe = substitute(&shellpipe, '| tee', ' >', '') |
ffc6f9c140cd
Move this Ag stuff into a function, remove flickers
Meredith Howard <mhoward@roomag.org>
parents:
750
diff
changeset
|
45 | |
832
8acb094e5e12
use cword as ag/rg default
Meredith Howard <mhoward@roomag.org>
parents:
829
diff
changeset
|
46 | let grepargs = a:args == '' ? expand('<cword>') : a:args . join(a:000, ' ') |
8acb094e5e12
use cword as ag/rg default
Meredith Howard <mhoward@roomag.org>
parents:
829
diff
changeset
|
47 | |
803
ffc6f9c140cd
Move this Ag stuff into a function, remove flickers
Meredith Howard <mhoward@roomag.org>
parents:
750
diff
changeset
|
48 | try |
832
8acb094e5e12
use cword as ag/rg default
Meredith Howard <mhoward@roomag.org>
parents:
829
diff
changeset
|
49 | silent! execute "grep " . escape(grepargs, '|') |
803
ffc6f9c140cd
Move this Ag stuff into a function, remove flickers
Meredith Howard <mhoward@roomag.org>
parents:
750
diff
changeset
|
50 | copen |
ffc6f9c140cd
Move this Ag stuff into a function, remove flickers
Meredith Howard <mhoward@roomag.org>
parents:
750
diff
changeset
|
51 | |
ffc6f9c140cd
Move this Ag stuff into a function, remove flickers
Meredith Howard <mhoward@roomag.org>
parents:
750
diff
changeset
|
52 | let @/ = matchstr(a:args, "\\v(-)\@<!(\<)\@<=\\w+|['\"]\\zs.{-}\\ze['\"]") |
ffc6f9c140cd
Move this Ag stuff into a function, remove flickers
Meredith Howard <mhoward@roomag.org>
parents:
750
diff
changeset
|
53 | call feedkeys(":let &hlsearch=1 \| echo \<CR>", 'n') |
ffc6f9c140cd
Move this Ag stuff into a function, remove flickers
Meredith Howard <mhoward@roomag.org>
parents:
750
diff
changeset
|
54 | finally |
ffc6f9c140cd
Move this Ag stuff into a function, remove flickers
Meredith Howard <mhoward@roomag.org>
parents:
750
diff
changeset
|
55 | let &t_ti = orig_t_ti |
ffc6f9c140cd
Move this Ag stuff into a function, remove flickers
Meredith Howard <mhoward@roomag.org>
parents:
750
diff
changeset
|
56 | let &t_te = orig_t_te |
ffc6f9c140cd
Move this Ag stuff into a function, remove flickers
Meredith Howard <mhoward@roomag.org>
parents:
750
diff
changeset
|
57 | let &shellpipe = orig_shellpipe |
ffc6f9c140cd
Move this Ag stuff into a function, remove flickers
Meredith Howard <mhoward@roomag.org>
parents:
750
diff
changeset
|
58 | endtry |
ffc6f9c140cd
Move this Ag stuff into a function, remove flickers
Meredith Howard <mhoward@roomag.org>
parents:
750
diff
changeset
|
59 | endfunc |
ffc6f9c140cd
Move this Ag stuff into a function, remove flickers
Meredith Howard <mhoward@roomag.org>
parents:
750
diff
changeset
|
60 | |
728
60df63f03873
I don't really use these except for the cd shortcuts
Meredith Howard <mhoward@roomag.org>
parents:
725
diff
changeset
|
61 | func! vimrc#Gcd() abort |
60df63f03873
I don't really use these except for the cd shortcuts
Meredith Howard <mhoward@roomag.org>
parents:
725
diff
changeset
|
62 | let root = system('git rev-parse --show-toplevel 2>/dev/null')[:-2] |
60df63f03873
I don't really use these except for the cd shortcuts
Meredith Howard <mhoward@roomag.org>
parents:
725
diff
changeset
|
63 | if ! v:shell_error |
60df63f03873
I don't really use these except for the cd shortcuts
Meredith Howard <mhoward@roomag.org>
parents:
725
diff
changeset
|
64 | exec 'cd ' . root |
60df63f03873
I don't really use these except for the cd shortcuts
Meredith Howard <mhoward@roomag.org>
parents:
725
diff
changeset
|
65 | endif |
60df63f03873
I don't really use these except for the cd shortcuts
Meredith Howard <mhoward@roomag.org>
parents:
725
diff
changeset
|
66 | pwd |
60df63f03873
I don't really use these except for the cd shortcuts
Meredith Howard <mhoward@roomag.org>
parents:
725
diff
changeset
|
67 | endfunc |
60df63f03873
I don't really use these except for the cd shortcuts
Meredith Howard <mhoward@roomag.org>
parents:
725
diff
changeset
|
68 | |
60df63f03873
I don't really use these except for the cd shortcuts
Meredith Howard <mhoward@roomag.org>
parents:
725
diff
changeset
|
69 | func! vimrc#Hgcd() abort |
60df63f03873
I don't really use these except for the cd shortcuts
Meredith Howard <mhoward@roomag.org>
parents:
725
diff
changeset
|
70 | let root = system('hg root 2>/dev/null')[:-2] |
60df63f03873
I don't really use these except for the cd shortcuts
Meredith Howard <mhoward@roomag.org>
parents:
725
diff
changeset
|
71 | if ! v:shell_error |
60df63f03873
I don't really use these except for the cd shortcuts
Meredith Howard <mhoward@roomag.org>
parents:
725
diff
changeset
|
72 | exec 'cd ' . root |
60df63f03873
I don't really use these except for the cd shortcuts
Meredith Howard <mhoward@roomag.org>
parents:
725
diff
changeset
|
73 | endif |
60df63f03873
I don't really use these except for the cd shortcuts
Meredith Howard <mhoward@roomag.org>
parents:
725
diff
changeset
|
74 | pwd |
60df63f03873
I don't really use these except for the cd shortcuts
Meredith Howard <mhoward@roomag.org>
parents:
725
diff
changeset
|
75 | endfunc |
60df63f03873
I don't really use these except for the cd shortcuts
Meredith Howard <mhoward@roomag.org>
parents:
725
diff
changeset
|
76 | |
750
36a4da0a9863
Separate errors from filter stream
Meredith Howard <mhoward@roomag.org>
parents:
728
diff
changeset
|
77 | func! vimrc#SafeFilterFile(cmd) |
36a4da0a9863
Separate errors from filter stream
Meredith Howard <mhoward@roomag.org>
parents:
728
diff
changeset
|
78 | let errors = tempname() |
36a4da0a9863
Separate errors from filter stream
Meredith Howard <mhoward@roomag.org>
parents:
728
diff
changeset
|
79 | try |
36a4da0a9863
Separate errors from filter stream
Meredith Howard <mhoward@roomag.org>
parents:
728
diff
changeset
|
80 | exec 'silent %!' . a:cmd . ' 2>' . shellescape(errors) |
36a4da0a9863
Separate errors from filter stream
Meredith Howard <mhoward@roomag.org>
parents:
728
diff
changeset
|
81 | if v:shell_error |
36a4da0a9863
Separate errors from filter stream
Meredith Howard <mhoward@roomag.org>
parents:
728
diff
changeset
|
82 | for line in readfile(errors) |
36a4da0a9863
Separate errors from filter stream
Meredith Howard <mhoward@roomag.org>
parents:
728
diff
changeset
|
83 | echomsg line |
36a4da0a9863
Separate errors from filter stream
Meredith Howard <mhoward@roomag.org>
parents:
728
diff
changeset
|
84 | endfor |
36a4da0a9863
Separate errors from filter stream
Meredith Howard <mhoward@roomag.org>
parents:
728
diff
changeset
|
85 | endif |
36a4da0a9863
Separate errors from filter stream
Meredith Howard <mhoward@roomag.org>
parents:
728
diff
changeset
|
86 | finally |
36a4da0a9863
Separate errors from filter stream
Meredith Howard <mhoward@roomag.org>
parents:
728
diff
changeset
|
87 | call delete(errors) |
36a4da0a9863
Separate errors from filter stream
Meredith Howard <mhoward@roomag.org>
parents:
728
diff
changeset
|
88 | endtry |
36a4da0a9863
Separate errors from filter stream
Meredith Howard <mhoward@roomag.org>
parents:
728
diff
changeset
|
89 | endfunc |