dev: cleanup

This commit is contained in:
NotAShelf 2023-07-30 16:00:18 +03:00
parent c766e8cf27
commit 7f7926fbbb
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
2 changed files with 186 additions and 181 deletions

View file

@ -24,47 +24,9 @@ in {
]; ];
vim.luaConfigRC.nvimtreelua = nvim.dag.entryAnywhere '' vim.luaConfigRC.nvimtreelua = nvim.dag.entryAnywhere ''
${
lib.optionalString (cfg.openOnSetup) ''
-- 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 })
''
}
${ ${
lib.optionalString (cfg.disableNetrw) '' lib.optionalString (cfg.disableNetrw) ''
-- disable netrew completely
vim.g.loaded_netrw = 1 vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1 vim.g.loaded_netrwPlugin = 1
'' ''
@ -143,164 +105,204 @@ in {
view = { view = {
centralize_selection = ${boolToString cfg.view.centralizeSelection}, centralize_selection = ${boolToString cfg.view.centralizeSelection},
cursorline = ${boolToString cfg.view.cursorline}, cursorline = ${boolToString cfg.view.cursorline},
debounce_delay = ${toString cfg.view.debounceDelay}, debounce_delay = ${toString cfg.view.debounceDelay},
width = ${nvim.lua.expToLua cfg.view.width}, width = ${nvim.lua.expToLua cfg.view.width},
side = "${cfg.view.side}", side = "${cfg.view.side}",
preserve_window_proportions = ${boolToString cfg.view.preserveWindowProportions}, preserve_window_proportions = ${boolToString cfg.view.preserveWindowProportions},
number = ${boolToString cfg.view.number}, number = ${boolToString cfg.view.number},
relativenumber = ${boolToString cfg.view.relativenumber}, relativenumber = ${boolToString cfg.view.relativenumber},
signcolumn = "${cfg.view.signcolumn}", signcolumn = "${cfg.view.signcolumn}",
float = { float = {
enable = ${boolToString cfg.view.float.enable}, enable = ${boolToString cfg.view.float.enable},
quit_on_focus_loss = ${boolToString cfg.view.float.quitOnFocusLoss}, quit_on_focus_loss = ${boolToString cfg.view.float.quitOnFocusLoss},
open_win_config = { open_win_config = {
relative = "${cfg.view.float.openWinConfig.relative}", relative = "${cfg.view.float.openWinConfig.relative}",
border = "${cfg.view.float.openWinConfig.border}", border = "${cfg.view.float.openWinConfig.border}",
width = ${toString cfg.view.float.openWinConfig.width}, width = ${toString cfg.view.float.openWinConfig.width},
height = ${toString cfg.view.float.openWinConfig.height}, height = ${toString cfg.view.float.openWinConfig.height},
row = ${toString cfg.view.float.openWinConfig.row}, row = ${toString cfg.view.float.openWinConfig.row},
col = ${toString cfg.view.float.openWinConfig.col}, col = ${toString cfg.view.float.openWinConfig.col},
},
},
},
renderer = {
add_trailing = ${boolToString cfg.renderer.addTrailing},
group_empty = ${boolToString cfg.renderer.groupEmpty},
full_name = ${boolToString cfg.renderer.fullName},
highlight_git = ${boolToString cfg.renderer.highlightGit},
highlight_opened_files = ${cfg.renderer.highlightOpenedFiles},
highlight_modified = ${cfg.renderer.highlightModified},
root_folder_label = ${nvim.lua.expToLua cfg.renderer.rootFolderLabel},
indent_width = ${toString cfg.renderer.indentWidth},
indent_markers = {
enable = ${boolToString cfg.renderer.indentMarkers.enable},
inline_arrows = ${boolToString cfg.renderer.indentMarkers.inlineArrows},
icons = ${nvim.lua.expToLua cfg.renderer.indentMarkers.icons},
},
special_files = ${nvim.lua.listToLuaTable cfg.renderer.specialFiles},
symlink_destination = ${boolToString cfg.renderer.symlinkDestination},
icons = {
webdev_colors = ${boolToString cfg.renderer.icons.webdevColors},
git_placement = "${cfg.renderer.icons.gitPlacement}",
modified_placement = "${cfg.renderer.icons.modifiedPlacement}",
padding = "${cfg.renderer.icons.padding}",
symlink_arrow = "${cfg.renderer.icons.symlinkArrow}",
show = {
git = ${boolToString cfg.renderer.icons.show.git},
folder = ${boolToString cfg.renderer.icons.show.folder},
folder_arrow = ${boolToString cfg.renderer.icons.show.folderArrow},
file = ${boolToString cfg.renderer.icons.show.file},
modified = ${boolToString cfg.renderer.icons.show.modified},
},
glyphs = {
default = "${cfg.renderer.icons.glyphs.default}",
symlink = "${cfg.renderer.icons.glyphs.symlink}",
modified = "${cfg.renderer.icons.glyphs.modified}",
folder = {
default = "${cfg.renderer.icons.glyphs.folder.default}",
open = "${cfg.renderer.icons.glyphs.folder.open}",
arrow_open = "${cfg.renderer.icons.glyphs.folder.arrowOpen}",
arrow_closed = "${cfg.renderer.icons.glyphs.folder.arrowClosed}",
empty = "${cfg.renderer.icons.glyphs.folder.empty}",
empty_open = "${cfg.renderer.icons.glyphs.folder.emptyOpen}",
symlink = "${cfg.renderer.icons.glyphs.folder.symlink}",
symlink_open = "${cfg.renderer.icons.glyphs.folder.symlinkOpen}",
},
git = {
unstaged = "${cfg.renderer.icons.glyphs.git.unstaged}",
staged = "${cfg.renderer.icons.glyphs.git.staged}",
unmerged = "${cfg.renderer.icons.glyphs.git.unmerged}",
renamed = "${cfg.renderer.icons.glyphs.git.renamed}",
untracked = "${cfg.renderer.icons.glyphs.git.untracked}",
deleted = "${cfg.renderer.icons.glyphs.git.deleted}",
ignored = "${cfg.renderer.icons.glyphs.git.ignored}",
},
},
},
},
filters = {
git_ignored = ${boolToString cfg.filters.gitIgnored},
dotfiles = ${boolToString cfg.filters.dotfiles},
git_clean = ${boolToString cfg.filters.gitClean},
no_buffer = ${boolToString cfg.filters.noBuffer},
exclude = ${nvim.lua.listToLuaTable cfg.filters.exclude},
},
trash = {
cmd = "${cfg.trash.cmd}",
},
actions = {
use_system_clipboard = ${boolToString cfg.actions.useSystemClipboard},
change_dir = {
enable = ${boolToString cfg.actions.changeDir.enable},
global = ${boolToString cfg.actions.changeDir.global},
restrict_above_cwd = ${boolToString cfg.actions.changeDir.restrictAboveCwd},
},
expand_all = {
max_folder_discovery = ${toString cfg.actions.expandAll.maxFolderDiscovery},
exclude = ${nvim.lua.listToLuaTable cfg.actions.expandAll.exclude},
},
file_popup = {
open_win_config = ${nvim.lua.expToLua cfg.actions.filePopup.openWinConfig},
},
open_file = {
quit_on_open = ${boolToString cfg.actions.openFile.quitOnOpen},
eject = ${boolToString cfg.actions.openFile.eject},
resize_window = ${boolToString cfg.actions.openFile.resizeWindow},
window_picker = {
enable = ${boolToString cfg.actions.openFile.windowPicker.enable},
picker = "${cfg.actions.openFile.windowPicker.picker}",
chars = "${cfg.actions.openFile.windowPicker.chars}",
exclude = {
filetype = ${nvim.lua.listToLuaTable cfg.actions.openFile.windowPicker.exclude.filetype},
buftype = ${nvim.lua.listToLuaTable cfg.actions.openFile.windowPicker.exclude.buftype},
}, },
}, },
}, },
renderer = { remove_file = {
add_trailing = ${boolToString cfg.renderer.addTrailing}, close_window = ${boolToString cfg.actions.removeFile.closeWindow},
group_empty = ${boolToString cfg.renderer.groupEmpty}, },
full_name = ${boolToString cfg.renderer.fullName}, },
highlight_git = ${boolToString cfg.renderer.highlightGit},
highlight_opened_files = ${cfg.renderer.highlightOpenedFiles},
highlight_modified = ${cfg.renderer.highlightModified},
root_folder_label = ${nvim.lua.expToLua cfg.renderer.rootFolderLabel},
indent_width = ${toString cfg.renderer.indentWidth},
indent_markers = {
enable = ${boolToString cfg.renderer.indentMarkers.enable},
inline_arrows = ${boolToString cfg.renderer.indentMarkers.inlineArrows},
icons = ${nvim.lua.expToLua cfg.renderer.indentMarkers.icons},
},
special_files = ${nvim.lua.listToLuaTable cfg.renderer.specialFiles}, live_filter = {
symlink_destination = ${boolToString cfg.renderer.symlinkDestination}, prefix = "${cfg.liveFilter.prefix}",
always_show_folders = ${boolToString cfg.liveFilter.alwaysShowFolders},
},
icons = { tab = {
webdev_colors = ${boolToString cfg.renderer.icons.webdevColors}, sync = {
git_placement = "${cfg.renderer.icons.gitPlacement}", open = ${boolToString cfg.tab.sync.open},
modified_placement = "${cfg.renderer.icons.modifiedPlacement}", close = ${boolToString cfg.tab.sync.close},
padding = "${cfg.renderer.icons.padding}", ignore = ${nvim.lua.listToLuaTable cfg.tab.sync.ignore},
symlink_arrow = "${cfg.renderer.icons.symlinkArrow}", },
},
show = { notify = {
git = ${boolToString cfg.renderer.icons.show.git}, threshold = vim.log.levels.${cfg.notify.threshold},
folder = ${boolToString cfg.renderer.icons.show.folder}, absolute_path = ${boolToString cfg.notify.absolutePath},
folder_arrow = ${boolToString cfg.renderer.icons.show.folderArrow}, },
file = ${boolToString cfg.renderer.icons.show.file},
modified = ${boolToString cfg.renderer.icons.show.modified},
},
glyphs = { ui = {
default = "${cfg.renderer.icons.glyphs.default}", confirm = {
symlink = "${cfg.renderer.icons.glyphs.symlink}", remove = ${boolToString cfg.ui.confirm.remove},
modified = "${cfg.renderer.icons.glyphs.modified}", trash = ${boolToString cfg.ui.confirm.trash},
},
},
})
folder = { -- autostart behaviour
default = "${cfg.renderer.icons.glyphs.folder.default}", ${
open = "${cfg.renderer.icons.glyphs.folder.open}", lib.optionalString (cfg.openOnSetup) ''
arrow_open = "${cfg.renderer.icons.glyphs.folder.arrowOpen}", -- Open on startup has been deprecated
arrow_closed = "${cfg.renderer.icons.glyphs.folder.arrowClosed}", -- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup
empty = "${cfg.renderer.icons.glyphs.folder.empty}",
empty_open = "${cfg.renderer.icons.glyphs.folder.emptyOpen}",
symlink = "${cfg.renderer.icons.glyphs.folder.symlink}",
symlink_open = "${cfg.renderer.icons.glyphs.folder.symlinkOpen}",
},
git = { -- use a nix eval to dynamically insert the open on startup function
unstaged = "${cfg.renderer.icons.glyphs.git.unstaged}", local function open_nvim_tree(data)
staged = "${cfg.renderer.icons.glyphs.git.staged}", local IGNORED_FT = {
unmerged = "${cfg.renderer.icons.glyphs.git.unmerged}", "markdown",
renamed = "${cfg.renderer.icons.glyphs.git.renamed}", }
untracked = "${cfg.renderer.icons.glyphs.git.untracked}",
deleted = "${cfg.renderer.icons.glyphs.git.deleted}",
ignored = "${cfg.renderer.icons.glyphs.git.ignored}",
},
},
},
},
filters = { -- buffer is a real file on the disk
git_ignored = ${boolToString cfg.filters.gitIgnored}, local real_file = vim.fn.filereadable(data.file) == 1
dotfiles = ${boolToString cfg.filters.dotfiles},
git_clean = ${boolToString cfg.filters.gitClean},
no_buffer = ${boolToString cfg.filters.noBuffer},
exclude = ${nvim.lua.listToLuaTable cfg.filters.exclude},
},
trash = { -- buffer is a [No Name]
cmd = "${cfg.trash.cmd}", local no_name = data.file == "" and vim.bo[data.buf].buftype == ""
},
actions = { -- &ft
use_system_clipboard = ${boolToString cfg.actions.useSystemClipboard}, local filetype = vim.bo[data.buf].ft
change_dir = {
enable = ${boolToString cfg.actions.changeDir.enable},
global = ${boolToString cfg.actions.changeDir.global},
restrict_above_cwd = ${boolToString cfg.actions.changeDir.restrictAboveCwd},
},
expand_all = { -- only files please
max_folder_discovery = ${toString cfg.actions.expandAll.maxFolderDiscovery}, if not real_file and not no_name then
exclude = ${nvim.lua.listToLuaTable cfg.actions.expandAll.exclude}, return
}, end
file_popup = { -- skip ignored filetypes
open_win_config = ${nvim.lua.expToLua cfg.actions.filePopup.openWinConfig}, if vim.tbl_contains(IGNORED_FT, filetype) then
}, return
end
open_file = { -- open the tree but don't focus it
quit_on_open = ${boolToString cfg.actions.openFile.quitOnOpen}, require("nvim-tree.api").tree.toggle({ focus = false })
eject = ${boolToString cfg.actions.openFile.eject}, end
resize_window = ${boolToString cfg.actions.openFile.resizeWindow},
window_picker = {
enable = ${boolToString cfg.actions.openFile.windowPicker.enable},
picker = "${cfg.actions.openFile.windowPicker.picker}",
chars = "${cfg.actions.openFile.windowPicker.chars}",
exclude = {
filetype = ${nvim.lua.listToLuaTable cfg.actions.openFile.windowPicker.exclude.filetype},
buftype = ${nvim.lua.listToLuaTable cfg.actions.openFile.windowPicker.exclude.buftype},
},
},
},
remove_file = { -- function to automatically open the tree on VimEnter
close_window = ${boolToString cfg.actions.removeFile.closeWindow}, vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
}, ''
}, }
live_filter = {
prefix = "${cfg.liveFilter.prefix}",
always_show_folders = ${boolToString cfg.liveFilter.alwaysShowFolders},
},
tab = {
sync = {
open = ${boolToString cfg.tab.sync.open},
close = ${boolToString cfg.tab.sync.close},
ignore = ${nvim.lua.listToLuaTable cfg.tab.sync.ignore},
},
},
notify = {
threshold = vim.log.levels.${cfg.notify.threshold},
absolute_path = ${boolToString cfg.notify.absolutePath},
},
ui = {
confirm = {
remove = ${boolToString cfg.ui.confirm.remove},
trash = ${boolToString cfg.ui.confirm.trash},
},
},
})
''; '';
}; };
} }

View file

@ -260,10 +260,12 @@ with builtins; {
severity = mkOption { severity = mkOption {
description = "Severity for which the diagnostics will be displayed. See `:help diagnostic-severity`"; description = "Severity for which the diagnostics will be displayed. See `:help diagnostic-severity`";
default = { default = {
min = "HINT"; min = "HINT";
max = "ERROR"; max = "ERROR";
}; };
type = types.submodule { type = types.submodule {
options = { options = {
min = mkOption { min = mkOption {
@ -306,7 +308,7 @@ with builtins; {
''; '';
}; };
timeOut = mkOption { timeout = mkOption {
type = types.int; type = types.int;
default = 400; default = 400;
description = '' description = ''
@ -472,6 +474,7 @@ with builtins; {
float = mkOption { float = mkOption {
description = "Configuration options for floating window."; description = "Configuration options for floating window.";
default = { default = {
enable = false; enable = false;
quitOnFocusLoss = true; quitOnFocusLoss = true;