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
|
||||
# installs a vim plugin from git with a given tag / branch
|
||||
plugin = owner: repo: rev: hash:
|
||||
plugin = src:
|
||||
pkgs.vimUtils.buildVimPlugin {
|
||||
pname = "${lib.strings.sanitizeDerivationName repo}";
|
||||
version = rev;
|
||||
src = pkgs.fetchFromGitHub {
|
||||
inherit rev owner repo hash;
|
||||
};
|
||||
pname = "${lib.strings.sanitizeDerivationName src.repo}";
|
||||
version = src.rev;
|
||||
inherit src;
|
||||
};
|
||||
|
||||
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;
|
||||
in {
|
||||
# TODO: make a gradle module and have java in device-vars.nix
|
||||
|
@ -48,6 +56,7 @@ in {
|
|||
nodePackages.npm
|
||||
nodePackages.neovim
|
||||
gradle
|
||||
gcc
|
||||
|
||||
bat
|
||||
|
||||
|
@ -134,95 +143,122 @@ in {
|
|||
extraConfig = fileContents ./base.vim;
|
||||
extraLuaConfig = fileContents ./base.lua;
|
||||
|
||||
plugins = with pkgs.vimPlugins; [
|
||||
# Coc configured
|
||||
coc-css
|
||||
coc-eslint
|
||||
coc-java
|
||||
coc-sh
|
||||
coc-stylelintplus
|
||||
{
|
||||
plugin = coc-snippets;
|
||||
type = "viml";
|
||||
config = fileContents ./plugins/snippets.vim;
|
||||
}
|
||||
plugins = let
|
||||
# custom packages
|
||||
hypr-src = pkgs.fetchFromGitHub {
|
||||
owner = "luckasRanarison";
|
||||
repo = "tree-sitter-hypr";
|
||||
rev = "90b3ddf8a85b5ea3d9dc4920fddb16182a192e14";
|
||||
hash = "sha256-ErFs2eCC0eZEyDldrTUj4JJ0Eu+exDHNQx4g8WXh/UQ=";
|
||||
};
|
||||
|
||||
## Lua
|
||||
coc-sumneko-lua
|
||||
neodev-nvim
|
||||
tree-sitter-hypr = plugin hypr-src;
|
||||
|
||||
## Fzf
|
||||
coc-fzf
|
||||
fzfWrapper
|
||||
fzf-vim
|
||||
hypr-grammar = buildGrammar "hypr" {
|
||||
src = hypr-src;
|
||||
generate = true;
|
||||
};
|
||||
|
||||
coc-highlight
|
||||
coc-json
|
||||
coc-pyright
|
||||
coc-vimlsp
|
||||
coc-yaml
|
||||
coc-toml
|
||||
coc-markdownlint
|
||||
coc-tsserver
|
||||
fugitive
|
||||
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-css
|
||||
coc-eslint
|
||||
coc-java
|
||||
coc-sh
|
||||
coc-stylelintplus
|
||||
{
|
||||
plugin = coc-snippets;
|
||||
type = "viml";
|
||||
config = fileContents ./plugins/snippets.vim;
|
||||
}
|
||||
|
||||
{
|
||||
plugin = dracula-nvim;
|
||||
type = "viml";
|
||||
config = fileContents ./plugins/dracula.vim;
|
||||
}
|
||||
{
|
||||
plugin = lualine-nvim;
|
||||
type = "lua";
|
||||
config = fileContents ./plugins/lualine.lua;
|
||||
}
|
||||
{
|
||||
plugin = todo-comments-nvim;
|
||||
type = "lua";
|
||||
config = "require('todo-comments').setup()";
|
||||
}
|
||||
{
|
||||
plugin = gitsigns-nvim;
|
||||
type = "lua";
|
||||
config = fileContents ./plugins/gitsigns.lua;
|
||||
}
|
||||
{
|
||||
plugin = nvim-autopairs;
|
||||
type = "lua";
|
||||
config = fileContents ./plugins/autopairs.lua;
|
||||
}
|
||||
nvim-treesitter-context
|
||||
nvim-treesitter-textobjects
|
||||
{
|
||||
plugin = nvim-treesitter.withAllGrammars;
|
||||
type = "viml";
|
||||
config = fileContents ./plugins/treesitter.vim;
|
||||
}
|
||||
{
|
||||
plugin =
|
||||
plugin "lukas-reineke" "indent-blankline.nvim"
|
||||
"046e2cf04e08ece927bacbfb87c5b35c0b636546"
|
||||
"sha256-bhoep8aTYje5K/dZ/XmpwBPn4PBEMPrmw33QJdfFe6M=";
|
||||
type = "lua";
|
||||
config = fileContents ./plugins/indent.lua;
|
||||
}
|
||||
{
|
||||
plugin = mini-nvim;
|
||||
type = "lua";
|
||||
config = fileContents ./plugins/mini.lua;
|
||||
}
|
||||
{
|
||||
plugin = neo-tree-nvim;
|
||||
type = "viml";
|
||||
config = ''
|
||||
${fileContents ./plugins/neotree.vim}
|
||||
## Lua
|
||||
coc-sumneko-lua
|
||||
neodev-nvim
|
||||
|
||||
lua << EOF
|
||||
${fileContents ./plugins/neotree.lua}
|
||||
EOF
|
||||
'';
|
||||
}
|
||||
];
|
||||
## Fzf
|
||||
coc-fzf
|
||||
fzfWrapper
|
||||
fzf-vim
|
||||
|
||||
coc-highlight
|
||||
coc-json
|
||||
coc-pyright
|
||||
coc-vimlsp
|
||||
coc-yaml
|
||||
coc-toml
|
||||
coc-markdownlint
|
||||
coc-tsserver
|
||||
fugitive
|
||||
|
||||
{
|
||||
plugin = dracula-nvim;
|
||||
type = "viml";
|
||||
config = fileContents ./plugins/dracula.vim;
|
||||
}
|
||||
{
|
||||
plugin = lualine-nvim;
|
||||
type = "lua";
|
||||
config = fileContents ./plugins/lualine.lua;
|
||||
}
|
||||
{
|
||||
plugin = todo-comments-nvim;
|
||||
type = "lua";
|
||||
config = "require('todo-comments').setup()";
|
||||
}
|
||||
{
|
||||
plugin = gitsigns-nvim;
|
||||
type = "lua";
|
||||
config = fileContents ./plugins/gitsigns.lua;
|
||||
}
|
||||
{
|
||||
plugin = nvim-autopairs;
|
||||
type = "lua";
|
||||
config = fileContents ./plugins/autopairs.lua;
|
||||
}
|
||||
nvim-treesitter-context
|
||||
nvim-treesitter-textobjects
|
||||
{
|
||||
plugin = tree-sitter-hypr;
|
||||
type = "lua";
|
||||
config = ''
|
||||
vim.treesitter.language.require_language("hypr", "${hypr-grammar}/parser")
|
||||
'';
|
||||
}
|
||||
{
|
||||
plugin = nvim-treesitter.withAllGrammars;
|
||||
type = "viml";
|
||||
config = fileContents ./plugins/treesitter.vim;
|
||||
}
|
||||
{
|
||||
plugin = indent-blankline;
|
||||
type = "lua";
|
||||
config = fileContents ./plugins/indent.lua;
|
||||
}
|
||||
{
|
||||
plugin = mini-nvim;
|
||||
type = "lua";
|
||||
config = fileContents ./plugins/mini.lua;
|
||||
}
|
||||
{
|
||||
plugin = neo-tree-nvim;
|
||||
type = "viml";
|
||||
config = ''
|
||||
${fileContents ./plugins/neotree.vim}
|
||||
|
||||
lua << EOF
|
||||
${fileContents ./plugins/neotree.lua}
|
||||
EOF
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
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
|
||||
|
||||
local path = "/home/matt/.cache/nvim/"
|
||||
|
||||
require('nvim-treesitter.configs').setup({
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true }
|
||||
indent = { enable = true },
|
||||
parser_install_dir = path,
|
||||
auto_install = true,
|
||||
})
|
||||
|
||||
require('treesitter-context').setup({
|
||||
|
@ -11,6 +15,7 @@ require('treesitter-context').setup({
|
|||
min_window_height = 20,
|
||||
})
|
||||
|
||||
vim.opt.runtimepath:append(path)
|
||||
EOF
|
||||
|
||||
" Add line under context
|
||||
|
|
Loading…
Reference in a new issue