From 04b2a511e11318e64d509dea815c85307a6325ad Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Fri, 14 May 2021 19:34:26 +0530 Subject: [PATCH] nvim: treesitter: Add fish and nix Drop the syntax highlighting plugins for fish and nix and switch to treesitter. The ftdetect is taken from the respective plugins. We might need to add the indent specific scripts for fish and nix later since we are not enabling indent with treesitter. --- nvim/.config/nvim/ftdetect/fish.vim | 22 ++++++++++++++++++++++ nvim/.config/nvim/ftdetect/nix.vim | 1 + nvim/.config/nvim/lua/plugins.lua | 2 -- nvim/.config/nvim/lua/treesitter.lua | 2 +- 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 nvim/.config/nvim/ftdetect/fish.vim create mode 100644 nvim/.config/nvim/ftdetect/nix.vim diff --git a/nvim/.config/nvim/ftdetect/fish.vim b/nvim/.config/nvim/ftdetect/fish.vim new file mode 100644 index 0000000..f7ba78c --- /dev/null +++ b/nvim/.config/nvim/ftdetect/fish.vim @@ -0,0 +1,22 @@ +autocmd BufRead,BufNewFile *.fish setfiletype fish + +" Detect fish scripts by the shebang line. +autocmd BufRead * + \ if getline(1) =~# '\v^#!%(\f*/|/usr/bin/env\s*<)fish>' | + \ setlocal filetype=fish | + \ endif + +" Move cursor to first empty line when using funced. +autocmd BufRead fish_funced_*_*.fish call search('^$') + +" Fish histories are YAML documents. +autocmd BufRead,BufNewFile ~/.config/fish/fish_{read_,}history setfiletype yaml + +" Universal variable storages should not be hand edited. +autocmd BufRead,BufNewFile ~/.config/fish/fishd.* setlocal readonly + +" Mimic `funced` when manually creating functions. +autocmd BufNewFile ~/.config/fish/functions/*.fish + \ call append(0, ['function '.expand('%:t:r'), + \'', + \'end']) | diff --git a/nvim/.config/nvim/ftdetect/nix.vim b/nvim/.config/nvim/ftdetect/nix.vim new file mode 100644 index 0000000..606fdb2 --- /dev/null +++ b/nvim/.config/nvim/ftdetect/nix.vim @@ -0,0 +1 @@ +au BufRead,BufNewFile *.nix set filetype=nix diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index d4d3e9a..d23f9df 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -134,7 +134,6 @@ local init = function () use 'vim-pandoc/vim-pandoc-syntax' -- Dhall & nix use 'vmchale/dhall-vim' - use 'LnL7/vim-nix' -- LISP use { 'Olical/conjure', @@ -148,7 +147,6 @@ local init = function () } use 'wlangstroth/vim-racket' -- Other syntax highlighting support - use 'georgewitteman/vim-fish' use 'inkarkat/SyntaxAttr.vim' -- For statusline use { diff --git a/nvim/.config/nvim/lua/treesitter.lua b/nvim/.config/nvim/lua/treesitter.lua index 26c963d..00f80f4 100644 --- a/nvim/.config/nvim/lua/treesitter.lua +++ b/nvim/.config/nvim/lua/treesitter.lua @@ -1,5 +1,5 @@ require'nvim-treesitter.configs'.setup { - ensure_installed = { "bash", "c", "clojure", "cpp", "fennel", "java", "javascript", "jsdoc", "json", "lua", "python", "rust", "toml" }, + ensure_installed = { "bash", "c", "clojure", "cpp", "fennel", "fish", "java", "javascript", "jsdoc", "json", "lua", "nix", "python", "rust", "toml" }, highlight = { enable = true, },