From e257fe11349a39571f53a907b954159d4f4381b2 Mon Sep 17 00:00:00 2001 From: Henrik Bakken Date: Thu, 28 Dec 2023 23:30:53 +0100 Subject: [PATCH] nvim added hlslens+ufo --- nvim/init.lua | 66 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 17 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index b695042..7b777fe 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -144,13 +144,24 @@ require("lazy").setup({ end, }, { - -- better asterisk search - "haya14busa/vim-asterisk", + -- search count > 99 + "kevinhwang91/nvim-hlslens", + dependencies = { + "haya14busa/vim-asterisk", + }, config = function() - vim.g["asterisk#keeppos"] = 1 + require("hlslens").setup({ nearest_only = true }) + local kopts = { noremap = true, silent = true } local map = vim.keymap.set - map("", "*", "(asterisk-z*)", {}) - map("", "g*", "(asterisk-gz*)", {}) + vim.g["asterisk#keeppos"] = 1 + map({ "n", "x" }, "*", [[(asterisk-z*)lua require('hlslens').start()]], {}) + map({ "n", "x" }, "#", [[(asterisk-z#)lua require('hlslens').start()]], {}) + map({ "n", "x" }, "g*", [[(asterisk-gz*)lua require('hlslens').start()]], {}) + map({ "n", "x" }, "g#", [[(asterisk-gz#)lua require('hlslens').start()]], {}) + map({ "n", "x" }, "n", [[nlua require('hlslens').start()]], kopts) + map({ "n", "x" }, "N", [[Nlua require('hlslens').start()]], kopts) + map({ "n", "x" }, "m", "nzz", kopts) + map({ "n", "x" }, "M", "Nzz", kopts) end, }, { @@ -398,12 +409,7 @@ require("lazy").setup({ -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). cmp.setup.cmdline(":", { mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { - name = "path", - option = { trailing_slash = false }, - }, - }, { { name = "cmdline" } }), + sources = cmp.config.sources({ { name = "path" } }, { { name = "cmdline" } }), }) end, }, -- Fuzzy Finder (files, lsp, etc) @@ -452,6 +458,23 @@ require("lazy").setup({ }) end, }, + { + "kevinhwang91/nvim-ufo", + dependencies = { "kevinhwang91/promise-async" }, + config = function() + vim.o.foldcolumn = "1" -- '0' is not bad + vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value + vim.o.foldlevelstart = 99 + vim.o.foldenable = true + + local ufo = require("ufo") + local map = vim.keymap.set + -- Using ufo provider need remap `zR` and `zM`. If Neovim is 0.6.1, remap yourself + map("n", "zR", ufo.openAllFolds) + map("n", "zM", ufo.closeAllFolds) + ufo.setup() + end, + }, { -- Highlight, edit, and navigate code "nvim-treesitter/nvim-treesitter", @@ -572,7 +595,7 @@ require("lazy").setup({ function() return { exe = "black", - args = { "--quiet", "--preview", "-" }, + args = { "--quiet", "-" }, stdin = true, } end, @@ -642,7 +665,6 @@ require("lazy").setup({ "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim", "folke/neodev.nvim", - "hrsh7th/nvim-cmp", }, config = function() local on_attach = function(client, bufnr) @@ -728,7 +750,19 @@ require("lazy").setup({ require("neodev").setup() local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) + + local cmp = require("cmp_nvim_lsp") + if cmp then + capabilities = cmp.default_capabilities(capabilities) + end + + local ufo = require("ufo") + if ufo then + capabilities.textDocument.foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true, + } + end local mason_lspconfig = require("mason-lspconfig") mason_lspconfig.setup({ @@ -775,9 +809,7 @@ require("lazy").setup({ inc_rename = false, -- enables an input dialog for inc-rename.nvim lsp_doc_border = false, -- add a border to hover docs and signature help }, - messages = { - enabled = true, - }, + messages = { enabled = true, view_search = false }, }) end, dependencies = { "MunifTanjim/nui.nvim" },