add more golang lua bullshit to nvim
Jes Olson j3s@c3f.net
Wed, 17 Aug 2022 17:02:01 -0500
1 files changed,
22 insertions(+),
1 deletions(-)
jump to
M
.config/nvim/init.vim
→
.config/nvim/init.vim
@@ -65,10 +65,31 @@ nvim_lsp[lsp].setup { on_attach = on_attach }
end EOF +" golang imports setup (ugh, sorry) +lua <<EOF + -- … + + function go_org_imports(wait_ms) + local params = vim.lsp.util.make_range_params() + params.context = {only = {"source.organizeImports"}} + local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, wait_ms) + for cid, res in pairs(result or {}) do + for _, r in pairs(res.result or {}) do + if r.edit then + local enc = (vim.lsp.get_client_by_id(cid) or {}).offset_encoding or "utf-16" + vim.lsp.util.apply_workspace_edit(r.edit, enc) + end + end + end + end +EOF + +autocmd BufWritePre *.go lua go_org_imports() + " tabstops for my langs autocmd FileType sh setlocal et ts=4 sw=4 -autocmd FileType go setlocal noet ts=4 sw=4 autocmd FileType python setlocal et ts=4 sw=4 +autocmd FileType go setlocal noet ts=4 sw=4 autocmd FileType ruby setlocal et ts=2 sw=2 autocmd FileType terraform setlocal et ts=2 sw=2 autocmd FileType text setlocal tw=80