all repos — dotfiles @ 37f5a15a764b8baf8ba8d9b2b8ba767624b1a154

my *nix dotfiles

nvim/ftplugin/go.vim (view raw)

 1setlocal noexpandtab
 2setlocal autoindent
 3setlocal shiftwidth=4
 4setlocal smarttab
 5setlocal formatoptions=croql
 6setlocal tabstop=4
 7
 8
 9lua <<EOF
10    function org_imports(wait_ms)
11      local params = vim.lsp.util.make_range_params()
12      params.context = {only = {"source.organizeImports"}}
13      local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, wait_ms)
14      for _, res in pairs(result or {}) do
15        for _, r in pairs(res.result or {}) do
16          if r.edit then
17            vim.lsp.util.apply_workspace_edit(r.edit, "utf-16")
18          else
19            vim.lsp.buf.execute_command(r.command)
20          end
21        end
22      end
23  end
24EOF
25
26augroup go_lsp
27    autocmd!
28    autocmd BufWritePre *.go :silent! lua vim.lsp.buf.format()
29    autocmd BufWritePre *.go :silent! lua org_imports(3000)
30augroup END