mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-22 05:10:44 +00:00
Compare commits
6 commits
9777057ed2
...
70b5954925
Author | SHA1 | Date | |
---|---|---|---|
|
70b5954925 | ||
|
8a827f92c9 | ||
|
c99afe12c3 | ||
|
7f5c33605d | ||
|
62b1e30e49 | ||
|
c971673529 |
7 changed files with 123 additions and 61 deletions
|
@ -54,5 +54,10 @@ in {
|
||||||
Nvf now uses $NVIM_APP_NAME so there is no longer the problem of
|
Nvf now uses $NVIM_APP_NAME so there is no longer the problem of
|
||||||
(accidental) leaking of user configuration.
|
(accidental) leaking of user configuration.
|
||||||
'')
|
'')
|
||||||
|
|
||||||
|
(mkRemovedOptionModule ["vim" "lsp" "trouble" "mappings" "toggle"] ''
|
||||||
|
With Trouble having so many different modes, and breaking changes
|
||||||
|
upstream, it no longer makes sense, nor works, to toggle only Trouble.
|
||||||
|
'')
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf;
|
||||||
|
inherit (lib.strings) optionalString;
|
||||||
|
|
||||||
cfg = config.vim.filetree.neo-tree;
|
cfg = config.vim.filetree.neo-tree;
|
||||||
in {
|
in {
|
||||||
|
@ -21,7 +22,28 @@ in {
|
||||||
setupModule = "neo-tree";
|
setupModule = "neo-tree";
|
||||||
inherit (cfg) setupOpts;
|
inherit (cfg) setupOpts;
|
||||||
|
|
||||||
|
beforeAll =
|
||||||
|
optionalString (cfg.setupOpts.filesystem.hijack_netrw_behavior != "disabled")
|
||||||
|
# from https://github.com/nvim-neo-tree/neo-tree.nvim/discussions/1326
|
||||||
|
''
|
||||||
|
vim.api.nvim_create_autocmd("BufEnter", {
|
||||||
|
group = vim.api.nvim_create_augroup("load_neo_tree", {}),
|
||||||
|
desc = "Loads neo-tree when openning a directory",
|
||||||
|
callback = function(args)
|
||||||
|
local stats = vim.uv.fs_stat(args.file)
|
||||||
|
|
||||||
|
if not stats or stats.type ~= "directory" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
require("lz.n").trigger_load("neo-tree-nvim")
|
||||||
|
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
'';
|
||||||
cmd = ["Neotree"];
|
cmd = ["Neotree"];
|
||||||
|
event = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
visuals.nvim-web-devicons.enable = true;
|
visuals.nvim-web-devicons.enable = true;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{lib, ...}: let
|
{lib, ...}: let
|
||||||
inherit (lib.types) bool str int submodule enum either listOf;
|
inherit (lib.types) bool str enum either listOf;
|
||||||
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
||||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||||
in {
|
in {
|
||||||
|
@ -150,6 +150,14 @@ in {
|
||||||
A list of filetypes that should not be replaced when opening a file
|
A list of filetypes that should not be replaced when opening a file
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
filesystem = {
|
||||||
|
hijack_netrw_behavior = mkOption {
|
||||||
|
type = enum ["disabled" "open_default" "open_current"];
|
||||||
|
default = "open_default";
|
||||||
|
description = "Hijack Netrw behavior";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ in {
|
||||||
package = "nvim-tree-lua";
|
package = "nvim-tree-lua";
|
||||||
setupModule = "nvim-tree";
|
setupModule = "nvim-tree";
|
||||||
inherit (cfg) setupOpts;
|
inherit (cfg) setupOpts;
|
||||||
|
|
||||||
cmd = ["NvimTreeClipboard" "NvimTreeClose" "NvimTreeCollapse" "NvimTreeCollapseKeepBuffers" "NvimTreeFindFile" "NvimTreeFindFileToggle" "NvimTreeFocus" "NvimTreeHiTest" "NvimTreeOpen" "NvimTreeRefresh" "NvimTreeResize" "NvimTreeToggle"];
|
cmd = ["NvimTreeClipboard" "NvimTreeClose" "NvimTreeCollapse" "NvimTreeCollapseKeepBuffers" "NvimTreeFindFile" "NvimTreeFindFileToggle" "NvimTreeFocus" "NvimTreeHiTest" "NvimTreeOpen" "NvimTreeRefresh" "NvimTreeResize" "NvimTreeToggle"];
|
||||||
keys = [
|
keys = [
|
||||||
(mkLznBinding ["n"] cfg.mappings.toggle ":NvimTreeToggle<cr>" mappings.toggle.description)
|
(mkLznBinding ["n"] cfg.mappings.toggle ":NvimTreeToggle<cr>" mappings.toggle.description)
|
||||||
|
@ -31,58 +32,76 @@ in {
|
||||||
(mkLznBinding ["n"] cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
|
(mkLznBinding ["n"] cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
|
||||||
(mkLznBinding ["n"] cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
|
(mkLznBinding ["n"] cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
|
||||||
];
|
];
|
||||||
|
|
||||||
|
beforeAll = ''
|
||||||
|
${
|
||||||
|
optionalString cfg.setupOpts.disable_netrw ''
|
||||||
|
-- disable netrew completely
|
||||||
|
vim.g.loaded_netrw = 1
|
||||||
|
vim.g.loaded_netrwPlugin = 1
|
||||||
|
''
|
||||||
|
}
|
||||||
|
|
||||||
|
${optionalString (cfg.setupOpts.hijack_netrw && !cfg.openOnSetup) ''
|
||||||
|
vim.api.nvim_create_autocmd("BufEnter", {
|
||||||
|
group = vim.api.nvim_create_augroup("load_nvim_tree", {}),
|
||||||
|
desc = "Loads nvim-tree when openning a directory",
|
||||||
|
callback = function(args)
|
||||||
|
local stats = vim.uv.fs_stat(args.file)
|
||||||
|
|
||||||
|
if not stats or stats.type ~= "directory" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
require("lz.n").trigger_load("nvim-tree-lua")
|
||||||
|
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
''}
|
||||||
|
|
||||||
|
${
|
||||||
|
optionalString cfg.openOnSetup ''
|
||||||
|
${optionalString config.vim.lazy.enable ''require('lz.n').trigger_load("nvim-tree-lua")''}
|
||||||
|
-- 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 })
|
||||||
|
''
|
||||||
|
}
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
pluginRC.nvimtreelua = entryAnywhere ''
|
|
||||||
${
|
|
||||||
optionalString cfg.setupOpts.disable_netrw ''
|
|
||||||
-- disable netrew completely
|
|
||||||
vim.g.loaded_netrw = 1
|
|
||||||
vim.g.loaded_netrwPlugin = 1
|
|
||||||
''
|
|
||||||
}
|
|
||||||
|
|
||||||
${
|
|
||||||
optionalString cfg.openOnSetup ''
|
|
||||||
${optionalString config.vim.lazy.enable ''require('lz.n').trigger_load("nvim-tree-lua")''}
|
|
||||||
-- 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 })
|
|
||||||
''
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,19 +21,18 @@ in {
|
||||||
|
|
||||||
cmd = "Trouble";
|
cmd = "Trouble";
|
||||||
keys = [
|
keys = [
|
||||||
(mkSetLznBinding "n" mappings.toggle "<cmd>TroubleToggle<CR>")
|
(mkSetLznBinding "n" mappings.workspaceDiagnostics "<cmd>Trouble toggle diagnostics<CR>")
|
||||||
(mkSetLznBinding "n" mappings.workspaceDiagnostics "<cmd>TroubleToggle workspace_diagnostics<CR>")
|
(mkSetLznBinding "n" mappings.documentDiagnostics "<cmd>Trouble toggle diagnostics filter.buf=0<CR>")
|
||||||
(mkSetLznBinding "n" mappings.documentDiagnostics "<cmd>TroubleToggle document_diagnostics<CR>")
|
(mkSetLznBinding "n" mappings.lspReferences "<cmd>Trouble toggle lsp_references<CR>")
|
||||||
(mkSetLznBinding "n" mappings.lspReferences "<cmd>TroubleToggle lsp_references<CR>")
|
(mkSetLznBinding "n" mappings.quickfix "<cmd>Trouble toggle quickfix<CR>")
|
||||||
(mkSetLznBinding "n" mappings.quickfix "<cmd>TroubleToggle quickfix<CR>")
|
(mkSetLznBinding "n" mappings.locList "<cmd>Trouble toggle loclist<CR>")
|
||||||
(mkSetLznBinding "n" mappings.locList "<cmd>TroubleToggle loclist<CR>")
|
(mkSetLznBinding "n" mappings.symbols "<cmd>Trouble toggle symbols<CR>")
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
binds.whichKey.register = pushDownDefault {
|
binds.whichKey.register = pushDownDefault {
|
||||||
"<leader>l" = "Trouble";
|
|
||||||
"<leader>x" = "+Trouble";
|
"<leader>x" = "+Trouble";
|
||||||
"<leader>lw" = "Workspace";
|
"<leader>lw" = "+Workspace";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,12 +10,12 @@ in {
|
||||||
setupOpts = mkPluginSetupOption "Trouble" {};
|
setupOpts = mkPluginSetupOption "Trouble" {};
|
||||||
|
|
||||||
mappings = {
|
mappings = {
|
||||||
toggle = mkMappingOption "Toggle trouble [trouble]" "<leader>xx";
|
|
||||||
workspaceDiagnostics = mkMappingOption "Workspace diagnostics [trouble]" "<leader>lwd";
|
workspaceDiagnostics = mkMappingOption "Workspace diagnostics [trouble]" "<leader>lwd";
|
||||||
documentDiagnostics = mkMappingOption "Document diagnostics [trouble]" "<leader>ld";
|
documentDiagnostics = mkMappingOption "Document diagnostics [trouble]" "<leader>ld";
|
||||||
lspReferences = mkMappingOption "LSP References [trouble]" "<leader>lr";
|
lspReferences = mkMappingOption "LSP References [trouble]" "<leader>lr";
|
||||||
quickfix = mkMappingOption "QuickFix [trouble]" "<leader>xq";
|
quickfix = mkMappingOption "QuickFix [trouble]" "<leader>xq";
|
||||||
locList = mkMappingOption "LOCList [trouble]" "<leader>xl";
|
locList = mkMappingOption "LOCList [trouble]" "<leader>xl";
|
||||||
|
symbols = mkMappingOption "Symbols [trouble]" "<leader>xs";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,6 +25,15 @@
|
||||||
(removeAttrs spec ["package" "setupModule" "setupOpts" "keys"])
|
(removeAttrs spec ["package" "setupModule" "setupOpts" "keys"])
|
||||||
// {
|
// {
|
||||||
"@1" = name;
|
"@1" = name;
|
||||||
|
beforeAll =
|
||||||
|
if spec.beforeAll != null
|
||||||
|
then
|
||||||
|
mkLuaInline ''
|
||||||
|
function()
|
||||||
|
${spec.beforeAll}
|
||||||
|
end
|
||||||
|
''
|
||||||
|
else null;
|
||||||
before =
|
before =
|
||||||
if spec.before != null
|
if spec.before != null
|
||||||
then
|
then
|
||||||
|
|
Loading…
Reference in a new issue