Skip to content

Commit

Permalink
neovim: Use treesitter from nix and migrate from lazy to vim-plug
Browse files Browse the repository at this point in the history
I didn't have time to split these commits.
  • Loading branch information
juanibiapina committed Mar 19, 2024
1 parent c252a2f commit 13c4b4f
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 167 deletions.
1 change: 0 additions & 1 deletion assets/nix/packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
vivaldi

# coding
neovim-unwrapped
(callPackage ./packages/nvim.nix {})
vim
vscode
Expand Down
21 changes: 19 additions & 2 deletions assets/nix/packages/nvim.nix
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
{ writeShellApplication, wrapNeovim, neovim-unwrapped }:
{ writeShellApplication, wrapNeovim, neovim-unwrapped, vimPlugins, symlinkJoin }:

let
# Link together all treesitter grammars into single derivation
treesitterPath = symlinkJoin {
name = "nvim-nix-treesitter-parsers";
paths = vimPlugins.nvim-treesitter.withAllGrammars.dependencies;
};

# wrap neovim
wrapped = wrapNeovim neovim-unwrapped {
configure = {
customRC = /* vim */ ''
" Setting variables here is a clever way to set variables that are
" different in NixOS and MacOS
" let g:treesitter_path = "${treesitterPath}"
" Add nvim-treesitter to runtimepath
set rtp^=${vimPlugins.nvim-treesitter}
" Add grammars to runtimepath
set rtp^=${treesitterPath}
" Load configuration from default location
source $HOME/.config/nvim/init.lua
'';
};
};
in
writeShellApplication {
name = "nvim-test";
name = "nvim";
text = ''${wrapped}/bin/nvim "$@"'';
}
26 changes: 4 additions & 22 deletions dotfiles/nvim/.config/nvim/conf/auto/treesitter.lua
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
-- https://github.com/nvim-treesitter/nvim-treesitter

-- this is needed because nix shells set CC to clang and for some reason this
-- breaks compilation of treesitter parsers
vim.env.CC = ''

require'nvim-treesitter.configs'.setup {
ensure_installed = {
-- required parsers
"c", "lua", "vim", "vimdoc", "query",
-- extra parsers
"ruby", "javascript", "typescript", "nix", "gitcommit", "yaml", "json",
},

-- Install parsers asynchronously (only applied to `ensure_installed`)
sync_install = false,

-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,

-- List of parsers to ignore installing
-- diff: for some reason this parser is worse than the default
ignore_install = { "diff" },
require('nvim-treesitter.configs').setup {
-- Don't automatically install missing parsers
-- This is handled by nix
auto_install = false,

highlight = { enable = true },

Expand Down
12 changes: 1 addition & 11 deletions dotfiles/nvim/.config/nvim/init.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
require("prelude")

-- setup lazy
require("lazy").setup({
-- this loads lua/plugins.lua or lua/plugins/*.lua
spec = "plugins",
change_detection = {
enabled = false,
},
})

-- load the rest of the config
require("plugins")
require('config')
require('highlights')
require('auto')
Expand Down
208 changes: 92 additions & 116 deletions dotfiles/nvim/.config/nvim/lua/plugins.lua
Original file line number Diff line number Diff line change
@@ -1,116 +1,92 @@
return {
-- LSP
{
'neovim/nvim-lspconfig',
dependencies = {
-- Status updates for LSP
{ 'j-hui/fidget.nvim' },
},
},

-- Completion
{
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"dcampos/nvim-snippy",
"dcampos/cmp-snippy",
}
},

-- Snippets
{ "honza/vim-snippets" },

-- keymap documentation
{ "folke/which-key.nvim", config = true },

-- Treesitter
{
'nvim-treesitter/nvim-treesitter',
build = ":TSUpdate",
},

-- fuzzy finder
{
"nvim-telescope/telescope.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
},
},

-- linter
-- disabling ale for now to avoid conflicts with LSP
-- "dense-analysis/ale",

-- Adds git releated signs to the gutter, as well as utilities for managing changes
'lewis6991/gitsigns.nvim',

-- Commenting
{ 'numToStr/Comment.nvim', config = true },

-- file system tree
{
"juanibiapina/vim-lighttree",
},

-- text objects
'wellle/targets.vim',

-- migrated from Plug

-- Navigation
{ "mileszs/ack.vim", event = 'VimEnter' },
"tpope/vim-unimpaired",

-- Utilities
"tpope/vim-surround",
"editorconfig/editorconfig-vim",
"tpope/vim-repeat",
"godlygeek/tabular",
"tpope/vim-eunuch",
"tpope/vim-abolish",
-- Detect tabstop and shiftwidth automatically
"tpope/vim-sleuth",
"tpope/vim-rhubarb",
"tpope/vim-capslock",
"tpope/vim-dispatch",
"radenling/vim-dispatch-neovim",
"AndrewRadev/splitjoin.vim",
"kopischke/vim-fetch",
"ntpeters/vim-better-whitespace",
"AndrewRadev/sideways.vim",
"moll/vim-bbye",
"sunaku/vim-shortcut",
"tpope/vim-projectionist",
"tpope/vim-sensible",
"kassio/neoterm",

-- Colors
"lifepillar/vim-solarized8",

-- Github CoPilot
"github/copilot.vim",

-- Diff
"lambdalisue/vim-improve-diff",
"lambdalisue/vim-unified-diff",

-- Git
"tpope/vim-git",
"tpope/vim-fugitive",

-- Quickfix
"itchyny/vim-qfedit",

-- Rails
"tpope/vim-rails",

-- Ruby
"vim-ruby/vim-ruby",
"ngmy/vim-rubocop",
"tpope/vim-bundler",
"keith/rspec.vim",

-- Testing
"juanibiapina/vim-runner",
}
local vim = vim -- just to prevent errors for the linter

local Plug = vim.fn['plug#']
vim.call('plug#begin')

-- LSP
Plug('neovim/nvim-lspconfig')
Plug('j-hui/fidget.nvim') -- Status updates for LSP

-- Completion
Plug("hrsh7th/nvim-cmp")
Plug("hrsh7th/cmp-nvim-lsp")
Plug("dcampos/nvim-snippy")
Plug("dcampos/cmp-snippy")

-- Fuzzy finder
Plug("nvim-telescope/telescope.nvim")
Plug("nvim-lua/plenary.nvim")

-- Colors
Plug("lifepillar/vim-solarized8")

-- Keymap documentation
Plug("folke/which-key.nvim")

-- Snippets
Plug("honza/vim-snippets")

-- Git signs
Plug("lewis6991/gitsigns.nvim")

-- file system tree
Plug("juanibiapina/vim-lighttree")

-- text objects
Plug("wellle/targets.vim")

-- Grep
Plug("mileszs/ack.vim")

-- Github CoPilot
Plug("github/copilot.vim")

-- Diff
Plug("lambdalisue/vim-improve-diff")
Plug("lambdalisue/vim-unified-diff")

-- Git
Plug("tpope/vim-git")
Plug("tpope/vim-fugitive")

-- Quickfix
Plug("itchyny/vim-qfedit")

-- Rails
Plug("tpope/vim-rails")

-- Ruby
Plug("vim-ruby/vim-ruby")
Plug("ngmy/vim-rubocop")
Plug("tpope/vim-bundler")
Plug("keith/rspec.vim")

-- Testing
Plug("juanibiapina/vim-runner")

-- Not organized yet
Plug("AndrewRadev/sideways.vim")
Plug("AndrewRadev/splitjoin.vim")
Plug("editorconfig/editorconfig-vim")
Plug("godlygeek/tabular")
Plug("kassio/neoterm")
Plug("kopischke/vim-fetch")
Plug("moll/vim-bbye")
Plug("ntpeters/vim-better-whitespace")
Plug("radenling/vim-dispatch-neovim")
Plug("sunaku/vim-shortcut")

-- Tpope
Plug("tpope/vim-abolish")
Plug("tpope/vim-capslock")
Plug("tpope/vim-dispatch")
Plug("tpope/vim-eunuch")
Plug("tpope/vim-projectionist")
Plug("tpope/vim-repeat")
Plug("tpope/vim-rhubarb")
Plug("tpope/vim-sensible")
Plug("tpope/vim-sleuth")
Plug("tpope/vim-surround")
Plug("tpope/vim-unimpaired")

vim.call("plug#end")
15 changes: 0 additions & 15 deletions dotfiles/nvim/.config/nvim/lua/prelude.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
-- bootstrap lazy
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)

-- set leader to space
-- this needs to happen before lazy is setup
vim.g.mapleader = " "
vim.g.maplocalleader = " "

0 comments on commit 13c4b4f

Please sign in to comment.