jinja-lsp starts but it can't find config file
The jinja-lsp starts up and looks good at first, but like others have mentioned, it doesn’t seem to provide the expected functionalities.
I’m testing it using the example folder in the jinja-lsp repository.
When I try to view available variables, it displays Backend variable, which could be a good sign but there is no syntax highlight and the functionalities from the README.md
I tried to use it with lsp-config but it shows the same result.
Please see the attached screenshots and the configuration file. Please let me know if I can provide any additional information.
- I’m also wondering if the project root for a Jinja project matters? I’ve noticed that if I don’t launch nvim from the examples folder, nothing is shown.
- Does it require the project dependencies to be installed, jinja?
My config:
-- vim.filetype.add {
-- extension = {
-- jinja = 'jinja',
-- jinja2 = 'jinja',
-- j2 = 'jinja',
-- },
-- }
-- require'lspconfig'.jinja_lsp.setup{
-- on_attach = on_attach,
-- capabilities = capabilities,
-- }
vim.filetype.add {
extension = {
jinja = 'jinja',
jinja2 = 'jinja',
j2 = 'jinja',
},
}
-- if you want to debug
vim.lsp.set_log_level("debug")
local nvim_lsp = require('lspconfig')
local configs = require('lspconfig.configs')
if not configs.jinja_lsp then
configs.jinja_lsp = {
default_config = {
name = "jinja-lsp",
cmd = { '/home/balazser/.cargo/bin/jinja-lsp' },
filetypes = { 'jinja', 'rust' },
root_dir = function(fname)
return "."
--return nvim_lsp.util.find_git_ancestor(fname)
end,
init_options = {
templates = './templates',
backend = { './src' },
lang = "python"
},
},
}
end
-- local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
nvim_lsp.jinja_lsp.setup {
on_attach = on_attach,
capabilities = capabilities
}
-- nvim_lsp.jinja_lsp.setup { }
end,
I could make it work for the exmaple project but I still lack of syntax highlighting. I can see that in the README syntax highlighting is mentioned. is this provided by jinja-lsp or an external package like treesitter etc?
Also should it support a single file? It seems opening a single .jinja file makes this plugin fail silently.
thank you!
I will try to run it inside Neovim this week. For syntax highlighting I use tree-sitter-jinja2.
Thank you. Also I'm not sure if it picks up the config file if it's not defined in nvim. And even if it's defined then should the local one overwrite it? I can see this in the lsplogs the following messages and having a broken lsp
[WARN][2025-03-18 22:30:40] ...lsp/handlers.lua:625 "Config doesn't exist."
[WARN][2025-03-18 22:30:40] ...lsp/handlers.lua:625 "Template directory not found"
[WARN][2025-03-18 22:30:40] ...lsp/handlers.lua:625 "Backend language not supported"
although I'm having the config in the CWD
[jinja-lsp]
templates = "./templates"
backend = ["./src"]
lang = "python"
I’m also wondering if the project root for a Jinja project matters?
Yes.
Does it require the project dependencies to be installed, jinja?
No.
Here it works for Neovim, version is v0.10.0. Which version of Neovim do you have?
I use 0.10 nvim as well.
NVIM v0.10.4
Build type: Release
LuaJIT 2.1.1736781742
Run "nvim -V1 -v" for more info
Also I'm wondering if jinja-lsp picks up the config from the pyproject.toml or jinja-lsp.toml. 🤔 I can see in the logs for me it does not really want to do that from any of them.
Maybe we could add a log to see where config is initialized?
Thank you. Also I'm not sure if it picks up the config file if it's not defined in nvim. And even if it's defined then should the local one overwrite it? I can see this in the lsplogs the following messages and having a broken lsp
[WARN][2025-03-18 22:30:40] ...lsp/handlers.lua:625 "Config doesn't exist." [WARN][2025-03-18 22:30:40] ...lsp/handlers.lua:625 "Template directory not found" [WARN][2025-03-18 22:30:40] ...lsp/handlers.lua:625 "Backend language not supported"although I'm having the config in the CWD
[jinja-lsp] templates = "./templates" backend = ["./src"] lang = "python"