diff --git a/modules/home-manager/programs/nixvim/presets/auto-save.nix b/modules/home-manager/programs/nixvim/presets/auto-save.nix index ed98562..b6b86c1 100644 --- a/modules/home-manager/programs/nixvim/presets/auto-save.nix +++ b/modules/home-manager/programs/nixvim/presets/auto-save.nix @@ -5,14 +5,7 @@ in { options.presets.auto-save = { enable = lib.mkEnableOption "auto save"; - varName = lib.mkOption { - type = lib.types.str; - default = "disable_autosave"; - }; - commandName = lib.mkOption { - type = lib.types.str; - default = "AutoSaveToggle"; - }; + disableOnStart = lib.mkEnableOption "disable auto save on start"; event = lib.mkOption { type = lib.types.listOf lib.types.str; default = [ @@ -25,15 +18,18 @@ in config = lib.mkIf cfg.enable { extraConfigLua = # lua '' - function AutoSave() - if not vim.b.${cfg.varName} and not vim.g.${cfg.varName} then - local bufnr = vim.api.nvim_get_current_buf() - local modified = vim.api.nvim_buf_get_option(bufnr, 'modified') - if modified then - vim.cmd('silent! w') - print("Auto save at " .. os.date("%H:%M:%S")) - end - end + function PerformAutoSave(buf) + buf = buf or vim.api.nvim_get_current_buf() + + if vim.b.disable_autosave or vim.g.disable_autosave then return end + if vim.fn.getbufvar(buf, "&modifiable") ~= 1 then return end + if not vim.api.nvim_buf_get_option(buf, 'modified') then return end + if vim.api.nvim_buf_get_option(buf, 'buftype') ~= "" then return end + + vim.api.nvim_buf_call(buf, function() + vim.cmd('silent! w') + print("Auto save at " .. os.date("%H:%M:%S")) + end) end ''; @@ -41,19 +37,22 @@ in { event = cfg.event; pattern = [ "*" ]; - command = "lua AutoSave()"; + callback.__raw = # lua + "function(args) PerformAutoSave(args.buf) end"; } ]; - userCommands.${cfg.commandName} = { + globals.disable_autosave = cfg.disableOnStart; + + userCommands.ToggleAutoSave = { bang = true; command.__raw = # lua '' function(args) if args.bang then - vim.b.${cfg.varName} = not vim.b.${cfg.varName} + vim.b.disable_autosave = not vim.b.disable_autosave else - vim.g.${cfg.varName} = not vim.g.${cfg.varName} + vim.g.disable_autosave = not vim.g.disable_autosave end local lualine, lib = pcall(require, 'lualine') if lualine then @@ -68,13 +67,13 @@ in key = "as"; mode = "n"; options.silent = true; - action = ":${cfg.commandName}"; + action = ":ToggleAutoSave"; } { key = "aS"; mode = "n"; options.silent = true; - action = ":${cfg.commandName}!"; + action = ":ToggleAutoSave!"; } ]; @@ -87,15 +86,12 @@ in }; }; - neo-tree.eventHandlers.window_before_open = # lua - '' - function() - AutoSave() - end - ''; + /*neo-tree.eventHandlers.window_before_open = # lua + "function() PerformAutoSave() end";*/ lualine.sections.lualine_x = lib.mkOrder 700 [ - "(vim.g.${cfg.varName} or vim.b.${cfg.varName}) and '󱙃' or nil" + # lua + "(vim.g.disable_autosave or vim.b.disable_autosave) and '󱙃' or nil" ]; }; }; diff --git a/modules/home-manager/programs/nixvim/presets/base/diagnostics.nix b/modules/home-manager/programs/nixvim/presets/base/diagnostics.nix index 10a3269..ea4ee7c 100644 --- a/modules/home-manager/programs/nixvim/presets/base/diagnostics.nix +++ b/modules/home-manager/programs/nixvim/presets/base/diagnostics.nix @@ -87,7 +87,6 @@ in R = "Restart LSP"; d = "Definitions"; i = "Implementations"; - s = "Document Symbols"; w = "Workspace Symbols"; t = "Type Definitions"; h = "Diagnostics"; diff --git a/modules/home-manager/programs/nixvim/presets/base/tree.nix b/modules/home-manager/programs/nixvim/presets/base/tree.nix index 952d508..a38ac58 100644 --- a/modules/home-manager/programs/nixvim/presets/base/tree.nix +++ b/modules/home-manager/programs/nixvim/presets/base/tree.nix @@ -13,6 +13,10 @@ in key = "ft"; action = ":Neotree toggle"; } + { + key = "ss"; + action = ":Neotree document_symbols right toggle"; + } ]; plugins = { neo-tree = { @@ -22,15 +26,19 @@ in followCurrentFile.enabled = true; filteredItems.visible = true; }; + extraSources = [ "document_symbols" ]; popupBorderStyle = "rounded"; - eventHandlers.file_opened = # lua + eventHandlers.neo_tree_buffer_leave = # lua '' function() require('neo-tree').close_all() end ''; }; - which-key.registrations."f".t = "Tree"; + which-key.registrations = { + "f".t = "Tree"; + "s".s = "Document Symbols"; + }; }; }; } diff --git a/modules/home-manager/theme/nvim.vim b/modules/home-manager/theme/nvim.vim index 53a0672..9b309ad 100644 --- a/modules/home-manager/theme/nvim.vim +++ b/modules/home-manager/theme/nvim.vim @@ -44,6 +44,9 @@ end hi! Pmenu ctermbg=none guibg=none guifg={{colors.on_surface.default.hex}} hi! PmenuSel guibg={{colors.primary.default.hex}} guifg={{colors.on_primary.default.hex}} +hi! PmenuThumb guifg=none guifg={{colors.primary.default.hex}} +hi! link NormalFloat Normal +hi! FloatBorder guifg={{colors.primary.default.hex}} hi! CursorColumn guibg={{colors.primary.default.hex}} guifg={{colors.on_primary.default.hex}} hi! CursorLine guibg={{colors.primary.default.hex}} guifg={{colors.on_primary.default.hex}} hi! WildMenu guibg={{colors.primary.default.hex}} guifg={{colors.on_primary.default.hex}} @@ -109,9 +112,9 @@ hi! NeoTreeGitConflict guifg={{colors.danger.default.hex}} hi! NeoTreeGitUntracked guifg={{colors.blue.default.hex}} hi! NonText guifg={{colors.outline_variant.default.hex}} -hi! LineNr guifg={{colors.outline_variant.default.hex}} hi! CursorLineNr guifg={{colors.on_surface.default.hex}} hi! SignColumn guibg=none guifg={{colors.on_surface.default.hex}} +hi! LineNr guifg={{colors.secondary.default.hex}} hi! IblScope guifg={{colors.on_surface.default.hex}} hi! @ibl.scope.char.1 guifg={{colors.on_surface.default.hex}} @@ -129,7 +132,9 @@ hi! @variable guifg={{colors.on_surface.default.hex}} hi! Operator guifg={{colors.on_surface.default.hex}} hi! Delimiter guifg={{colors.on_surface.default.hex}} hi! Statement gui=bold guifg={{colors.on_surface.default.hex}} + hi! link Operator Normal +hi! link @punctuation.special @punctuation hi! @conditional.ternary guifg={{colors.on_surface.default.hex}} hi! link @keyword.conditional.ternary Operator hi! link Delimiter Normal @@ -140,6 +145,11 @@ hi! @lsp.mod.defaultLibrary gui=bold hi! @lsp.mod.readonly gui=italic hi! Constant guifg={{colors.constants.default.hex}} +hi! link @variable Constant +hi! link @variable.parameter Identifier +hi! link @lsp.typemod.variable.local Identifier +hi! link @variable.python Identifier +hi! link @variable.lua Identifier hi! @property guifg={{colors.properties.default.hex}} hi! link @field @property @@ -151,9 +161,6 @@ hi! link @lsp.type.property @property hi! link @attribute @property hi! link @tag.attribute @property -hi! link @lsp.type.variable Constant -hi! link @lsp.typemod.variable.local Identifier - hi! Keyword guifg={{colors.keywords.default.hex}} hi! Special guifg={{colors.keywords.default.hex}} hi! link Character Keyword @@ -165,6 +172,17 @@ hi! link Include Keyword hi! link Conditional Keyword hi! link @type.builtin Keyword +hi! link NotifyERRORIcon NotifyERRORBorder +hi! link NotifyWARNIcon NotifyWARNBorder +hi! link NotifyINFOIcon NotifyINFOBorder +hi! link NotifyTRACEIcon NotifyTRACEBorder +hi! link NotifyDEBUGIcon NotifyDEBUGBorder +hi! link NotifyERRORTitle NotifyERRORBorder +hi! link NotifyWARNTitle NotifyWARNBorder +hi! link NotifyINFOTitle NotifyINFOBorder +hi! link NotifyTRACETitle NotifyTRACEBorder +hi! link NotifyDEBUGTitle NotifyDEBUGBorder + hi! Number guifg={{colors.numbers.default.hex}} hi! Function guifg={{colors.functions.default.hex}} @@ -172,6 +190,11 @@ hi! Structure guifg={{colors.structures.default.hex}} hi! link PreProc Structure hi! link Tag Structure hi! link @attribute.typescript Structure +hi! link @lsp.type.decorator Structure +hi! link @lsp.type.attributeBracket Structure +hi! link @keyword.directive.cpp PreProc +hi! link @keyword.directive.define.cpp PreProc +hi! link @keyword.import.cpp PreProc hi! Type gui=none guifg={{colors.types.default.hex}} hi! link @lsp.type.interface Type