move ftdetect/ftplugin around; gomod detecting

pull/282/head
ray-x 1 year ago
parent bd9caf8d0e
commit 3a853d50af

@ -9,6 +9,7 @@ au BufRead,BufNewFile go.work.sum set filetype=gosum
au BufRead,BufNewFile go.work set filetype=gowork
au! BufRead,BufNewFile *.mod,*.MOD
au BufRead,BufNewFile *.mod,*.MOD set filetype=gomod
let &cpo = s:cpo_save

@ -1,17 +0,0 @@
let s:cpo_save = &cpo
set cpo&vim
au BufRead,BufNewFile *.go setfiletype go
au BufRead,BufNewFile *.s setfiletype asm
au BufRead,BufNewFile *.tmpl set filetype=gohtmltmpl
au BufRead,BufNewFile go.sum set filetype=gosum
au BufRead,BufNewFile go.work.sum set filetype=gosum
au BufRead,BufNewFile go.work set filetype=gowork
au! BufRead,BufNewFile *.mod,*.MOD
let &cpo = s:cpo_save
unlet s:cpo_save
" vim: sw=2 ts=2 et

@ -0,0 +1,16 @@
let s:cpo_save = &cpo
set cpo&vim
let &cpo = s:cpo_save
unlet s:cpo_save
setlocal formatoptions-=t
setlocal comments=s1:/*,mb:*,ex:*/,://
setlocal commentstring=//\ %s
setlocal noexpandtab
compiler go
" vim: sw=2 ts=2 et

@ -51,7 +51,6 @@ end
for _, value in ipairs(gopls_cmds) do
local fname = string.sub(value, #'gopls.' + 1)
cmds[fname] = function(arg)
log(fname)
local b = vim.api.nvim_get_current_buf()
local uri = vim.uri_from_bufnr(b)
local arguments = { { URI = uri } }
@ -62,6 +61,7 @@ for _, value in ipairs(gopls_cmds) do
end
arguments = { vim.tbl_extend('keep', arguments[1], arg or {}) }
log(fname, arguments)
if vim.tbl_contains(gopls_with_result, value) then
local resp = vim.lsp.buf_request_sync(b, 'workspace/executeCommand', {
command = value,

@ -15,6 +15,9 @@ function M.run(...)
end)
end,
}
if vim.fn.expand('%:t'):find('go.mod') then
opts.cwd = vim.fn.expand('%:p:h')
end
runner.run(cmd, opts)
end

Loading…
Cancel
Save