From 8dab7cb3a625a16a888125a17b459495d0b0f9a5 Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Tue, 24 Dec 2024 23:07:16 +0100 Subject: [PATCH] Update nvim config --- .chezmoiignore | 5 +- dot_config/kitty/kitty.conf.tmpl | 5 +- dot_config/nvim/lua/config/autocmds.lua | 36 ++++++ dot_config/nvim/lua/config/keymaps.lua | 14 +++ dot_config/nvim/lua/config/lazy.lua | 24 ++-- dot_config/nvim/lua/config/options.lua | 2 + dot_config/nvim/lua/plugins/coding.lua | 10 -- dot_config/nvim/lua/plugins/colorscheme.lua | 13 --- dot_config/nvim/lua/plugins/notes.lua | 27 +++++ dot_config/nvim/lua/plugins/notes.lua.tmpl | 83 ------------- dot_config/nvim/lua/plugins/ui.lua | 122 +------------------- 11 files changed, 91 insertions(+), 250 deletions(-) delete mode 100644 dot_config/nvim/lua/plugins/colorscheme.lua create mode 100644 dot_config/nvim/lua/plugins/notes.lua delete mode 100644 dot_config/nvim/lua/plugins/notes.lua.tmpl diff --git a/.chezmoiignore b/.chezmoiignore index 0f270d5..e1229d6 100644 --- a/.chezmoiignore +++ b/.chezmoiignore @@ -11,7 +11,6 @@ LICENSE .xsession .config/openbox/* .config/nvim/lua/plugins/lsp.lua -{{ else }} -.config/fish/conf.d/fish-ssh-agent.fish -.config/fish/functions/__ssh_agent_* +.config/nvim/lazy-lock.json +.config/nvim/lazyvim.json {{ end }} diff --git a/dot_config/kitty/kitty.conf.tmpl b/dot_config/kitty/kitty.conf.tmpl index b8f55ed..29a3f75 100644 --- a/dot_config/kitty/kitty.conf.tmpl +++ b/dot_config/kitty/kitty.conf.tmpl @@ -180,8 +180,6 @@ enabled_layouts Horizontal,Stack tab_bar_edge top tab_bar_style separator tab_separator "" -tab_title_template " {index} {title} " -tab_bar_background #434C5E shell {{ .shell }} editor nvim @@ -603,7 +601,8 @@ map kitty_mod+R set_tab_title # BEGIN_KITTY_THEME -include Nord.conf +# Catppuccin-Mocha +include current-theme.conf # END_KITTY_THEME # BEGIN_KITTY_FONTS diff --git a/dot_config/nvim/lua/config/autocmds.lua b/dot_config/nvim/lua/config/autocmds.lua index af027fb..4b3202c 100644 --- a/dot_config/nvim/lua/config/autocmds.lua +++ b/dot_config/nvim/lua/config/autocmds.lua @@ -11,5 +11,41 @@ vim.api.nvim_create_autocmd("FileType", { vim.opt_local.softtabstop = 2 vim.opt_local.shiftwidth = 2 vim.opt_local.expandtab = true + + -- Add the key mappings only for Markdown files in a zk notebook. + if require("zk.util").notebook_root(vim.fn.expand("%:p")) ~= nil then + local function map(...) + vim.api.nvim_buf_set_keymap(0, ...) + end + local opts = { noremap = true, silent = false } + + -- Open the link under the caret. + map("n", "", "lua vim.lsp.buf.definition()", opts) + + -- Create a new note after asking for its title. + -- This overrides the global `zn` mapping to create the note in the same directory as the current buffer. + map("n", "zn", "ZkNew { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }", opts) + -- Create a new note in the same directory as the current buffer, using the current selection for title. + map("v", "znt", ":'<,'>ZkNewFromTitleSelection { dir = vim.fn.expand('%:p:h') }", opts) + -- Create a new note in the same directory as the current buffer, using the current selection for note content and asking for its title. + map( + "v", + "znc", + ":'<,'>ZkNewFromContentSelection { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }", + opts + ) + + -- Open notes linking to the current buffer. + map("n", "zb", "ZkBacklinks", opts) + -- Alternative for backlinks using pure LSP and showing the source context. + --map('n', 'zb', 'lua vim.lsp.buf.references()', opts) + -- Open notes linked by the current buffer. + map("n", "zl", "ZkLinks", opts) + + -- Preview a linked note. + map("n", "K", "lua vim.lsp.buf.hover()", opts) + -- Open the code actions for a visual selection. + map("v", "za", ":'<,'>lua vim.lsp.buf.range_code_action()", opts) + end end, }) diff --git a/dot_config/nvim/lua/config/keymaps.lua b/dot_config/nvim/lua/config/keymaps.lua index edb8f6a..c93df70 100644 --- a/dot_config/nvim/lua/config/keymaps.lua +++ b/dot_config/nvim/lua/config/keymaps.lua @@ -19,3 +19,17 @@ map("n", "td", "require('dap-go').debug_test()") map("n", "to", "require('neotest').output.open({enter = true})") map("n", "tS", "require('neotest').run.stop()") map("n", "ts", "require('neotest').summary.toggle()") + +-- zk +-- Create a new note after asking for its title. +map("n", "zn", "ZkNew { title = vim.fn.input('Title: ') }") + +-- Open notes. +map("n", "zo", "ZkNotes { sort = { 'modified' } }") +-- Open notes associated with the selected tags. +map("n", "zt", "ZkTags") + +-- Search for the notes matching a given query. +map("n", "zf", "ZkNotes { sort = { 'modified' }, match = { vim.fn.input('Search: ') } }") +-- Search for the notes matching the current visual selection. +map("v", "zf", ":'<,'>ZkMatch") diff --git a/dot_config/nvim/lua/config/lazy.lua b/dot_config/nvim/lua/config/lazy.lua index d73bfa1..ec08493 100644 --- a/dot_config/nvim/lua/config/lazy.lua +++ b/dot_config/nvim/lua/config/lazy.lua @@ -1,23 +1,16 @@ local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not (vim.uv or vim.loop).fs_stat(lazypath) then - local lazyrepo = "https://github.com/folke/lazy.nvim.git" - local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) - if vim.v.shell_error ~= 0 then - vim.api.nvim_echo({ - { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, - { out, "WarningMsg" }, - { "\nPress any key to exit..." }, - }, true, {}) - vim.fn.getchar() - os.exit(1) - end +if not vim.loop.fs_stat(lazypath) then + -- bootstrap lazy.nvim + -- stylua: ignore + vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath }) end -vim.opt.rtp:prepend(lazypath) +vim.opt.rtp:prepend(vim.env.LAZY or lazypath) require("lazy").setup({ spec = { -- add LazyVim and import its plugins { "LazyVim/LazyVim", import = "lazyvim.plugins" }, + -- import any extras modules here -- import/override with your plugins { import = "plugins" }, }, @@ -31,10 +24,7 @@ require("lazy").setup({ -- version = "*", -- try installing the latest stable version for plugins that support semver }, install = { colorscheme = { "tokyonight", "habamax" } }, - checker = { - enabled = true, -- check for plugin updates periodically - notify = false, -- notify on update - }, -- automatically check for plugin updates + checker = { enabled = true, notify = false, frequency = 259200 }, -- automatically check for plugin updates performance = { rtp = { -- disable some rtp plugins diff --git a/dot_config/nvim/lua/config/options.lua b/dot_config/nvim/lua/config/options.lua index 3ea1454..9cc496a 100644 --- a/dot_config/nvim/lua/config/options.lua +++ b/dot_config/nvim/lua/config/options.lua @@ -1,3 +1,5 @@ -- Options are automatically loaded before lazy.nvim startup -- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua -- Add any additional options here + +vim.g.snacks_animate = false diff --git a/dot_config/nvim/lua/plugins/coding.lua b/dot_config/nvim/lua/plugins/coding.lua index 57b09e3..cd50c1d 100644 --- a/dot_config/nvim/lua/plugins/coding.lua +++ b/dot_config/nvim/lua/plugins/coding.lua @@ -1,14 +1,4 @@ return { - { - "kylechui/nvim-surround", - version = "*", -- Use for stability; omit to use `main` branch for the latest features - event = "VeryLazy", - config = function() - require("nvim-surround").setup({ - -- Configuration here, or leave empty to use defaults - }) - end, - }, { "windwp/nvim-autopairs", event = "InsertEnter", diff --git a/dot_config/nvim/lua/plugins/colorscheme.lua b/dot_config/nvim/lua/plugins/colorscheme.lua deleted file mode 100644 index ac0584d..0000000 --- a/dot_config/nvim/lua/plugins/colorscheme.lua +++ /dev/null @@ -1,13 +0,0 @@ -return { - { - "shaunsingh/nord.nvim", - lazy = false, - priority = 1000, - }, - { - "LazyVim/LazyVim", - opts = { - colorscheme = "nord", - }, - }, -} diff --git a/dot_config/nvim/lua/plugins/notes.lua b/dot_config/nvim/lua/plugins/notes.lua new file mode 100644 index 0000000..9b1fa21 --- /dev/null +++ b/dot_config/nvim/lua/plugins/notes.lua @@ -0,0 +1,27 @@ +return { + { + { + "zk-org/zk-nvim", + config = function() + require("zk").setup({ + picker = "fzf_lua", + + lsp = { + config = { + cmd = { "zk", "lsp" }, + name = "zk", + -- on_attach = ... + -- etc, see `:h vim.lsp.start_client()` + }, + + -- automatically attach buffers in a zk notebook that match the given filetypes + auto_attach = { + enabled = true, + filetypes = { "markdown" }, + }, + }, + }) + end, + }, + }, +} diff --git a/dot_config/nvim/lua/plugins/notes.lua.tmpl b/dot_config/nvim/lua/plugins/notes.lua.tmpl deleted file mode 100644 index 811d07d..0000000 --- a/dot_config/nvim/lua/plugins/notes.lua.tmpl +++ /dev/null @@ -1,83 +0,0 @@ -return { - { - "renerocksai/telekasten.nvim", - lazy = true, - dependencies = { - "nvim-telescope/telescope.nvim", - "renerocksai/calendar-vim", - }, - opts = { - take_over_my_home = true, - auto_set_filetype = false, - home = "{{ .home }}/doc/zettelkasten", - dailies = "{{ .home }}/doc/zettelkasten/daily", - weeklies = "{{ .home }}/doc/zettelkasten/weekly", - templates = "{{ .home }}/doc/zettelkasten/templates", - image_subdir = "img", - extension = ".md", - new_note_filename = "uuid-title", - uuid_type = "%Y%m%d%H%M", - uuid_sep = "-", - follow_creates_nonexisting = true, - dailies_create_nonexisting = true, - weeklies_create_nonexisting = true, - journal_auto_open = false, - - -- template for new notes (new_note, follow_link) - -- set to `nil` or do not specify if you do not want a template - template_new_note = "{{ .home }}/doc/zettelkasten/templates/new_note.md", - - -- template for newly created daily notes (goto_today) - -- set to `nil` or do not specify if you do not want a template - template_new_daily = "{{ .home }}/doc/zettelkasten/templates/daily.md", - - -- template for newly created weekly notes (goto_thisweek) - -- set to `nil` or do not specify if you do not want a template - template_new_weekly = "{{ .home }}/doc/zettelkasten/templates/weekly.md", - - -- image link style - -- wiki: ![[image name]] - -- markdown: ![](image_subdir/xxxxx.png) - image_link_style = "wiki", - - -- default sort option: 'filename', 'modified' - sort = "filename", - - -- integrate with calendar-vim - plug_into_calendar = true, - calendar_opts = { - weeknm = 4, - calendar_monday = 1, - calendar_mark = "left-fit", - }, - - close_after_yanking = false, - insert_after_inserting = true, - tag_notation = "#tag", - command_palette_theme = "dropdown", - show_tags_theme = "ivy", - subdirs_in_links = true, - template_handling = "smart", - new_note_location = "smart", - rename_update_links = true, - follow_url_fallback = nil, - }, - keys = { - { "zf", "Telekasten find_notes" }, - { "zd", "Telekasten find_daily_notes" }, - { "zg", "Telekasten search_notes" }, - { "zz", "Telekasten follow_link" }, - { "zn", "Telekasten new_note" }, - { "zr", "Telekasten rename_note" }, - { "zc", "Telekasten show_calendar" }, - { "zb", "Telekasten show_backlinks" }, - { "z[", "Telekasten insert_link" }, - { "#", "Telekasten show_tags" }, - { "z", "Telekasten panel" }, - }, - init = function() - vim.api.nvim_set_hl(0, "tklink", { fg = "#689d6a", bg = "" }) - vim.api.nvim_set_hl(0, "tkBrackets", { fg = "gray", bg = "gray" }) - end, - }, -} diff --git a/dot_config/nvim/lua/plugins/ui.lua b/dot_config/nvim/lua/plugins/ui.lua index 60539b6..1de2c89 100644 --- a/dot_config/nvim/lua/plugins/ui.lua +++ b/dot_config/nvim/lua/plugins/ui.lua @@ -5,6 +5,7 @@ return { colorscheme = "catppuccin-mocha", }, }, + { "nvim-lualine/lualine.nvim", event = "VeryLazy", @@ -13,16 +14,6 @@ return { end, }, - { - "RRethy/vim-illuminate", - config = function() - -- change the highlight style - vim.api.nvim_set_hl(0, "IlluminatedWordText", { link = "Visual" }) - vim.api.nvim_set_hl(0, "IlluminatedWordRead", { link = "Visual" }) - vim.api.nvim_set_hl(0, "IlluminatedWordWrite", { link = "Visual" }) - end, - }, - { "snacks.nvim", opts = { @@ -41,117 +32,6 @@ return { }, }, - { - "NvChad/nvim-colorizer.lua", - opts = function(_, opts) - opts.filetypes = { - "html", - "css", - "scss", - "javascript", - "typescript", - "typescriptreact", - "javascriptreact", - "lua", - } - opts.user_default_options = { - mode = "background", - tailwind = false, -- Enable tailwind colors - } - end, - }, - { - "nvimdev/dashboard-nvim", - event = "VimEnter", - opts = function() - vim.api.nvim_set_hl(0, "DashboardHeader", { fg = "#79b8ff" }) - vim.api.nvim_set_hl(0, "DashboardIcon", { fg = "#39c5cf" }) - vim.api.nvim_set_hl(0, "DashboardKey", { fg = "#39c5cf" }) - vim.api.nvim_set_hl(0, "DashboardFooter", { fg = "#959da5" }) - local logo = [[ - _ _ _ _ - | | (_) | | | | - _ __ ___ ___ ___| |__ _ _ _ ___| |__ __ _ _ __ __| | -| '_ ` _ \ / _ \ / _ \ '_ \| | | | / __| '_ \ / _` | '_ \ / _` | -| | | | | | (_) | __/ |_) | | |_| \__ \ |_) | (_| | | | | (_| | -|_| |_| |_|\___/ \___|_.__/|_|\__,_|___/_.__/ \__,_|_| |_|\__,_| ]] - - logo = string.rep("\n", 8) .. logo .. "\n\n" - - local opts = { - theme = "doom", - hide = { - statusline = false, - }, - config = { - header = vim.split(logo, "\n"), - center = { - { - action = "lua LazyVim.pick()()", - desc = " Find file", - icon = " ", - key = "f", - }, - { - action = "Telescope oldfiles", - desc = " Recent files", - icon = " ", - key = "r", - }, - { - action = 'lua LazyVim.pick("live_grep")()', - desc = " Find text", - icon = " ", - key = "g", - }, - { - action = "lua LazyVim.pick.config_files()()", - desc = " Config", - icon = " ", - key = "c", - }, - { - action = "Telekasten find_notes", - desc = " Find notes", - icon = " ", - key = "n", - }, - { - action = "Lazy", - desc = " Lazy", - icon = "󰒲 ", - key = "l", - }, - { action = "qa", desc = " Quit", icon = " ", key = "q" }, - }, - footer = function() - local stats = require("lazy").stats() - local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) - return { "⚡ Neovim loaded " .. stats.loaded .. "/" .. stats.count .. " plugins in " .. ms .. "ms" } - end, - }, - } - - for _, button in ipairs(opts.config.center) do - button.desc = button.desc .. string.rep(" ", 43 - #button.desc) - button.key_format = " %s" - end - - -- close Lazy and re-open when the dashboard is ready - if vim.o.filetype == "lazy" then - vim.cmd.close() - vim.api.nvim_create_autocmd("User", { - pattern = "DashboardLoaded", - callback = function() - require("lazy").show() - end, - }) - end - - return opts - end, - }, - { "stevearc/oil.nvim", opts = {},