Skip to content

Commit 5e785bc

Browse files
committed
fix: vue를 위한 LSP 설정 및 문서화 #39 (#57)
1 parent 5b4ba10 commit 5e785bc

File tree

1 file changed

+42
-5
lines changed

1 file changed

+42
-5
lines changed

lua/plugins/lsp.lua

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ return {
1313
},
1414
config = function()
1515
require("mason").setup({})
16-
-- https://github.com/NvChad/NvChad/blob/e5f8a38ae3d6b3bedf68f29b0e96dad7a4ca2da5/lua/nvchad/plugins/init.lua
16+
-- https://github.com/NvChad/NvChad/blob/e5f8a38ae3d6b3bedf68f29b0e96dad7a4ca2da5/lua/nvchad/plugins/init.lua
1717
-- NvChad 레포에서 제공하는 MasonInstallAll 커맨드를 구현함
1818
-- 처음부터 확정 설치를 할수 없음 MasonInstallAll로 코드로 설정을 명시하게 됨
1919
local ensure_installed = {
@@ -33,7 +33,6 @@ return {
3333
vim.cmd("MasonInstall " .. table.concat(ensure_installed, " "))
3434
end
3535
end, { desc = "Mason Install All package" })
36-
3736
end,
3837
},
3938
{
@@ -82,9 +81,47 @@ return {
8281
})
8382

8483
-- JS & TS
85-
lspconfig.tsserver.setup({
86-
capabilities = capabilities,
87-
})
84+
85+
local secret = os.getenv("VUE_LSP_PATH")
86+
-- Version 2 stop working with nvim lsp
87+
-- https://github.com/vuejs/language-tools/issues/3925
88+
-- https://github.com/williamboman/mason-lspconfig.nvim/issues/371#issuecomment-1988153959
89+
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#volar
90+
-- npm install -g @vue/language-server # vue lsp를 전역으로 설치
91+
-- npm list -g # 이 명령으로 설치된 경로를 알아낼 수 있음
92+
-- .zshrc, bash, posh rc 파일에 설치한 @vue/language-server의 경로를 VUE_LSP_PATH에 설정할 것.
93+
-- VUE_LSP_PATH="명령으로_알아낸_설치_경로/node_modules/@vue/language-server"
94+
-- 모든 해결책이 소용없다면 다음 명령 활용
95+
-- :MasonInstall [email protected]
96+
if secret == nil then
97+
print("VUE LSP PATH not set")
98+
lspconfig.tsserver.setup({
99+
capabilities = capabilities,
100+
})
101+
else
102+
lspconfig.tsserver.setup({
103+
init_options = {
104+
plugins = {
105+
{
106+
name = "@vue/typescript-plugin",
107+
location = secret,
108+
languages = {
109+
"typescript",
110+
"javascript",
111+
"vue",
112+
},
113+
},
114+
},
115+
},
116+
filetypes = {
117+
"javascript",
118+
"typescript",
119+
"vue",
120+
},
121+
capabilities = capabilities,
122+
})
123+
end
124+
88125
lspconfig.marksman.setup({
89126
capabilities = capabilities,
90127
})

0 commit comments

Comments
 (0)