From 85cc99140c8f87f22ab77405e845724fcae7af77 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 1 Feb 2022 12:02:02 +0200 Subject: [PATCH] feat: treesitter plugin for neovim --- dotfiles/neovim/init.lua | 42 +++++++++---------- dotfiles/neovim/lua/my/plugins/init.lua | 1 + dotfiles/neovim/lua/my/plugins/treesitter.lua | 19 +++++++++ modules/applications/neovim.nix | 1 + 4 files changed, 41 insertions(+), 22 deletions(-) create mode 100644 dotfiles/neovim/lua/my/plugins/treesitter.lua diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 376a407..1c17e62 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -1,35 +1,33 @@ -local cmd = vim.cmd -- to execute Vim commands e.g. cmd('pwd') -local fn = vim.fn -- to call Vim functions e.g. fn.bufnr() -local g = vim.g -- a table to access global variables -local opt = vim.opt -- to set options +local cmd = vim.cmd -- to execute Vim commands e.g. cmd('pwd') +local fn = vim.fn -- to call Vim functions e.g. fn.bufnr() +local g = vim.g -- a table to access global variables +local opt = vim.opt -- to set options -- Basic options -opt.joinspaces = false -- No double spaces with join -opt.list = true -- Show some invisible characters +opt.joinspaces = false -- No double spaces with join +opt.list = true -- Show some invisible characters -opt.number = true -- Show line numbers -opt.relativenumber = true -- Relative line numbers +opt.number = true -- Show line numbers +opt.relativenumber = true -- Relative line numbers -opt.scrolloff = 4 -- Lines of context -opt.shiftround = true -- Round indent -opt.shiftwidth = 2 -- Size of an indent -opt.termguicolors = true -- True color support +opt.scrolloff = 4 -- Lines of context +opt.shiftround = true -- Round indent +opt.shiftwidth = 2 -- Size of an indent +opt.termguicolors = true -- True color support -opt.ignorecase = true -- Ignore case -opt.smartcase = true -- Do not ignore case with capitals +opt.ignorecase = true -- Ignore case +opt.smartcase = true -- Do not ignore case with capitals -opt.smartindent = true -- Insert indents automatically +opt.smartindent = true -- Insert indents automatically -opt.splitbelow = true -- Put new windows below current -opt.splitright = true -- Put new windows right of current +opt.splitbelow = true -- Put new windows below current +opt.splitright = true -- Put new windows right of current -opt.wrap = false -- Disable line wrap -opt.wildmode = {'list', 'longest'} -- Command-line completion mode +opt.wrap = false -- Disable line wrap +opt.wildmode = {'list', 'longest'} -- Command-line completion mode -- Set theme -require('github-theme').setup({ - theme_style = "light" -}) +require('github-theme').setup({theme_style = "light", dark_float = true}) -- Import my other files require('my.keymaps').setup() diff --git a/dotfiles/neovim/lua/my/plugins/init.lua b/dotfiles/neovim/lua/my/plugins/init.lua index 258fd41..40da524 100644 --- a/dotfiles/neovim/lua/my/plugins/init.lua +++ b/dotfiles/neovim/lua/my/plugins/init.lua @@ -3,6 +3,7 @@ local M = {} function M.setup() require("my.plugins.lspconfig").setup() require("my.plugins.fzf-lua").setup() + require("my.plugins.treesitter").setup() -- Other unconfigured plugins require('nvim-autopairs').setup() diff --git a/dotfiles/neovim/lua/my/plugins/treesitter.lua b/dotfiles/neovim/lua/my/plugins/treesitter.lua new file mode 100644 index 0000000..9d002f5 --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/treesitter.lua @@ -0,0 +1,19 @@ +local M = {} + +function M.setup() + require'nvim-treesitter.configs'.setup { + ensure_installed = "maintained", + sync_install = false, + highlight = { + enable = true, + + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = false + } + } +end + +return M diff --git a/modules/applications/neovim.nix b/modules/applications/neovim.nix index 55aa93d..10d3586 100644 --- a/modules/applications/neovim.nix +++ b/modules/applications/neovim.nix @@ -39,6 +39,7 @@ in fzf-lua # fuzzy search for say opening files purescript-vim # purescript syntax highlighting nvim-comment # allows toggling line-comments + nvim-treesitter # use treesitter for syntax highlighting ]; }; }