Skip to content

Commit

Permalink
feat(nvim): introduce efm-langserver and prettierd
Browse files Browse the repository at this point in the history
  • Loading branch information
tosuke committed Jan 4, 2024
1 parent 595fa3c commit 1546ffc
Show file tree
Hide file tree
Showing 5 changed files with 503 additions and 4 deletions.
2 changes: 2 additions & 0 deletions dot_config/aquaproj-aqua/aqua.yaml
Expand Up @@ -19,6 +19,8 @@ packages:
- name: kubernetes/kubectl@v1.29.0
- name: int128/kubelogin@v1.28.0
- name: stern/stern@v1.27.0
# LSP
- name: mattn/efm-langserver@v0.0.49
# Terraform
- name: tfutils/tfenv@v3.0.0
- name: hashicorp/terraform-ls@v0.32.4
Expand Down
48 changes: 48 additions & 0 deletions dot_config/efm-langserver/config.yaml
@@ -0,0 +1,48 @@
version: 2
root-markers:
- .git/
- package.json
lint-debounce: 1s

tools:
prettierd: &prettierd
format-command: "prettierd \"${INPUT}\""
format-stdin: true
# Go
gofmt: &gofmt
format-command: "gofmt"
format-stdin: true
root-markers:
- go.mod
- go.sum
goimports: &goimports
format-command: "goimports"
format-stdin: true
root-markers:
- go.mod
- go.sum
languages:
go:
- <<: *gofmt
- <<: *goimports
# web
html:
- <<: *prettierd
markdown:
- <<: *prettierd
javascript:
- <<: *prettierd
javascriptreact:
- <<: *prettierd
typescript:
- <<: *prettierd
typescriptreact:
- <<: *prettierd
# config
json:
- <<: *prettierd
jsonc:
- <<: *prettierd
yaml:
- <<: *prettierd

50 changes: 46 additions & 4 deletions dot_config/nvim/lua/plugins.lua
Expand Up @@ -451,9 +451,51 @@ local plugins = {
setup(conf)
end

local function disable_format(config)
return function(spec, c)
local conf = {}
if type(config) == 'function' then
conf = config(spec, c)
else
conf = config
end
if conf.capabilities == nil then
conf.capabilities = vim.lsp.protocol.make_client_capabilities()
end
conf.capabilities.documentFormattingProvider = false
conf.capabilities.documentRangeFormattingProvider = false
return conf
end
end

-- efm
setup_lsp(lspcfg.efm.setup, {
init_options = {
documentFormatting = true,
rangeFormatting = true,
hover = true,
documentSymbol = true,
codeAction = true,
completion = true,
},
filetypes = {
'go',
-- config
'json',
'jsonc',
'yaml',
-- web
'html',
'markdown',
'javascript',
'javascriptreact',
'typescript',
'typescriptreact',
},
})

-- Go
setup_lsp(lspcfg.gopls.setup, {})
table.insert(nsources, null_ls.builtins.formatting.goimports)
setup_lsp(lspcfg.gopls.setup, disable_format({}))

-- Rust
setup_lsp(lspcfg.rust_analyzer.setup, {})
Expand All @@ -466,7 +508,7 @@ local plugins = {
setup_lsp(lspcfg.lua_ls.setup, {})

-- json
setup_lsp(lspcfg.jsonls.setup, function(_, config)
setup_lsp(lspcfg.jsonls.setup, disable_format(function(_, config)
config.capabilities.textDocument.completion.completionItem.snippetSupport = true
config.settings = {
json = {
Expand All @@ -475,7 +517,7 @@ local plugins = {
}
}
return config
end)
end))

-- shell
table.insert(nsources, null_ls.builtins.code_actions.shellcheck)
Expand Down
1 change: 1 addition & 0 deletions dot_config/nvim/lua/tools/node/package.json
Expand Up @@ -3,6 +3,7 @@
"type": "module",
"packageManager": "pnpm@8.14.0",
"dependencies": {
"@fsouza/prettierd": "^0.25.2",
"vscode-langservers-extracted": "^4.8.0"
}
}

0 comments on commit 1546ffc

Please sign in to comment.