Skip to content

Commit

Permalink
Merge pull request #57 from aserowy/main
Browse files Browse the repository at this point in the history
Introduction of a simple plugin for nvim
  • Loading branch information
fdncred authored Jan 3, 2024
2 parents 958ccfb + 65a551d commit 23671f7
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 11 deletions.
35 changes: 24 additions & 11 deletions installation/neovim.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
> **Warning**
> This is probably more hands-on than many people will like, but I think that's
> just the state of things at the moment. There are superficially easier
> solutions, but I suspect you might be frustrated by outdated grammars
> resulting in wonky highlights.
>
> The instructions below will at least allow you to maintain your own highlights
> queries for things which you care about. This might result in better
> worst-case highlighting, which is my personal preference.
# neovim

## Lazy.nvim installation

Extend your lazy config with treesitter and the nu parser. The parser doesn't have to be listed under dependencies.

```lua
{
"nvim-treesitter/nvim-treesitter",
config = function()
-- setup treesitter with config
end,
dependencies = {
-- NOTE: additional parser
{ "nushell/tree-sitter-nu" },
},
build = ":TSUpdate",
},
```

## Manual installation

The ability to add syntax highlighting can be provided by [tree-sitter] using
[nvim-treesitter] (please refer to its own installation instructions).
Expand All @@ -26,7 +38,7 @@ parser_config.nu = {

Run `:TSInstall nu` in neovim to install the above parser.

> **Note**
> **Note**
> To get an overview of how [tree-sitter] is parsing [nushell] code, I recommend
> poking around with [nvim-treesitter/playground].
Expand All @@ -36,8 +48,9 @@ of highlight groups.

If you are using the `lazy` package manager for *neovim*, you can run the
following snippet to install the highlights file and enable the highlighting:

```nushell
let remote = "https://raw.githubusercontent.com/nushell/tree-sitter-nu/main/queries/"
let remote = "https://raw.githubusercontent.com/nushell/tree-sitter-nu/main/queries/nu/"
let local = (
$env.XDG_DATA_HOME?
| default ($env.HOME | path join ".local" "share")
Expand Down
15 changes: 15 additions & 0 deletions plugin/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
vim.filetype.add({ extension = { nu = "nu" } })

vim.api.nvim_create_autocmd("FileType", {
pattern = "nu",
callback = function(event) vim.bo[event.buf].commentstring = "# %s" end,
})

require("nvim-treesitter.parsers").get_parser_configs().nu = {
install_info = {
url = "https://github.com/nushell/tree-sitter-nu",
files = { "src/parser.c" },
branch = "main",
},
filetype = "nu",
}
File renamed without changes.
File renamed without changes.

0 comments on commit 23671f7

Please sign in to comment.