-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nvim-html-css
doesn't load when used with nVim v0.10.0
#1
Comments
Hi @savchenko
Thank you for the feedback!
I've handled the nil values for `self.option.enable_on` and
`vim.bo.filetype` to prevent errors when these values are empty.
Additionally, based on your suggestions, here's how to configure the
`option` settings in `lazy.nvim` to ensure all desired filetypes are set.
Currently, it supports `html`, `htmldjango`, `php`, and
`enable_file_patterns` (if not `.html`, like `.php`, please include it in
`file_extensions`). Although it currently only detects `css`, this
configuration ensures `TSInstall` works correctly with the `html-css`
filetype.
Please make sure to run `TSInstall html` and `TSInstall css` to enable the
Treesitter syntax trees for the required filetypes. Without this step,
`html-css` completion for the specified filetypes will not work.
Additionally, ensure that `enable_on`, `enable_file_patterns`, and
`file_extensions` are not empty in your configuration. The plugin will not
function correctly if these values are missing.
```lua
{
"hrsh7th/nvim-cmp",
opts = {
sources = {
-- other sources
{
name = "html-css",
option = {
enable_on = {
"htmldjango",
"html",
"php"
}, -- set the file
types you want the plugin to work on
enable_file_patterns = { "*.html" }, -- set the file patterns you
want the plugin to work on (default is *.html)
-- enable_file_patterns = { "*.html", "*.php" }
file_extensions = { "css", "sass", "less" }, -- set the local
filetypes from which you want to derive classes
style_sheets = {
-- example of remote styles, only css no js for now
"
***@***.***/dist/css/bootstrap.min.css",
***@***.***/css/bulma.min.css",
}
}
},
},
},
}
---
If you are using other Neovim distributions like lunavim or lazyvim,
please find the corresponding configuration API for cmp. For example, with
lunarvim (confirmed with the latest version and Neovim 10), you can use:
---
table.insert(lvim.builtin.cmp.sources, 1, {
name = "html-css",
priority = 10,
option = {
max_count = {}, -- not ready yet
enable_on = {
"htmldjango",
"html",
"php",
}, -- set the file types you
want the plugin to work on
enable_file_patterns = { "*.html", "*.php" }, -- set the file patterns
you want the plugin to work on
file_extensions = { "css", "sass", "less" }, -- set the local
filetypes from which you want to derive classes
-- style_sheets = {
-- example of remote styles, only css no js for now
-- "
***@***.***/dist/css/bootstrap.min.css",
-- ***@***.***/css/bulma.min.css",
-- }
}
})
---
Also, this cmp source dynamically adds completion sources based on the link
src in the HTML or the extends template in htmldjango, which is a
consideration for performance. Therefore, if the HTML doesn't link to any
src, it will only complete the CSS inside the style tag.
If you have any questions, feel free to ask. I have reopened the issue.
Thank you!
savchenko ***@***.***> 於 2024年6月9日 週日 上午10:37寫道:
Sorry for creating this in the wrong repo, but the *"Issues"* section is
disabled at ESSO0428/nvim-html-css
<https://github.com/ESSO0428/nvim-html-css>.
This check
<https://github.com/ESSO0428/nvim-html-css/blob/8e797fedbfeeecce56a67156f097ab44a8f91d26/lua/html-css/init.lua#L327>
:
if not vim.tbl_contains(self.option.enable_on, vim.bo.filetype) then
Fails with:
Error executing vim.schedule lua callback: vim/shared.lua:0: t: expected table, got nil
stack traceback:
[C]: in function 'error'
vim/shared.lua: in function 'validate'
vim/shared.lua: in function 'tbl_contains'
...ocal/share/nvim/lazy/nvim-html-css/lua/html-css/init.lua:327: in function ''
vim/_editor.lua: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
Plugin is installed with default settings, nvim-cmp source added.
—
Reply to this email directly, view it on GitHub
<#1>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWFQI5SV5CRSHCNW7U3UJVDZGO5XNAVCNFSM6AAAAABJAPNCZGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGM2DCOJYGQ4TCOA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
savchenko ***@***.***> 於 2024年6月9日 週日 上午10:37寫道:
… Sorry for creating this in the wrong repo, but the *"Issues"* section is
disabled at ESSO0428/nvim-html-css
<https://github.com/ESSO0428/nvim-html-css>.
This check
<https://github.com/ESSO0428/nvim-html-css/blob/8e797fedbfeeecce56a67156f097ab44a8f91d26/lua/html-css/init.lua#L327>
:
if not vim.tbl_contains(self.option.enable_on, vim.bo.filetype) then
Fails with:
Error executing vim.schedule lua callback: vim/shared.lua:0: t: expected table, got nil
stack traceback:
[C]: in function 'error'
vim/shared.lua: in function 'validate'
vim/shared.lua: in function 'tbl_contains'
...ocal/share/nvim/lazy/nvim-html-css/lua/html-css/init.lua:327: in function ''
vim/_editor.lua: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
Plugin is installed with default settings, nvim-cmp source added.
—
Reply to this email directly, view it on GitHub
<#1>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWFQI5SV5CRSHCNW7U3UJVDZGO5XNAVCNFSM6AAAAABJAPNCZGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGM2DCOJYGQ4TCOA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Since I haven't received any further responses after my last reply, I'll go ahead and close this issue for now. If you have any additional questions or need further assistance, please feel free to reopen it. Thank you for your understanding and support! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
EDIT
I think this is happening because the plugin loads prematurely. I can manually get
user_config
via Lua oncecmp
has loaded without any issues.Adding
nvim-cmp
as the dependency ofnvim-html-css
makes it load successfully, but thecmp
source is still unavailable:ORIGINAL MESSAGE
Sorry for creating this in the wrong repo, but the "Issues" section is disabled at ESSO0428/nvim-html-css.
This check:
Fails with:
Plugin is installed with default settings,
nvim-cmp
source added. Here is the content ofself
at the time:...and the relevant snippet from
cmp
config:The text was updated successfully, but these errors were encountered: