mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-09 02:15:58 +01:00
f9789432f9
* modules: switch to gerg's neovim-wrapper * modules: use initViml instead of writing the file * treewide: make the entire generated config lua based * docs: remove mentions of configRC * plugins/treesitter: remove vim.cmd hack * treewide: move resolveDag to lib * modules/wrapper(rc): fix typo * treewide: migrate to pluginRC for correct DAG order The "new" DAG order is as follows: - (luaConfigPre) - globalsScript - basic - theme - pluginConfigs - extraPluginConfigs - mappings - (luaConfigPost) * plugins/theme: fix theme DAG place * plugins/theme: fix fixed theme DAG place * modules/wrapper(rc): add removed option module for configRC * docs: add dag-entries chapter, add release note entry * fix: formatting CI * languages/nix: add missing `local` * docs: fix page link * docs: add mention of breaking changes at the start of the release notes * plugins/neo-tree: convert to pluginRC * modules/wrapper(rc): add back entryAnywhere * modules/wrapper(rc): expose pluginRC * apply raf patch --------- Co-authored-by: NotAShelf <raf@notashelf.dev>
84 lines
2.5 KiB
Nix
84 lines
2.5 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}: let
|
|
inherit (lib.strings) optionalString;
|
|
inherit (lib.modules) mkIf mkMerge;
|
|
inherit (lib.nvim.binds) mkBinding;
|
|
inherit (lib.nvim.dag) entryAnywhere;
|
|
inherit (lib.nvim.lua) toLuaObject;
|
|
inherit (lib.nvim.binds) pushDownDefault;
|
|
|
|
cfg = config.vim.filetree.nvimTree;
|
|
self = import ./nvimtree.nix {inherit pkgs lib;};
|
|
inherit (self.options.vim.filetree.nvimTree) mappings;
|
|
in {
|
|
config = mkIf cfg.enable {
|
|
vim.startPlugins = ["nvim-tree-lua"];
|
|
|
|
vim.maps.normal = mkMerge [
|
|
(mkBinding cfg.mappings.toggle ":NvimTreeToggle<cr>" mappings.toggle.description)
|
|
(mkBinding cfg.mappings.refresh ":NvimTreeRefresh<cr>" mappings.refresh.description)
|
|
(mkBinding cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
|
|
(mkBinding cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
|
|
];
|
|
|
|
vim.binds.whichKey.register = pushDownDefault {
|
|
"<leader>t" = "+NvimTree";
|
|
};
|
|
|
|
vim.pluginRC.nvimtreelua = entryAnywhere ''
|
|
${
|
|
optionalString cfg.setupOpts.disable_netrw ''
|
|
-- disable netrew completely
|
|
vim.g.loaded_netrw = 1
|
|
vim.g.loaded_netrwPlugin = 1
|
|
''
|
|
}
|
|
|
|
require'nvim-tree'.setup(${toLuaObject cfg.setupOpts})
|
|
|
|
${
|
|
optionalString cfg.openOnSetup ''
|
|
-- autostart behaviour
|
|
-- Open on startup has been deprecated
|
|
-- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup
|
|
|
|
-- use a nix eval to dynamically insert the open on startup function
|
|
local function open_nvim_tree(data)
|
|
local IGNORED_FT = {
|
|
"markdown",
|
|
}
|
|
|
|
-- buffer is a real file on the disk
|
|
local real_file = vim.fn.filereadable(data.file) == 1
|
|
|
|
-- buffer is a [No Name]
|
|
local no_name = data.file == "" and vim.bo[data.buf].buftype == ""
|
|
|
|
-- &ft
|
|
local filetype = vim.bo[data.buf].ft
|
|
|
|
-- only files please
|
|
if not real_file and not no_name then
|
|
return
|
|
end
|
|
|
|
-- skip ignored filetypes
|
|
if vim.tbl_contains(IGNORED_FT, filetype) then
|
|
return
|
|
end
|
|
|
|
-- open the tree but don't focus it
|
|
require("nvim-tree.api").tree.toggle({ focus = false })
|
|
end
|
|
|
|
-- function to automatically open the tree on VimEnter
|
|
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
|
|
''
|
|
}
|
|
'';
|
|
};
|
|
}
|