LiadOz / nvim-dap-repl-highlights

Add syntax highlighting to the nvim-dap REPL
110 stars 6 forks source link

Add nvim-treesitter filetype-lang parser lookup #5

Closed tkf144 closed 3 months ago

tkf144 commented 1 year ago

Hi @LiadOz

Thanks for the plugin.

I was working around a difference in the C# filetype (cs) and the corresponding TS parser name (c_sharp) when I came across this ft_to_lang map function provided by nvim-treesitter.parsers. I thought it might be useful to add to the plugin, behind the existing repl_lang option in priority, as a way to translate between filetypes and TS parser names without requiring explicit setting of repl_lang.

I don't have any Neovim plugin development experience so I've just dropped the relevant function in where it seems appropriate to illustrate how it might work - but it's an untested best guess.

Hope you find it useful.

LiadOz commented 1 year ago

ft_to_lang seems to raise an exception when nil is passed to it, could you add a guard around it? Also it seems that when given a string, ft_to_lang will return that string if it doesn't find a language, so there is no need to keep the or session.filetype at the end.

LiadOz commented 3 months ago

Resolved in #13