`emmet-expand-abbr` fails in `getFileType` when there is no treesitter syntax (`E701: Invalid type for len()`)
Nobody has claimed this yet.
- Dominant language
- Vim Script
- Stars
- 6.5k
- Forks
- 414
- PR merge metrics
- No merged PRs in 30d
Description
getFileType contains this piece of code:
if get(g:, 'loaded_nvim_treesitter', 0)
let type = luaeval('require"emmet_utils".get_node_at_cursor()')
" […]
However the assumptions here are flawed. g:loaded_nvim_treesitter is v:true, even if there is no treesitter parser or grammar for the current filetype. Thus type gets set to v:null in files with only regex syntax highlighting. This then causes an error later down the line when trying to call len(type). There needs to be an alternative or more thorough check, that treesitter actually returns a file type.
The error is: E701: Invalid type for len()
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at getFileType, which is used by emmet-expand-abbr, and inspect the result of emmet_utils.get_node_at_cursor() when no Tree-sitter parser or grammar exists. Reproduce the issue in a filetype using regex syntax highlighting and verify that the resulting file-type handling no longer passes v:null to len().
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua, vim
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100