feat(neovim): add hypr grammar
This commit is contained in:
parent
acc2d647f7
commit
ced46f834d
3 changed files with 194 additions and 91 deletions
|
@ -4,14 +4,22 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
# installs a vim plugin from git with a given tag / branch
|
# installs a vim plugin from git with a given tag / branch
|
||||||
plugin = owner: repo: rev: hash:
|
plugin = src:
|
||||||
pkgs.vimUtils.buildVimPlugin {
|
pkgs.vimUtils.buildVimPlugin {
|
||||||
pname = "${lib.strings.sanitizeDerivationName repo}";
|
pname = "${lib.strings.sanitizeDerivationName src.repo}";
|
||||||
version = rev;
|
version = src.rev;
|
||||||
src = pkgs.fetchFromGitHub {
|
inherit src;
|
||||||
inherit rev owner repo hash;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
buildGrammar = name: grammar:
|
||||||
|
pkgs.callPackage ./grammar.nix {} {
|
||||||
|
language = grammar.language or name;
|
||||||
|
version = grammar.src.rev;
|
||||||
|
src = grammar.src;
|
||||||
|
location = grammar.location or null;
|
||||||
|
generate = grammar.generate or false;
|
||||||
};
|
};
|
||||||
|
|
||||||
fileContents = lib.strings.fileContents;
|
fileContents = lib.strings.fileContents;
|
||||||
in {
|
in {
|
||||||
# TODO: make a gradle module and have java in device-vars.nix
|
# TODO: make a gradle module and have java in device-vars.nix
|
||||||
|
@ -48,6 +56,7 @@ in {
|
||||||
nodePackages.npm
|
nodePackages.npm
|
||||||
nodePackages.neovim
|
nodePackages.neovim
|
||||||
gradle
|
gradle
|
||||||
|
gcc
|
||||||
|
|
||||||
bat
|
bat
|
||||||
|
|
||||||
|
@ -134,7 +143,30 @@ in {
|
||||||
extraConfig = fileContents ./base.vim;
|
extraConfig = fileContents ./base.vim;
|
||||||
extraLuaConfig = fileContents ./base.lua;
|
extraLuaConfig = fileContents ./base.lua;
|
||||||
|
|
||||||
plugins = with pkgs.vimPlugins; [
|
plugins = let
|
||||||
|
# custom packages
|
||||||
|
hypr-src = pkgs.fetchFromGitHub {
|
||||||
|
owner = "luckasRanarison";
|
||||||
|
repo = "tree-sitter-hypr";
|
||||||
|
rev = "90b3ddf8a85b5ea3d9dc4920fddb16182a192e14";
|
||||||
|
hash = "sha256-ErFs2eCC0eZEyDldrTUj4JJ0Eu+exDHNQx4g8WXh/UQ=";
|
||||||
|
};
|
||||||
|
|
||||||
|
tree-sitter-hypr = plugin hypr-src;
|
||||||
|
|
||||||
|
hypr-grammar = buildGrammar "hypr" {
|
||||||
|
src = hypr-src;
|
||||||
|
generate = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
indent-blankline = plugin (pkgs.fetchFromGitHub {
|
||||||
|
owner = "lukas-reineke";
|
||||||
|
repo = "indent-blankline.nvim";
|
||||||
|
rev = "046e2cf04e08ece927bacbfb87c5b35c0b636546";
|
||||||
|
hash = "sha256-bhoep8aTYje5K/dZ/XmpwBPn4PBEMPrmw33QJdfFe6M=";
|
||||||
|
});
|
||||||
|
in
|
||||||
|
with pkgs.vimPlugins; [
|
||||||
# Coc configured
|
# Coc configured
|
||||||
coc-css
|
coc-css
|
||||||
coc-eslint
|
coc-eslint
|
||||||
|
@ -193,16 +225,20 @@ in {
|
||||||
}
|
}
|
||||||
nvim-treesitter-context
|
nvim-treesitter-context
|
||||||
nvim-treesitter-textobjects
|
nvim-treesitter-textobjects
|
||||||
|
{
|
||||||
|
plugin = tree-sitter-hypr;
|
||||||
|
type = "lua";
|
||||||
|
config = ''
|
||||||
|
vim.treesitter.language.require_language("hypr", "${hypr-grammar}/parser")
|
||||||
|
'';
|
||||||
|
}
|
||||||
{
|
{
|
||||||
plugin = nvim-treesitter.withAllGrammars;
|
plugin = nvim-treesitter.withAllGrammars;
|
||||||
type = "viml";
|
type = "viml";
|
||||||
config = fileContents ./plugins/treesitter.vim;
|
config = fileContents ./plugins/treesitter.vim;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
plugin =
|
plugin = indent-blankline;
|
||||||
plugin "lukas-reineke" "indent-blankline.nvim"
|
|
||||||
"046e2cf04e08ece927bacbfb87c5b35c0b636546"
|
|
||||||
"sha256-bhoep8aTYje5K/dZ/XmpwBPn4PBEMPrmw33QJdfFe6M=";
|
|
||||||
type = "lua";
|
type = "lua";
|
||||||
config = fileContents ./plugins/indent.lua;
|
config = fileContents ./plugins/indent.lua;
|
||||||
}
|
}
|
||||||
|
|
62
common/home/neovim/grammar.nix
Normal file
62
common/home/neovim/grammar.nix
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
{ stdenv
|
||||||
|
, nodejs
|
||||||
|
, tree-sitter
|
||||||
|
, lib
|
||||||
|
}:
|
||||||
|
|
||||||
|
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/parsing/tree-sitter/grammar.nix
|
||||||
|
# Build a parser grammar and put the resulting shared object in `$out/parser`
|
||||||
|
|
||||||
|
{
|
||||||
|
# language name
|
||||||
|
language
|
||||||
|
, version
|
||||||
|
, src
|
||||||
|
, location ? null
|
||||||
|
, generate ? false
|
||||||
|
, ...
|
||||||
|
}@args:
|
||||||
|
|
||||||
|
stdenv.mkDerivation ({
|
||||||
|
pname = "${language}-grammar";
|
||||||
|
|
||||||
|
inherit src version;
|
||||||
|
|
||||||
|
nativeBuildInputs = lib.optionals generate [ nodejs tree-sitter ];
|
||||||
|
|
||||||
|
CFLAGS = [ "-Isrc" "-O2" ];
|
||||||
|
CXXFLAGS = [ "-Isrc" "-O2" ];
|
||||||
|
|
||||||
|
stripDebugList = [ "parser" ];
|
||||||
|
|
||||||
|
configurePhase = lib.optionalString (location != null) ''
|
||||||
|
cd ${location}
|
||||||
|
'' + lib.optionalString generate ''
|
||||||
|
tree-sitter generate
|
||||||
|
'';
|
||||||
|
|
||||||
|
# When both scanner.{c,cc} exist, we should not link both since they may be the same but in
|
||||||
|
# different languages. Just randomly prefer C++ if that happens.
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
if [[ -e src/scanner.cc ]]; then
|
||||||
|
$CXX -fPIC -c src/scanner.cc -o scanner.o $CXXFLAGS
|
||||||
|
elif [[ -e src/scanner.c ]]; then
|
||||||
|
$CC -fPIC -c src/scanner.c -o scanner.o $CFLAGS
|
||||||
|
fi
|
||||||
|
$CC -fPIC -c src/parser.c -o parser.o $CFLAGS
|
||||||
|
rm -rf parser
|
||||||
|
$CXX -shared -o parser *.o
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
mkdir $out
|
||||||
|
mv parser $out/
|
||||||
|
if [[ -d queries ]]; then
|
||||||
|
cp -r queries $out
|
||||||
|
fi
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
} // removeAttrs args [ "language" "location" "generate" ])
|
|
@ -1,8 +1,12 @@
|
||||||
lua << EOF
|
lua << EOF
|
||||||
|
|
||||||
|
local path = "/home/matt/.cache/nvim/"
|
||||||
|
|
||||||
require('nvim-treesitter.configs').setup({
|
require('nvim-treesitter.configs').setup({
|
||||||
highlight = { enable = true },
|
highlight = { enable = true },
|
||||||
indent = { enable = true }
|
indent = { enable = true },
|
||||||
|
parser_install_dir = path,
|
||||||
|
auto_install = true,
|
||||||
})
|
})
|
||||||
|
|
||||||
require('treesitter-context').setup({
|
require('treesitter-context').setup({
|
||||||
|
@ -11,6 +15,7 @@ require('treesitter-context').setup({
|
||||||
min_window_height = 20,
|
min_window_height = 20,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
vim.opt.runtimepath:append(path)
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
" Add line under context
|
" Add line under context
|
||||||
|
|
Loading…
Reference in a new issue