From c87a6c5de579ab6ae0e5d27b233b83bab85e17f6 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Tue, 15 Jun 2021 11:28:25 +0300 Subject: [PATCH] Detect already loaded code with simpler check --- vim/.vim/ftplugin/html/autos.vim | 2 +- vim/.vim/plugin/buftabline.vim | 9 ++++++--- vim/.vim/plugin/chnglstnav.vim | 3 +-- vim/.vim/plugin/ctags.vim | 11 +++++------ vim/.vim/plugin/defsplit.vim | 13 ++++++------- vim/.vim/plugin/exted.vim | 3 +-- vim/.vim/plugin/file_line.vim | 3 +-- vim/.vim/plugin/ggrep.vim | 3 +-- vim/.vim/plugin/grep.vim | 3 +-- vim/.vim/plugin/lsp.vim | 4 ++-- vim/.vim/plugin/whereami.vim | 9 ++++----- vim/.vim/plugin/zshfe.vim | 3 +-- 12 files changed, 30 insertions(+), 36 deletions(-) diff --git a/vim/.vim/ftplugin/html/autos.vim b/vim/.vim/ftplugin/html/autos.vim index fe2fcf3..3e073e6 100644 --- a/vim/.vim/ftplugin/html/autos.vim +++ b/vim/.vim/ftplugin/html/autos.vim @@ -1 +1 @@ -abbreviate tto FFBufTabLine') | finish | endif -function! BufTabline() +function! s:BufTabline() redir => bufsRaw silent buffers redir END @@ -22,5 +21,9 @@ function! BufTabline() return join(bufs, " ") endfunction +function! BufTabline() + return s:BufTabline() +endfunction + set showtabline=2 set tabline=%!BufTabline() diff --git a/vim/.vim/plugin/chnglstnav.vim b/vim/.vim/plugin/chnglstnav.vim index e383743..dac9e95 100644 --- a/vim/.vim/plugin/chnglstnav.vim +++ b/vim/.vim/plugin/chnglstnav.vim @@ -1,5 +1,4 @@ -if exists("g:loaded_mein_chnglstnav") | finish | endif -let g:loaded_mein_chnglstnav = 1 +if exists('*Chng') | finish | endif function! s:Chng(...) if a:0 == 0 | return | endif diff --git a/vim/.vim/plugin/ctags.vim b/vim/.vim/plugin/ctags.vim index fbc438c..268b27e 100644 --- a/vim/.vim/plugin/ctags.vim +++ b/vim/.vim/plugin/ctags.vim @@ -5,10 +5,9 @@ " Create "tags" file in your project's root first. " Then :Ctags LANG to fill it. -if exists("g:loaded_mein_ctags") | finish | endif -let g:loaded_mein_ctags = 1 +if exists('*Ctags') | finish | endif -function! s:ctags(lang, onlyCmd, verbose) +function! s:Ctags(lang, onlyCmd, verbose) let dst = tagfiles() if len(dst) == 0 echohl WarningMsg | echomsg "No tagfiles" | echohl None @@ -37,6 +36,6 @@ function! s:ctags(lang, onlyCmd, verbose) if a:verbose != v:true | redraw! | endif endfunction -command! -nargs=1 Ctags silent call s:ctags(, v:false, v:false) -command! -nargs=1 Ctagsv silent call s:ctags(, v:true, v:false) -command! -nargs=1 Ctagscmd call s:ctags(, v:true, v:true) +command! -nargs=1 Ctags silent call s:Ctags(, v:false, v:false) +command! -nargs=1 Ctagsv silent call s:Ctags(, v:true, v:false) +command! -nargs=1 Ctagscmd call s:Ctags(, v:true, v:true) diff --git a/vim/.vim/plugin/defsplit.vim b/vim/.vim/plugin/defsplit.vim index f995c8a..7beb26b 100644 --- a/vim/.vim/plugin/defsplit.vim +++ b/vim/.vim/plugin/defsplit.vim @@ -32,9 +32,8 @@ " Also there is :Brsplit command behaving similarly, but it splits other " types of brackets: "{}", "[]". -if exists("g:loaded_defsplit") | finish | endif -let g:loaded_defsplit = 1 if !exists("g:defsplit_shift") | let g:defsplit_shift = " " | endif +if exists('*Defsplit') | finish | endif function! s:bracket_find(brs_allowable, line, offset) let possible = [] @@ -45,7 +44,7 @@ function! s:bracket_find(brs_allowable, line, offset) return min(possible) endfunction -function! s:defsplit(brs_allowable, single_line_comma, ...) +function! s:Defsplit(brs_allowable, single_line_comma, ...) if a:0 == 0 | let skip = 0 | else | let skip = str2nr(a:1) | endif let shift = g:defsplit_shift let line = getline(".") @@ -95,9 +94,9 @@ function! s:defsplit(brs_allowable, single_line_comma, ...) normal "_dd endfunction -command! -nargs=? Defsplit call s:defsplit(["("], v:false, ) -command! -nargs=? Brsplit call s:defsplit(["(", "[", "{"], v:false, ) -command! -nargs=? Defsplits call s:defsplit(["("], v:true, ) -command! -nargs=? Brsplits call s:defsplit(["(", "[", "{"], v:true, ) +command! -nargs=? Defsplit call s:Defsplit(["("], v:false, ) +command! -nargs=? Brsplit call s:Defsplit(["(", "[", "{"], v:false, ) +command! -nargs=? Defsplits call s:Defsplit(["("], v:true, ) +command! -nargs=? Brsplits call s:Defsplit(["(", "[", "{"], v:true, ) command! Undefsplit normal ^v%$J:keepp s/^\(.*\)\([([{]\) \(.*[^,]\),\?\([)\]}]\)\(.*\)$/\1\2\3\4\5:keepp s/, \?\([)\]}]\+\)$/\1/e: diff --git a/vim/.vim/plugin/exted.vim b/vim/.vim/plugin/exted.vim index 3911431..3833a65 100644 --- a/vim/.vim/plugin/exted.vim +++ b/vim/.vim/plugin/exted.vim @@ -1,5 +1,4 @@ -if exists("g:loaded_mein_exted") | finish | endif -let g:loaded_mein_exted = 1 +if exists('*exted') | finish | endif function! s:exted(ext) execute "edit %<." . a:ext diff --git a/vim/.vim/plugin/file_line.vim b/vim/.vim/plugin/file_line.vim index 45e250e..8d7c429 100644 --- a/vim/.vim/plugin/file_line.vim +++ b/vim/.vim/plugin/file_line.vim @@ -1,8 +1,7 @@ " Simplified version of http://www.vim.org/scripts/script.php?script_id=2184 " that does not replace current window -if exists("g:loaded_mein_file_line") | finish | endif -let g:loaded_mein_file_line = 1 +if exists('*gotoline') | finish | endif function! s:gotoline() let file = bufname("%") diff --git a/vim/.vim/plugin/ggrep.vim b/vim/.vim/plugin/ggrep.vim index 7b52921..8a9bd8a 100644 --- a/vim/.vim/plugin/ggrep.vim +++ b/vim/.vim/plugin/ggrep.vim @@ -1,5 +1,4 @@ -if exists("g:loaded_mein_ggrep") | finish | endif -let g:loaded_mein_ggrep = 1 +if exists('*Vmg') | finish | endif function! s:Vmg(pattern) silent execute 'Ggrep "' . a:pattern . '"' diff --git a/vim/.vim/plugin/grep.vim b/vim/.vim/plugin/grep.vim index e0878e7..834390a 100644 --- a/vim/.vim/plugin/grep.vim +++ b/vim/.vim/plugin/grep.vim @@ -1,5 +1,4 @@ -if exists("g:loaded_mein_grep") | finish | endif -let g:loaded_mein_grep = 1 +if exists('*Vim') | finish | endif function! s:Vim(pattern) let ignorecase_bak=&ignorecase diff --git a/vim/.vim/plugin/lsp.vim b/vim/.vim/plugin/lsp.vim index 45f903c..d8c9167 100644 --- a/vim/.vim/plugin/lsp.vim +++ b/vim/.vim/plugin/lsp.vim @@ -1,5 +1,5 @@ -if exists("g:loaded_mein_lsp") | finish | endif -let g:loaded_mein_lsp = 1 +if exists('*on_lsp_buffer_enabled') | finish | endif + let g:lsp_auto_enable = 1 let g:lsp_diagnostics_echo_cursor = 1 diff --git a/vim/.vim/plugin/whereami.vim b/vim/.vim/plugin/whereami.vim index f3a4f3c..a6d5336 100644 --- a/vim/.vim/plugin/whereami.vim +++ b/vim/.vim/plugin/whereami.vim @@ -1,5 +1,4 @@ -if exists("g:loaded_mein_whereami") | finish | endif -let g:loaded_mein_whereami = 1 +if exists('*pwdLoad') | finish | endif function! s:pwdLoad() let g:mein_pwdL=trim(system("pwd -L")) @@ -8,7 +7,7 @@ endfunction autocmd VimEnter * call s:pwdLoad() -function! WhereAmI(fmt) +function! s:WhereAmI(fmt) let fullpath = expand("%:p") if fullpath[:len(g:mein_pwdP)-1] ==# g:mein_pwdP let fullpath = g:mein_pwdL . fullpath[len(g:mein_pwdP):] @@ -24,5 +23,5 @@ function! WhereAmI(fmt) echomsg where endfunction -nmap w :call WhereAmI("gnu") -nmap W :call WhereAmI("lldb") +nmap w :call WhereAmI("gnu") +nmap W :call WhereAmI("lldb") diff --git a/vim/.vim/plugin/zshfe.vim b/vim/.vim/plugin/zshfe.vim index fd5e5b1..cd9cc07 100644 --- a/vim/.vim/plugin/zshfe.vim +++ b/vim/.vim/plugin/zshfe.vim @@ -2,8 +2,7 @@ " Maintainer: Sergey Matveev " License: GNU General Public License version 3 of the License or later -if exists("g:loaded_zshfe") | finish | endif -let g:loaded_zshfe = 1 +if exists('*zshfe') | finish | endif if !exists("g:zshfe_path") | let g:zshfe_path=expand("~/.vim/plugin/zshfe.zsh") | endif function! s:zshfe(query, opencmd) -- 2.44.0