LhKipp / nvim-nu

Basic editor support for the nushell language
GNU General Public License v3.0
141 stars 11 forks source link

Setup help? #8

Closed rudolphpienaar closed 1 year ago

rudolphpienaar commented 1 year ago

Greetings! I came across your repo while looking for syntax highlighting for nushell scripts. Looks like this would completely fit my need. I am a (n)vim user but lua/lisp newbie -- using latest nvim on arch Linux. I have added the plugin to my init.vim and as far as I can tell, the plugin is installed.

Plug 'LhKipp/nvim-nu', {'do':  ':TSIntall nu'}

However, I managed to get completely bedeviled at the most frustrating of steps. You explicitly remind the user to run:

require'nu'.setup{}

with a script (lua?) at the configuration. Goodness? What is this? Where/how do I run this?

For the life of me I couldn't get this figured out. I tried to a nu.lua script with the configuration text in my ~/.config/nvim/lua directory -- which just resulted in startup syntax errors when I open vim. Would you perhaps place some expllciti instructions in the README?

I would really love to have nushell syntax highlighting in nvim.

Any help would be most appreciated!

petrisch commented 1 year ago

This is really just what you have to do. For me this works, at least kind of. Filetypes with .nu get detected. For syntax highlight you need to add treesitter and install the grammar for it. But keep in mind that nushell is quite new and they work on a new grammar. The one that is linked with this plugin is somehow outdated with latest nushell. The new gramar is here, but WIP: https://github.com/nushell/tree-sitter-nu

rudolphpienaar commented 1 year ago

Thanks for the reply. It seemed in my case as if this file ~/.vim/plugged/nvim-nu/ftplugin/nu.lua was causing startup errors. I simply commented out its contents and then added your configuration code in ~/.config/nvim/lua/nu.lua. I followed the above tree-sitter-nu and installed :TSInstall nu which worked with no errors.

When I open a .nu file I get no errors, but also no syntax highlighting. I don't quite know how to run your lua configuration, but I assume it is read on startup? I naively tried :lua require'nu'.setup{} which simply generated errors.

I might keep plugging at this. Thanks again for getting the ball rolling on this and also your help!

petrisch commented 1 year ago

Hi yeah so I haven't myself set this up properly because as you can see it is pretty much WIP. If you have an older version of nu, you can just go with the instructions on this repo.

If you are on 0.79, where they changed alot of the syntax in nu, then this grammar will likely give errors. Then you should go with the grammar from the other repo I mentioned above.

However afaik they don't handle filetype and highlighting just yet. And it is just the grammar. So on my home-test- machine I do this atm:

That sort of worked last week, but again, it can brak any time and is not the way to go in the long run.

rudolphpienaar commented 1 year ago

Got it... I tried running :lua require'nu'.setup{} once I fired up nvim and I get

E5108: Error executing lua /home/rudolph/.config/nvim/lua/nu.lua:1: loop or previous error loading module 'nu'
stack traceback:
        [C]: in function 'require'
        /home/rudolph/.config/nvim/lua/nu.lua:1: in main chunk
        [C]: in function 'require'
        [string ":lua"]:1: in main chunk

Not being a lua expert I'm not sure what to make of that. Also it seems pretty unhelpful an error message!

LhKipp commented 1 year ago

Hi @rudolphpienaar ,

please undo anything you've done so far and follow these steps:

  1. Add nvim-nu via your plugin manager (e.G.: Plug 'LhKipp/nvim-nu', {'do': ':TSInstall nu'})
  2. Create the file /home/rudolph/.config/nvim/plugin/this_file_gets_run_once_nvim_starts.lua
  3. Put the following piece of code into the file created in step 2: require("nu").setup({})

You are welcome