nvim-html-css
nvim-html-css copied to clipboard
bug: not working with htmldjango
Neovim version (nvim -v)
NVIM v0.11.4
Error Message
Hi, I tried to fix the problem and now it's working for me. Because I couldn't test with all possibilities, I'm sending the diff of what I did to let you know. (I can't send the real diff because something changed my file formatting).
The file that I changed was: lua/html-css/source.lua
Proposed Code:
--To make Tree-sitter work, it needs to know if the file is html or htmldjango.
- local ext = vim.fn.expand("%:t:e")
- local ext = vim.bo.filetype
-- It is necessary to use ignore_injections = false as a parameter.
- local lang = isJSX and "javascript" or isTSX and "tsx" or "html"
- local node = vim.treesitter.get_node({ lang = lang })
- local lang = isJSX and "javascript" or isTSX and "tsx" or ext
- local node = vim.treesitter.get_node({ lang = lang, ignore_injections = false })
Steps To Reproduce
Open a django template file
Minimal Configuration
-- Paste your minimal init.lua or init.vim here
-- Only include what's necessary to reproduce the issue
NVIM v0.11.4
Build type: Release
LuaJIT 2.1.1741730670
Related Plugins
- [ ] nvim-cmp
- [x] blink.cmp
- [ ] Other (please specify in Additional Information)
Additional Information
No response
Hmm, strange for me it works perfectly fine, here is my minimal blink setup, also I have tested on nightly and on 0.11
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
error("Error cloning lazy.nvim:\n" .. out)
end
end ---@diagnostic disable-next-line: undefined-field
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
{
-- add blink.compat
{
"saghen/blink.compat",
-- use the latest release, via version = '*', if you also use the latest release for blink.cmp
version = "*",
-- lazy.nvim will automatically load the plugin when it's required by blink.cmp
lazy = true,
-- make sure to set opts so that lazy.nvim calls blink.compat's setup
opts = {},
},
{
"Saghen/blink.cmp",
-- optional: provides snippets for the snippet source
dependencies = {
"rafamadriz/friendly-snippets",
{ "L3MON4D3/LuaSnip", version = "v2.*" },
{
"stevearc/vim-vscode-snippets",
config = function()
require("luasnip.loaders.from_vscode").lazy_load()
require("luasnip.loaders.from_vscode").lazy_load({ paths = "./my_snippets" })
end,
},
},
-- use a release tag to download pre-built binaries
version = "1.*",
---@module 'blink.cmp'
---@type blink.cmp.Config
opts = {
sources = {
default = { "lsp", "path", "snippets", "html-css" },
providers = {
snippets = {
max_items = 10,
-- score_offset = 10,
},
buffer = {
max_items = 10,
},
["html-css"] = {
name = "html-css",
module = "blink.compat.source",
},
},
},
snippets = { preset = "luasnip" },
completion = {
list = {
selection = {
preselect = function(ctx)
return ctx.mode ~= "cmdline"
end,
auto_insert = false,
},
},
documentation = {
auto_show = true,
auto_show_delay_ms = 1,
},
},
},
opts_extend = { "sources.default" },
},
{
-- "Jezda1337/nvim-html-css",
-- dependencies = { "hrsh7th/nvim-cmp", "nvim-treesitter/nvim-treesitter" }, -- Use this if you're using nvim-cmp
dependencies = { "saghen/blink.cmp", "nvim-treesitter/nvim-treesitter" }, -- Use this if you're using blink.cmp
opts = {
enable_on = { -- Example file types
"html",
"htmldjango",
"tsx",
"jsx",
"erb",
"svelte",
"vue",
"blade",
"php",
"templ",
"astro",
},
handlers = {
definition = {
bind = "gd",
},
hover = {
bind = "K",
wrap = true,
border = "none",
position = "cursor",
},
},
documentation = {
auto_show = true,
},
style_sheets = {
"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css",
"https://cdnjs.cloudflare.com/ajax/libs/bulma/1.0.3/css/bulma.min.css",
},
},
},
},
})
could you test it with this mini blink example using -u flag? bdw do you have any errors?
Hi, you are right. It works for me too, but I still can't get my own configuration to work. I couldn't understand why... The line vim.treesitter.get_node({ lang = lang }) still returns a null node. Sorry for the time spent and the trouble.
@fabioml it would be great if you can share your config so i can take a closer look
@fabioml also you can try reinstalling tree-setter parsers, if you are on linux you can find them in ~/.local/share/nvim/lazy/nvim-treesitter/parser/html.so and css.so, you can remove that files and install it again using :TSInstall html css (if you using nvim-treesitter)
same issue
@GladioFeng can you provide min config? you have one in previous comments
I could not reproduce this without a minimal reproducible example. I posted one and you confirmed it works. Closing this issue as resolved. Reopen or submit a new issue if you can provide a reproducible case that still fails.