add d2 tree-sitter to dev editor

This commit is contained in:
Dmitriy Pleshevskiy 2022-12-07 17:14:44 +03:00
parent 0cbd3f0dd6
commit de08e20947
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
2 changed files with 42 additions and 10 deletions

View file

@ -1,29 +1,58 @@
{ pkgs ? import <nixpkgs> { } }: { pkgs ? import <nixpkgs> { } }:
let let
d2-vim = pkgs.vimUtils.buildVimPluginFrom2Nix { extraGrammars = {
name = "d2-vim"; tree-sitter-d2 = {
src = pkgs.fetchFromGitHub { language = "d2";
owner = "terrastruct"; src = ../.;
repo = "d2-vim"; version = "0.0.0";
rev = "ac58c07ba192d215cbbd2b2207f9def808a9283d";
hash = "sha256-rXUhXVmva4K0PqUboSXUpTqNttwehjkjjsEgTCZbGKI=";
}; };
}; };
tree-sitter = (pkgs.tree-sitter.override { inherit extraGrammars; });
grammars = tree-sitter.withPlugins (g: [ g.tree-sitter-d2 ]);
nvim-treesitter = pkgs.vimPlugins.nvim-treesitter.overrideAttrs (oldAttrs: {
postPatch = ''
rm -r parser
ln -s ${grammars} parser
ln -s ${../.}/queries queries/d2
'';
});
luaRc = ''
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.d2 = {}
require("nvim-treesitter.configs").setup({
ensure_installed = { },
sync_install = false,
highlight = {
enable = true,
},
indent = {
enable = true,
},
})
'';
neovim = pkgs.neovim.override { neovim = pkgs.neovim.override {
configure = { configure = {
customRC = '' customRC = ''
source ${./vimrc.vim} source ${./vimrc.vim}
lua <<EOF
${luaRc}
EOF
''; '';
packages.myPlugins.start = with pkgs.vimPlugins; [ packages.myPlugins.start = [
d2-vim
nvim-treesitter nvim-treesitter
]; ];
}; };
}; };
in in
pkgs.runCommand "nvim-ts" { } '' pkgs.runCommand "nvim-ts" { } ''
mkdir -p $out/bin mkdir -p $out/bin

View file

@ -13,3 +13,6 @@ set autoindent
" Always show statusline. " Always show statusline.
set laststatus=2 set laststatus=2
set statusline=%<%f\ %m%r%y\ %LL\ %=\ 0x%-4.B\ %-16.(%lL,%cC%V,%oB%)\ %P set statusline=%<%f\ %m%r%y\ %LL\ %=\ 0x%-4.B\ %-16.(%lL,%cC%V,%oB%)\ %P
" Detect d2 without d2-vim
au BufNewFile,BufRead *.d2 setfiletype d2