Glint V2 LSP Configuration for Neovim
I have already migrated from V1 to V2 and the Glint V2 plugin for VSCode works nice, however when I'm trying to implement it to other editors like neovim or helix the LSP doesn't respond. There are no LSP Definitions, no Hovers, no Auto-completion, nothing.
The LSP setup for neovim I'm using is simply:
cmd = { "glint-language-server", "--stdio" },
init_options = {
glint = {
useGlobal = true,
},
},
For helix:
[language-server.ember-language-server]
command = "glint-language-server"
args = ["--stdio"]
I noticed that the VSCode plugin uses the NodeIPC instead, so perhaps the stdio isn't working as expected? Thanks.
I haven't had time to upstream this yet (to the nvim/mason repos), but here is how I configured glint2:
https://github.com/NullVoxPopuli/dotfiles/blob/065fa7e8014aa825092b8c86666c77c5b65e0de5/home/.config/nvim/lua/plugin-config/lsp/typescript.lua#L1
local utils = require('plugin-config.lsp.utils')
local filetypes = {
'typescript',
'javascript',
'typescript.glimmer',
'javascript.glimmer',
'typescript.tsx',
'javascript.jsx',
'html.handlebars',
'handlebars',
}
-- https://neovim.io/doc/user/lsp.html
vim.lsp.config('ts_ls', {
-- This allows us to switch types of TSServers based on the open file.
-- We don't always need the @glint/tsserver-plugin -- for example, in backend projects.
root_dir = utils.is_ts_project,
settings = {
hostInfo = "neovim native TS LS",
maxTsServerMemory = 8000,
-- implicitProjectConfig = {
-- experimentalDecorators = true
-- },
disableAutomaticTypingAcquisition = true,
importModuleSpecifierPreference = "relative",
importModuleSpecifierEnding = "minimal",
},
init_options = {
-- tsserver = { logVerbosity = 'verbose', trace = "verbose" },
preferences = {
disableAutomaticTypingAcquisition = true,
importModuleSpecifierPreference = "relative",
importModuleSpecifierEnding = "minimal",
},
plugins = {
-- All plugins need to be defined here,
-- even if we have to change the location later
{
name = "@glint/tsserver-plugin",
location = "/your/path/to/@glint/tsserver-plugin",
languages = filetypes
},
},
},
filetypes = filetypes,
on_new_config = function(new_config, new_root_dir)
local info = utils.read_nearest_ts_config(new_root_dir)
local glintPlugin = new_root_dir .. "node_modules/@glint/tsserver-plugin"
if new_config.init_options then
if (info.isGlintPlugin) then
new_config.init_options.plugins = {
{
name = "@glint/tsserver-plugin",
location = glintPlugin,
languages = filetypes,
enableForWorkspaceTypeScriptVersions = true,
configNamespace = "typescript"
}
}
end
end
end,
})
vim.lsp.config('glint', {
root_dir = utils.is_glint_project,
})
vim.lsp.enable('ts_ls')
vim.lsp.enable('glint')
I've packaged all of this into a plugin for neovim: https://github.com/nullvoxpopuli/ember.nvim which should actually get folks a better experience out of the box with less work than vscode now.
The important file if you don't want to use this plugin and manage your own config is here: https://github.com/NullVoxPopuli/ember.nvim/blob/main/lua/ember/lsp/typescript.lua