Comments (8)
Hmm, weird
It should have said csharp instead..
Can you go on a csharp file and print :lua print(vim.no.filetype)
?
from neogen.
Hello, indeed the new Neogen internals require the filename to be exactly the result of filetype, can you try it out ?
from neogen.
@danymat Late ping, sorry, was unsure whether this would go unnoticed as the issue is closed.
There seems to be another problem related to this.
I get the following error with the latest version:
E5108: Error executing lua /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:25: no parser for 'cs' language, see :help treesitter-parsers
stack traceback:
[C]: in function 'error'
/usr/share/nvim/runtime/lua/vim/treesitter/language.lua:25: in function 'require_language'
/usr/share/nvim/runtime/lua/vim/treesitter.lua:39: in function '_create_parser'
/usr/share/nvim/runtime/lua/vim/treesitter.lua:94: in function 'get_parser'
...m/site/pack/packer/start/neogen/lua/neogen/generator.lua:41: in function 'get_parent_node'
...m/site/pack/packer/start/neogen/lua/neogen/generator.lua:206: in function 'generate'
[string ":lua"]:1: in main chunk
So it correctly finds a configuration based on the cs
filetype. But it directly uses that to look up the TreeSitter parser - which is called c_sharp
.
Perhaps something has changed with vim.treesitter.get_parser
as used here:
neogen/lua/neogen/generator.lua
Line 41 in f249a70
Trying it out with lua print(vim.treesitter.get_parser(0, "c_sharp"))
I get a result, but not for lua print(vim.treesitter.get_parser(0, "cs"))
.
from neogen.
Hello, can you try again with latest commit ? 32adfde
from neogen.
Hello, can you try again with latest commit ? 32adfde
I did try renaming myself, but it only moved the problem, as it then cannot match the filetype with a neogen configuration:
E5108: Error executing lua ...m/site/pack/packer/start/neogen/lua/neogen/generator.lua:201: attempt to index field 'parent' (a nil value)
stack traceback:
...m/site/pack/packer/start/neogen/lua/neogen/generator.lua:201: in function 'generate'
[string ":lua"]:1: in main chunk
So, nvim filetype is cs
, while treesitter parser filetype is c_sharp
.
It works if I keep the keep the file named lua/neogen/configurations/cs.lua
and then do a simple mapping before getting the parser:
diff --git a/lua/neogen/generator.lua b/lua/neogen/generator.lua
index b762176..a4f2cc8 100644
--- a/lua/neogen/generator.lua
+++ b/lua/neogen/generator.lua
@@ -38,7 +38,8 @@ local function todo_text(type)
end
local function get_parent_node(filetype, typ, language)
- local parser = vim.treesitter.get_parser(0, filetype)
+ local parser_name = filetype == "cs" and "c_sharp" or filetype
+ local parser = vim.treesitter.get_parser(0, parser_name)
local tstree = parser:parse()[1]
local tree = tstree:root()
I do wonder how this worked earlier. Perhaps vim.treesitter.get_parser
has changed? It is a little unclear that its parameter filetype
refers to a name known to treesitter which does not necessarily correspond to the nvim filenameg.
from neogen.
Very weird, nvim-treesitter has likely changed the name in fact.
Do you want to create a PR for that (revert the file change, and apply the patch) ? I'm not at home at the moment, so i can not do it for the next hours
from neogen.
Very weird, nvim-treesitter has likely changed the name in fact. Do you want to create a PR for that (revert the file change, and apply the patch) ? I'm not at home at the moment, so i can not do it for the next hours
I'm using the patch locally for now, so no rush. I might do a PR if I can come up with a bit more generic way of handling the mapping from filetype to treesitters parser name.
from neogen.
@danymat I found out how to do the mapping and added a PR #89.
from neogen.
Related Issues (20)
- Feature Request - Support NeoVim native snippet engine HOT 2
- `Invalid 'end_col': out of range` error whenever running `Neogen file` HOT 2
- Bug: handling of arbitrary args and kwargs with type hints HOT 1
- Allow generating explicit sections HOT 3
- Update / Correction command HOT 2
- Python - raise module_name.Error() is not detected
- Bug: Neogen not functioning in vue files. HOT 2
- Could not get neogen to work with LazyVim HOT 4
- Need unittests HOT 1
- Missing blank line in numpydoc
- Option to always disable writing argument types in Python HOT 2
- FR: support creating annotations in Markdown code blocks HOT 1
- Sometimes native snippets do not expand on tab
- Add support for records in C# HOT 2
- Support annotating interfaces HOT 2
- Help implementing doctrings for Julia HOT 4
- Annotate all nodes in a file or ones from visual selection HOT 1
- Fix Python bugs
- Use Release Please to simplify neogen versioning
- Python: Should Raises be after Return in google style? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neogen.