Skip to content

Commit

Permalink
update!: queries & cleanup
Browse files Browse the repository at this point in the history
Synced the queries with the queries in nvim-treesitter and removed the Neovim plugin and Nix files.
  • Loading branch information
luckasRanarison committed Feb 10, 2024
1 parent e60fc85 commit d3954af
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 247 deletions.
77 changes: 1 addition & 76 deletions README.md
Expand Up @@ -4,82 +4,7 @@

## Neovim

To actually use it in Neovim and get syntax highlighting, folds, smart indent, and automatic file detection, you can use the repository as a plugin by installing it with your package manager. Then, install the grammar with `:TSInstall hyprlang`.

### Lazy

```lua
return {
"luckasRanarison/tree-sitter-hyprlang",
dependencies = { "nvim-treesitter/nvim-treesitter" },
}
```

### Packer

```lua
use {
"luckasRanarison/tree-sitter-hyprlang",
requires = { "nvim-treesitter/nvim-treesitter" },
}
```

### Nix as flake

Add the flake and use it as `vimPlugin` within e.g. your home manager configuration for neovim.

```nix
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
tree-sitter-hyprlang = {
url = "github:luckasRanarison/tree-sitter-hyprlang";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
nixpkgs,
home-manager,
tree-sitter-hyprlang,
...
}: {
homeConfigurations."user@hostname" = let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
in
home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
{
programs.neovim = {
enable = true;
plugins = with pkgs.vimPlugins; [
tree-sitter-hyprlang.packages.${pkgs.system}.default
{
plugin = nvim-treesitter.withAllGrammars;
type = "lua";
config = ''
require('nvim-treesitter.configs').setup({
highlight = { enable = true }
})
'';
}
];
};
}
# ...
];
};
};
}
```

### Filetype detection

hyprlang does not have a specific filetype extension. Thus, we detect `.conf` with a path pattern. If your configuration does not get initialized as filetype `hyprlang` you can set it locally with `:set filetype=hyprlang` or add another pattern for type detection to your config. The following snippet resolves files with name `hyprland.conf` and sets `hyprlang` as filetype.
You can install the hyprlang parser in neovim using [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) and use the following code snippet for automatic filetype detection:

```lua
vim.filetype.add({
Expand Down
61 changes: 0 additions & 61 deletions flake.lock

This file was deleted.

53 changes: 0 additions & 53 deletions flake.nix

This file was deleted.

17 changes: 0 additions & 17 deletions plugin/init.lua

This file was deleted.

4 changes: 1 addition & 3 deletions queries/hyprlang/folds.scm
@@ -1,3 +1 @@
[
(section)
] @fold
(section) @fold
55 changes: 23 additions & 32 deletions queries/hyprlang/highlights.scm
@@ -1,57 +1,48 @@
(comment) @comment
(comment) @comment @spell

(source "source" @keyword)

(exec "exec" @keyword)
(exec "exec-once" @keyword)
[
"source"
"exec"
"exec-once"
] @keyword

(keyword
(name) @keyword
)
(name) @keyword)

(assignment
(name) @property
)
(name) @property)

(section
(name) @namespace
)
(name) @module)

(section
device: (device_name) @type
)
device: (device_name) @type)

(variable) @variable
(variable "$" @punctuation.special)

(number) @number
"$" @punctuation.special

(boolean) @boolean

(mod) @constant

(vec2
(number) @number
(number) @number
)

[
"rgb"
[
"rgb"
"rgba"
] @function
] @function.builtin

(color
(legacy_hex) @number
)

(angle) @number
(angle "deg" @type)
[
(number)
(legacy_hex)
(angle)
(hex)
] @number

(hex) @number
"deg" @type

[ "," ] @punctuation
"," @punctuation.delimiter

[
[
"("
")"
"{"
Expand Down
9 changes: 4 additions & 5 deletions queries/hyprlang/indents.scm
@@ -1,7 +1,6 @@
[
(section)
] @indent.begin
(section) @indent.begin

(section "}" @indent.end)
(section
"}" @indent.end)

[ "}" ] @indent.branch
"}" @indent.branch

0 comments on commit d3954af

Please sign in to comment.