diff --git a/init.lua b/init.lua index 6d209f4..e85085c 100644 --- a/init.lua +++ b/init.lua @@ -52,13 +52,21 @@ vim.opt.scrolloff = math.floor(vim.o.lines / 2) - 3 -- Indent vim.o.autoindent = true --- Rebind 'i' to indent properly on empty lines + vim.keymap.set("n", "i", function() if vim.fn.getline("."):match("^%s*$") then return [["_cc]] else return "i" end +end, { expr = true, desc = "Inent properly on empty lines" }) + +vim.keymap.set("n", "a", function() + if vim.fn.getline("."):match("^%s*$") then + return [["_cc]] + else + return "a" + end end, { expr = true, desc = "Indent properly on empty lines" }) -- Force proper keybindings @@ -70,8 +78,6 @@ vim.keymap.set("n", "", 'echo "Use j to move!!"') -- C-BS for deleting whole word in insert mode vim.keymap.set("i", "", "", { noremap = true }) --- Setup notifications - -- Keybinds for MiniSessions vim.keymap.set("n", "qj", function() -- quit and save session local MiniSessions.write(".session") diff --git a/lua/plugins/completion/blink.lua b/lua/plugins/completion/blink.lua index e02a7ee..1128a72 100644 --- a/lua/plugins/completion/blink.lua +++ b/lua/plugins/completion/blink.lua @@ -36,13 +36,13 @@ return { -- "cmdline", -- Generally configured separately, but often included by default }, providers = { - lazydev = { - name = "LazyDev", - module = "lazydev.integrations.blink", - -- make lazydev completions top priority (see `:h blink.cmp`) - score_offset = 100, - }, - }, + lazydev = { + name = "LazyDev", + module = "lazydev.integrations.blink", + -- make lazydev completions top priority (see `:h blink.cmp`) + score_offset = 100, + }, + }, }, }, } diff --git a/lua/plugins/completion/conform.lua b/lua/plugins/completion/conform.lua index f8492df..7284997 100644 --- a/lua/plugins/completion/conform.lua +++ b/lua/plugins/completion/conform.lua @@ -9,6 +9,7 @@ return { nix = { "nixfmt" }, }, format_on_save = true, + undojoin = true, }) end, } diff --git a/lua/plugins/functional/autosave.lua b/lua/plugins/functional/autosave.lua new file mode 100644 index 0000000..af53d64 --- /dev/null +++ b/lua/plugins/functional/autosave.lua @@ -0,0 +1,47 @@ +return { + "okuuva/auto-save.nvim", + version = "^1.0.0", -- see https://devhints.io/semver, alternatively use '*' to use the latest tagged release + cmd = "ASToggle", -- optional for lazy loading on command + event = { "InsertLeave", "TextChanged" }, + opts = {}, + config = function(opts) + require("auto-save").setup({ + enabled = true, + trigger_events = { -- See :h events + immediate_save = { "BufLeave", "FocusLost", "QuitPre", "VimSuspend" }, -- vim events that trigger an immediate save + defer_save = { "InsertLeave" }, -- vim events that trigger a deferred save (saves after `debounce_delay`) + cancel_deferred_save = { "InsertEnter" }, -- vim events that cancel a pending deferred save + }, + debounce_delay = 1000, + noautocmd = true, + }) + local group = vim.api.nvim_create_augroup("autosave", {}) + + vim.api.nvim_create_autocmd("User", { + pattern = "AutoSaveWritePre", + group = group, + callback = function(opts) + if opts.data.saved_buffer ~= nil then + local filename = vim.fn.expand("%:t") + print("Saved '" .. filename .. "' at " .. vim.fn.strftime("%H:%M:%S")) + end + end, + }) + + vim.api.nvim_create_autocmd("User", { + pattern = "AutoSaveEnable", + group = group, + callback = function(opts) + print("AutoSave enabled") + end, + }) + + vim.api.nvim_create_autocmd("User", { + pattern = "AutoSaveDisable", + group = group, + callback = function(opts) + print("AutoSave disabled") + end, + }) + end, +} diff --git a/lua/plugins/functional/neorg.lua b/lua/plugins/functional/neorg.lua index df80fd8..630d5be 100644 --- a/lua/plugins/functional/neorg.lua +++ b/lua/plugins/functional/neorg.lua @@ -2,12 +2,17 @@ return { "nvim-neorg/neorg", lazy = false, version = "*", - dependencies = { { "nvim-lua/plenary.nvim" }, { "nvim-neorg/neorg-telescope" } }, + dependencies = { { "nvim-lua/plenary.nvim" }, { "nvim-neorg/neorg-telescope" }, { "benlubas/neorg-interim-ls" } }, config = function() require("neorg").setup({ load = { ["core.defaults"] = {}, ["core.concealer"] = {}, + ["core.integrations.treesitter"] = {}, + ["core.looking-glass"] = {}, + ["core.completion"] = { + config = { engine = { module_name = "external.lsp-completion" } }, + }, ["core.dirman"] = { config = { workspaces = { @@ -25,6 +30,24 @@ return { }, }, }, + ["external.interim-ls"] = { + config = { + -- default config shown + completion_provider = { + -- Enable or disable the completion provider + enable = true, + + -- Show file contents as documentation when you complete a file name + documentation = true, + + -- Try to complete categories provided by Neorg Query. Requires `benlubas/neorg-query` + categories = false, + + -- suggest heading completions from the given file for `{@x|}` where `|` is your cursor + -- and `x` is an alphanumeric character. `{@name}` expands to `[name]{:$/people:# name}` + }, + }, + }, }, }) vim.wo.foldlevel = 99 diff --git a/lua/plugins/ui/noice.lua b/lua/plugins/ui/noice.lua index ef81f2e..1eb5f0f 100644 --- a/lua/plugins/ui/noice.lua +++ b/lua/plugins/ui/noice.lua @@ -5,7 +5,7 @@ return { require("noice").setup({ messages = { enabled = true, - view = "notify", + view = "mini", view_error = "notify", -- view for errors view_warn = "notify", -- view for warnings view_history = "messages", -- view for :messages