From 1b56f16e49139df5797c10f16b09cd08de6b565d Mon Sep 17 00:00:00 2001 From: Francis Date: Tue, 14 Oct 2025 16:41:13 +0100 Subject: [PATCH] added Precognition, Persistance, leaderW save and other nice updates --- .DS_Store | Bin 6148 -> 6148 bytes init.lua | 65 ++++++++++++++++++++++++---- lazy-lock.json | 39 ++++++++++------- lua/custom/plugins/marks.lua | 38 ++++++++++++++++ lua/custom/plugins/persistence.lua | 29 +++++++++++++ lua/custom/plugins/precognition.lua | 37 ++++++++++++++++ 6 files changed, 183 insertions(+), 25 deletions(-) create mode 100644 lua/custom/plugins/marks.lua create mode 100644 lua/custom/plugins/persistence.lua create mode 100644 lua/custom/plugins/precognition.lua diff --git a/.DS_Store b/.DS_Store index 09c4482ff8a62dc365c83da14417cd4a0ee5b0bb..728fd2f70146371794243fbb6432cb02d9981bec 100644 GIT binary patch delta 107 zcmZoMXffEJ$`r>hw~~Q@frUYjA)O(Up(Hoo#U&{xKM5$tG3$TeqIGh|9Z}^|@X8lt W7zQWj=N16H delta 107 zcmZoMXffEJ$`r?^UBke@z`~%%kj{|FP?DSP;*yk;p9B=+2y(yEZY6Zw5mi0~uY5s< VVQ_MOZUIma1B2j(&CN`Wq5yCK8YKV# diff --git a/init.lua b/init.lua index 377b89bd..c4273898 100644 --- a/init.lua +++ b/init.lua @@ -154,7 +154,7 @@ vim.opt.inccommand = 'split' vim.opt.cursorline = true -- Minimal number of screen lines to keep above and below the cursor. -vim.opt.scrolloff = 10 +vim.opt.scrolloff = 28 -- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`), -- instead raise a dialog asking if you wish to save the current file(s) @@ -168,6 +168,9 @@ vim.opt.confirm = true -- See `:help hlsearch` vim.keymap.set('n', '', 'nohlsearch') +-- Save file +vim.keymap.set('n', 'w', 'w', { desc = 'Save file' }) + -- Diagnostic keymaps vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) @@ -291,14 +294,14 @@ require('lazy').setup({ -- optional, but required for fuzzy finder support dependencies = { 'nvim-telescope/telescope-fzf-native.nvim', - build = 'make' + build = 'make', }, config = function() - local dropbar_api = require('dropbar.api') + local dropbar_api = require 'dropbar.api' vim.keymap.set('n', ';', dropbar_api.pick, { desc = 'Pick symbols in winbar' }) vim.keymap.set('n', '[;', dropbar_api.goto_context_start, { desc = 'Go to start of current context' }) vim.keymap.set('n', '];', dropbar_api.select_next_context, { desc = 'Select next context' }) - end + end, }, -- --NOTE: Kanso Theme - FQ -- { @@ -582,6 +585,18 @@ require('lazy').setup({ -- If you're wondering about lsp vs treesitter, you can check out the wonderfully -- and elegantly composed help section, `:help lsp-vs-treesitter` + -- LSP Hover and Signature Help Border (set before LspAttach) + vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { + border = 'rounded', + }) + vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, { + border = 'rounded', + }) + + -- Lighten LSP popup background + vim.api.nvim_set_hl(0, 'NormalFloat', { bg = '#15171c' }) + vim.api.nvim_set_hl(0, 'FloatBorder', { bg = '#15171c', fg = '#6a6a6a' }) + -- This function gets run when an LSP attaches to a particular buffer. -- That is to say, every time a new file is opened that is associated with -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this @@ -636,6 +651,25 @@ require('lazy').setup({ -- the definition of its *type*, not where it was *defined*. map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition') + -- Follow file:// links in LSP hover popup + vim.keymap.set('n', 'gx', function() + local line = vim.api.nvim_get_current_line() + local url = line:match('file://([^)]+)') + if url then + local file = url:match('([^#]+)') + local lnum = url:match('#L(%d+)') + if file then + vim.cmd('edit ' .. vim.fn.fnameescape(file)) + if lnum then + vim.cmd('normal! ' .. lnum .. 'Gzz') + end + end + else + -- Fallback to default gx behavior + vim.ui.open(vim.fn.expand('')) + end + end, { buffer = event.buf, desc = 'LSP: Open file:// link' }) + -- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10) ---@param client vim.lsp.Client ---@param method vim.lsp.protocol.Method @@ -748,6 +782,12 @@ require('lazy').setup({ local servers = { -- clangd = {}, -- gopls = {}, + zls = { + cmd = { 'zls' }, + settings = { + zig_exe_path = '/Users/fq/.zvm/bin/zig', + }, + }, pyright = { cmd = { 'pyright-langserver', '--stdio' }, settings = { @@ -812,9 +852,9 @@ require('lazy').setup({ -- for you, so that they are available from within Neovim. -- Filter out servers that aren't available through Mason local mason_servers = vim.tbl_filter(function(server_name) - return server_name ~= 'sourcekit' -- sourcekit-lsp comes with Xcode, not Mason + return server_name ~= 'sourcekit' and server_name ~= 'zls' -- sourcekit-lsp comes with Xcode, zls using custom version end, vim.tbl_keys(servers or {})) - + local ensure_installed = mason_servers vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code @@ -832,17 +872,23 @@ require('lazy').setup({ -- by the server configuration above. Useful when disabling -- certain features of an LSP (for example, turning off formatting for ts_ls) server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) - require('lspconfig')[server_name].setup(server) + + -- Use new vim.lsp.config API for Neovim 0.11+ + vim.lsp.config(server_name, server) + vim.lsp.enable(server_name) end, }, } -- Setup LSP servers that aren't managed by Mason - local non_mason_servers = { 'sourcekit' } + local non_mason_servers = { 'sourcekit', 'zls' } for _, server_name in ipairs(non_mason_servers) do local server = servers[server_name] or {} server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) - require('lspconfig')[server_name].setup(server) + + -- Use new vim.lsp.config API for Neovim 0.11+ + vim.lsp.config(server_name, server) + vim.lsp.enable(server_name) end end, }, @@ -1133,6 +1179,7 @@ require('lazy').setup({ -- Or use telescope! -- In normal mode type `sh` then write `lazy.nvim-plugin` -- you can continue same window with `sr` which resumes last telescope search + }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the diff --git a/lazy-lock.json b/lazy-lock.json index 1b6e3328..13518211 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,28 +1,35 @@ { "LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" }, - "blink.cmp": { "branch": "main", "commit": "586ee87534f5bf65f1c8dea2d1da2a57e8cddd36" }, + "blink.cmp": { "branch": "main", "commit": "327fff91fe6af358e990be7be1ec8b78037d2138" }, "claude-code.nvim": { "branch": "main", "commit": "c9a31e51069977edaad9560473b5d031fcc5d38b" }, - "conform.nvim": { "branch": "master", "commit": "973f3cb73887d510321653044791d7937c7ec0fa" }, - "dropbar.nvim": { "branch": "master", "commit": "5c3b0afdae4eeebb17497062ffad58d98b1c1c79" }, - "fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" }, + "conform.nvim": { "branch": "master", "commit": "fbcb4fa7f34bfea9be702ffff481a8e336ebf6ed" }, + "dropbar.nvim": { "branch": "master", "commit": "ce202248134e3949aac375fd66c28e5207785b10" }, + "fidget.nvim": { "branch": "main", "commit": "3f5475949679953af6d78654db29b944fa826e6a" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, - "gitsigns.nvim": { "branch": "main", "commit": "1fcaddcc427ff5802b6602f46de37a5352d0f9e0" }, + "gitsigns.nvim": { "branch": "main", "commit": "1ee5c1fd068c81f9dd06483e639c2aa4587dc197" }, "kanso.nvim": { "branch": "main", "commit": "62e9c5d669567d086474b2b6863e0724c71c6c99" }, - "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, - "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "bb3a17efc797c34c054463174e5522442576ebd8" }, + "lazy.nvim": { "branch": "main", "commit": "1ea3c4085785f460fb0e46d2fe1ee895f5f9e7c1" }, + "lazydev.nvim": { "branch": "main", "commit": "e28ce52fc7ff79fcb76f0e79ee6fb6182fca90b9" }, + "marks.nvim": { "branch": "master", "commit": "f353e8c08c50f39e99a9ed474172df7eddd89b72" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "6bdb14f230de0904229ec367b410fb817e59b072" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "517ef5994ef9d6b738322664d5fdd948f0fdeb46" }, - "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, - "mini.nvim": { "branch": "main", "commit": "432a0614f8dc38715892b0eec537716457ea4c2f" }, - "nvim-lspconfig": { "branch": "master", "commit": "f47cd681d7cb6048876a2e908b6d8ba1e530d152" }, - "nvim-tree.lua": { "branch": "master", "commit": "6b5b36659688767fb9f133bb83024ab1466fe5cd" }, + "mason.nvim": { "branch": "main", "commit": "ad7146aa61dcaeb54fa900144d768f040090bff0" }, + "mini.nvim": { "branch": "main", "commit": "4eaa8f4034535c372f6ca04b2772897048296dab" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-lspconfig": { "branch": "master", "commit": "ac98db2f9f06a56498ec890a96928774eae412c3" }, + "nvim-tree.lua": { "branch": "master", "commit": "321bc61580fd066b76861c32de3319c3a6d089e7" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, - "nvim-web-devicons": { "branch": "master", "commit": "0422a19d9aa3aad2c7e5cca167e5407b13407a9d" }, - "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, + "nvim-web-devicons": { "branch": "master", "commit": "b8221e42cf7287c4dcde81f232f58d7b947c210d" }, + "oil.nvim": { "branch": "master", "commit": "919e155fdf38e9148cdb5304faaaf53c20d703ea" }, + "persistence.nvim": { "branch": "main", "commit": "51eef57272742b773468949f6bd0503ec3f83874" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "precognition.nvim": { "branch": "main", "commit": "2aae2687207029b3611a0e19a289f9e1c7efbe16" }, + "snacks.nvim": { "branch": "main", "commit": "839022302b470fe166b8b8b04add49bd32bdc01b" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, - "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, + "todo-comments.nvim": { "branch": "main", "commit": "19d461ddd543e938eb22505fb03fa878800270b6" }, "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, - "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } + "which-key.nvim": { "branch": "main", "commit": "b4177e3eaf15fe5eb8357ebac2286d488be1ed00" }, + "xcodebuild.nvim": { "branch": "main", "commit": "1ceeb313c28549884d59bbc204dac7220cb97ce8" } } diff --git a/lua/custom/plugins/marks.lua b/lua/custom/plugins/marks.lua new file mode 100644 index 00000000..50ae0d03 --- /dev/null +++ b/lua/custom/plugins/marks.lua @@ -0,0 +1,38 @@ +return { + 'chentoast/marks.nvim', + event = 'VeryLazy', + opts = { + -- whether to map keybinds or not. default true + default_mappings = true, + -- which builtin marks to show. default {} + builtin_marks = { '.', '<', '>', '^' }, + -- whether movements cycle back to the beginning/end of buffer. default true + cyclic = true, + -- whether the shada file is updated after modifying uppercase marks. default false + force_write_shada = false, + -- how often (in ms) to redraw signs/recompute mark positions + -- higher values will have better performance but may cause visual lag, + -- while lower values may cause performance penalties. default 150. + refresh_interval = 250, + -- sign priorities for each type of mark - builtin marks, uppercase marks, lowercase + -- marks, and bookmarks. + -- can be either a table with all/none of the keys, or a single number, in which case + -- the priority applies to all marks. + -- default 10. + sign_priority = { lower = 10, upper = 15, builtin = 8, bookmark = 20 }, + -- disables mark tracking for specific filetypes. default {} + excluded_filetypes = {}, + -- disables mark tracking for specific buftypes. default {} + excluded_buftypes = {}, + -- marks.nvim allows you to configure up to 10 bookmark groups, each with its own + -- sign/virttext. Bookmarks can be used to group together positions and quickly move + -- across multiple buffers. default sign is '!@#$%^&*()' (from 0 to 9), and + -- default virt_text is "". + bookmark_0 = { + sign = '⚑', + virt_text = 'hello world', + annotate = false, + }, + mappings = {}, + }, +} diff --git a/lua/custom/plugins/persistence.lua b/lua/custom/plugins/persistence.lua new file mode 100644 index 00000000..bf54c696 --- /dev/null +++ b/lua/custom/plugins/persistence.lua @@ -0,0 +1,29 @@ +return { + 'folke/persistence.nvim', + event = 'BufReadPre', + opts = {}, + -- Optional keymaps for manual session control + keys = { + { + 'qs', + function() + require('persistence').load() + end, + desc = 'Restore Session', + }, + { + 'ql', + function() + require('persistence').load { last = true } + end, + desc = 'Restore Last Session', + }, + { + 'qd', + function() + require('persistence').stop() + end, + desc = "Don't Save Current Session", + }, + }, +} diff --git a/lua/custom/plugins/precognition.lua b/lua/custom/plugins/precognition.lua new file mode 100644 index 00000000..2b6f63b8 --- /dev/null +++ b/lua/custom/plugins/precognition.lua @@ -0,0 +1,37 @@ +return { + 'tris203/precognition.nvim', + --event = "VeryLazy", + opts = { + startVisible = true, + -- showBlankVirtLine = true, + -- highlightColor = { link = "Comment" }, + -- hints = { + -- Caret = { text = "^", prio = 2 }, + -- Dollar = { text = "$", prio = 1 }, + -- MatchingPair = { text = "%", prio = 5 }, + -- Zero = { text = "0", prio = 1 }, + -- w = { text = "w", prio = 10 }, + -- b = { text = "b", prio = 9 }, + -- e = { text = "e", prio = 8 }, + -- W = { text = "W", prio = 7 }, + -- B = { text = "B", prio = 6 }, + -- E = { text = "E", prio = 5 }, + -- }, + -- gutterHints = { + -- G = { text = "G", prio = 10 }, + -- gg = { text = "gg", prio = 9 }, + -- PrevParagraph = { text = "{", prio = 8 }, + -- NextParagraph = { text = "}", prio = 8 }, + -- }, + -- disabled_fts = { + -- "startify", + -- }, + }, + keys = { + { + 'P', + 'Precognition toggle', + desc = 'Toggle Precognition', + }, + }, +}