Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local util = require 'lspconfig.util'
- local async = require 'lspconfig.async'
- local mod_cache = nil
- vim.lsp.start({
- name = "gopls",
- cmd = { "path/to/yout/gopls/executable" },
- root_dir = function(fname)
- if not mod_cache then
- local result = async.run_command { 'go', 'env', 'GOMODCACHE' }
- if result and result[1] then
- mod_cache = vim.trim(result[1])
- end
- end
- if fname:sub(1, #mod_cache) == mod_cache then
- local clients = vim.lsp.get_active_clients { name = 'gopls' }
- if #clients > 0 then
- return clients[#clients].config.root_dir
- end
- end
- return util.root_pattern('go.work', 'go.mod', '.git')(fname)
- end,
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement