Skip to content

Commit

Permalink
feat: enable coc-go on go.work files
Browse files Browse the repository at this point in the history
fixes: #177
  • Loading branch information
josa42 committed Mar 27, 2022
1 parent fd6bbb0 commit 530a541
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"activationEvents": [
"onLanguage:go",
"onLanguage:gomod",
"onLanguage:gowork",
"onCommand:go.install.gomodifytags",
"onCommand:go.install.goplay",
"onCommand:go.install.gopls",
Expand Down
9 changes: 8 additions & 1 deletion scripts/nvim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." &> /dev/null && pwd)"
TMP="$DIR/.tmp"

# rm -rf $TMP
mkdir -p $TMP/{share/nvim,state,cache,config/nvim}
mkdir -p $TMP/{share/nvim,state,cache,config/nvim/syntax}

PLUGGED="$TMP/share/data/plugged"
PLUG_FILE="$TMP/share/nvim/site/autoload/plug.vim"
PLUG_URL='https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'

curl -sS 'https://raw.githubusercontent.com/fatih/vim-go/master/syntax/gowork.vim' > $TMP/config/nvim/syntax/gowork.vim

cat > $TMP/config/nvim/init.lua <<EOF
vim.cmd [[
call plug#begin('$PLUGGED')
Expand Down Expand Up @@ -54,6 +56,11 @@ function _G.__coc()
end
vim.opt.statusline = '%{v:lua.__coc()}'
vim.cmd [[
au BufRead,BufNewFile go.work.sum set filetype=gosum
au BufRead,BufNewFile go.work set filetype=gowork
]]
EOF

cat > $TMP/config/nvim/coc-settings.json <<EOF
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async function registerGopls(context: ExtensionContext): Promise<void> {

// https://github.com/neoclide/coc.nvim/blob/master/src/language-client/client.ts#L684
const clientOptions: LanguageClientOptions = {
documentSelector: ['go', 'gomod'],
documentSelector: ['go', 'gomod', 'gowork'],
initializationOptions: () => getConfig().goplsOptions,
disableWorkspaceFolders: config.disable.workspaceFolders,
disableDiagnostics: config.disable.diagnostics,
Expand Down

0 comments on commit 530a541

Please sign in to comment.