From 0c1cb2eb8524e4a85892a13326cf8e0d37e111d6 Mon Sep 17 00:00:00 2001 From: paskozdilar Date: Mon, 3 Jun 2024 12:53:08 +0200 Subject: [PATCH] Remove support for GoKeyify Standalone keyify tool has been removed from the go-tools repository and integrated with gopls. https://github.com/dominikh/go-tools/issues/769 --- autoload/go/keyify.vim | 64 ---------------------------------------- doc/vim-go.txt | 15 ---------- ftplugin/go/commands.vim | 5 ---- plugin/go.vim | 1 - 4 files changed, 85 deletions(-) delete mode 100644 autoload/go/keyify.vim diff --git a/autoload/go/keyify.vim b/autoload/go/keyify.vim deleted file mode 100644 index 41a543f3d8..0000000000 --- a/autoload/go/keyify.vim +++ /dev/null @@ -1,64 +0,0 @@ -" don't spam the user when Vim is started in Vi compatibility mode -let s:cpo_save = &cpo -set cpo&vim - -function! go#keyify#Keyify() - " Needs: https://github.com/dominikh/go-tools/pull/272 - "\ '-tags', go#config#BuildTags(), - let l:cmd = ['keyify', - \ '-json', - \ printf('%s:#%s', fnamemodify(expand('%'), ':p:gs?\\?/?'), go#util#OffsetCursor())] - - let [l:out, l:err] = go#util#Exec(l:cmd) - if l:err - call go#util#EchoError("non-zero exit code: " . l:out) - return - endif - silent! let result = json_decode(l:out) - - " We want to output the error message in case the result isn't a JSON - if type(result) != type({}) - call go#util#EchoError(s:chomp(l:out)) - return - endif - - " Because keyify returns the byte before the region we want, we goto the - " byte after that - execute "goto" result.start + 1 - let start = getpos('.') - execute "goto" result.end - let end = getpos('.') - - let vis_start = getpos("'<") - let vis_end = getpos("'>") - - " Replace contents between start and end with `replacement` - call setpos("'<", start) - call setpos("'>", end) - - let select = 'gv' - - " Make sure the visual mode is 'v', to avoid some bugs - normal! gv - if mode() !=# 'v' - let select .= 'v' - endif - - silent! execute "normal!" select."\"=result.replacement\p" - - " Replacement text isn't aligned, so it needs fix - normal! '= - - call setpos("'<", vis_start) - call setpos("'>", vis_end) -endfunction - -function! s:chomp(string) - return substitute(a:string, '\n\+$', '', '') -endfunction - -" restore Vi compatibility settings -let &cpo = s:cpo_save -unlet s:cpo_save - -" vim: sw=2 ts=2 et diff --git a/doc/vim-go.txt b/doc/vim-go.txt index af5db2a032..e2e4ec3d73 100644 --- a/doc/vim-go.txt +++ b/doc/vim-go.txt @@ -765,21 +765,6 @@ CTRL-t Toggles |'g:go_template_autocreate'|. - *:GoKeyify* -:GoKeyify - - Uses `keyify` to turn unkeyed struct literals into keyed ones. - - For example: -> - Person{"John", "Smith"} -< - Becomes: -> - Person{ - Name: "John", - Surname: "Smith", - } < *:GoFillStruct* :GoFillStruct diff --git a/ftplugin/go/commands.vim b/ftplugin/go/commands.vim index 79d917317b..c8fcd6ac34 100644 --- a/ftplugin/go/commands.vim +++ b/ftplugin/go/commands.vim @@ -91,11 +91,6 @@ command! -nargs=* -complete=customlist,go#impl#Complete GoImpl call go#impl#Impl " -- template command! -nargs=0 GoTemplateAutoCreateToggle call go#template#ToggleAutoCreate() -" -- keyify -if go#package#InGOPATH() - command! -nargs=0 GoKeyify call go#keyify#Keyify() -endif - " -- fillstruct command! -nargs=0 GoFillStruct call go#fillstruct#FillStruct() diff --git a/plugin/go.vim b/plugin/go.vim index b8992437e5..30651a9167 100644 --- a/plugin/go.vim +++ b/plugin/go.vim @@ -54,7 +54,6 @@ let s:packages = { \ 'gorename': ['golang.org/x/tools/cmd/gorename@master'], \ 'gotags': ['github.com/jstemmer/gotags@master'], \ 'impl': ['github.com/josharian/impl@main'], - \ 'keyify': ['honnef.co/go/tools/cmd/keyify@master'], \ 'motion': ['github.com/fatih/motion@latest'], \ 'iferr': ['github.com/koron/iferr@master'], \ }