From 6cdf85b4e3b3dbf8707e9dee6ec7ab93b0e0a5f2 Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Fri, 20 Dec 2024 09:48:54 -0500 Subject: [PATCH] feat: Reworking nvim configuration --- nvim/m-housh/lua/plugins/blink.lua | 2 +- nvim/m-housh/lua/plugins/comment.lua | 2 +- nvim/m-housh/lua/plugins/fidget.lua | 33 ++-- nvim/m-housh/lua/plugins/formatter.lua | 21 ++- nvim/m-housh/lua/plugins/harpoon.lua | 152 +++++++-------- nvim/m-housh/lua/plugins/lsp.lua | 207 +++++++++++---------- nvim/m-housh/lua/plugins/lualine.lua | 178 ++---------------- nvim/m-housh/lua/plugins/luasnip.lua | 71 +++---- nvim/m-housh/lua/plugins/noice.lua | 89 +++++---- nvim/m-housh/lua/plugins/oil.lua | 30 --- nvim/m-housh/lua/plugins/todo-comments.lua | 60 +++--- nvim/m-housh/lua/plugins/treesitter.lua | 126 ++++++------- nvim/m-housh/lua/plugins/which-key.lua | 22 ++- 13 files changed, 426 insertions(+), 567 deletions(-) diff --git a/nvim/m-housh/lua/plugins/blink.lua b/nvim/m-housh/lua/plugins/blink.lua index 1957457..34940c0 100644 --- a/nvim/m-housh/lua/plugins/blink.lua +++ b/nvim/m-housh/lua/plugins/blink.lua @@ -1,7 +1,7 @@ return { { "saghen/blink.cmp", - enabeld = false, + enabled = false, dependencies = { "rafamadriz/friendly-snippets", --"L3MON4D3/LuaSnip", diff --git a/nvim/m-housh/lua/plugins/comment.lua b/nvim/m-housh/lua/plugins/comment.lua index b309b03..9564a85 100755 --- a/nvim/m-housh/lua/plugins/comment.lua +++ b/nvim/m-housh/lua/plugins/comment.lua @@ -1,7 +1,7 @@ return { 'numToStr/Comment.nvim', + event = { 'BufReadPre', 'BufNewFile' }, opts = { -- add any options here }, - event = { 'BufReadPre', 'BufNewFile' }, } diff --git a/nvim/m-housh/lua/plugins/fidget.lua b/nvim/m-housh/lua/plugins/fidget.lua index dd4f3cf..a9b709a 100644 --- a/nvim/m-housh/lua/plugins/fidget.lua +++ b/nvim/m-housh/lua/plugins/fidget.lua @@ -1,23 +1,20 @@ return { "j-hui/fidget.nvim", event = "VeryLazy", - config = function() - local fidget = require("fidget") - fidget.setup({ - notification = { - window = { - normal_hl = "String", -- Base highlight group in the notification window - winblend = 0, -- Background color opacity in the notification window - border = "rounded", -- Border around the notification window - zindex = 45, -- Stacking priority of the notification window - max_width = 0, -- Maximum width of the notification window - max_height = 0, -- Maximum height of the notification window - x_padding = 1, -- Padding from right edge of window boundary - y_padding = 1, -- Padding from bottom edge of window boundary - align = "bottom", -- How to align the notification window - relative = "editor", -- What the notification window position is relative to - }, + opts = { + notification = { + window = { + normal_hl = "String", -- Base highlight group in the notification window + winblend = 0, -- Background color opacity in the notification window + border = "rounded", -- Border around the notification window + zindex = 45, -- Stacking priority of the notification window + max_width = 0, -- Maximum width of the notification window + max_height = 0, -- Maximum height of the notification window + x_padding = 1, -- Padding from right edge of window boundary + y_padding = 1, -- Padding from bottom edge of window boundary + align = "bottom", -- How to align the notification window + relative = "editor", -- What the notification window position is relative to }, - }) - end, + }, + }, } diff --git a/nvim/m-housh/lua/plugins/formatter.lua b/nvim/m-housh/lua/plugins/formatter.lua index 881f3d1..95adf71 100755 --- a/nvim/m-housh/lua/plugins/formatter.lua +++ b/nvim/m-housh/lua/plugins/formatter.lua @@ -1,7 +1,19 @@ return { "mhartington/formatter.nvim", event = { "BufReadPre", "BufNewFile" }, - config = function() + keys = { + { + "f", + ":Format", + desc = "[F]ormat", + }, + { + "F", + ":FormatWrite", + desc = "[F]ormat write", + }, + }, + config = function(_, opts) local util = require("formatter.util") require("formatter").setup({ filetype = { @@ -50,13 +62,6 @@ return { }, }) - -- Keymaps - local wk = require("which-key") - wk.add({ - { "f", ":Format", desc = "[F]ormat" }, - { "F", ":FormateWrite", desc = "[F]ormat write" }, - }, { mode = "n", silent = true }) - local augroup = vim.api.nvim_create_augroup local autocmd = vim.api.nvim_create_autocmd diff --git a/nvim/m-housh/lua/plugins/harpoon.lua b/nvim/m-housh/lua/plugins/harpoon.lua index 3112ddb..e2e8f14 100644 --- a/nvim/m-housh/lua/plugins/harpoon.lua +++ b/nvim/m-housh/lua/plugins/harpoon.lua @@ -1,86 +1,86 @@ return { - "ThePrimeagen/harpoon", - branch = "harpoon2", - event = "VeryLazy", - dependencies = { - "nvim-lua/plenary.nvim", - }, - config = function() - local harpoon = require("harpoon") - harpoon:setup({ - settings = { - save_on_toggle = true, - sync_on_ui_close = true, - key = function() - return vim.loop.cwd() - end, - }, - }) + "ThePrimeagen/harpoon", + branch = "harpoon2", + event = "VeryLazy", + dependencies = { + "nvim-lua/plenary.nvim", + }, + config = function() + local harpoon = require("harpoon") + harpoon:setup({ + settings = { + save_on_toggle = true, + sync_on_ui_close = true, + key = function() + return vim.loop.cwd() + end, + }, + }) - local conf = require("telescope.config").values - local function toggle_telescope(harpoon_files) - local file_paths = {} - for _, item in ipairs(harpoon_files.items) do - table.insert(file_paths, item.value) - end + local conf = require("telescope.config").values + local function toggle_telescope(harpoon_files) + local file_paths = {} + for _, item in ipairs(harpoon_files.items) do + table.insert(file_paths, item.value) + end - require("telescope.pickers") - .new({}, { - prompt_title = "Harpoon", - finder = require("telescope.finders").new_table({ - results = file_paths, - }), - previewer = conf.file_previewer({}), - sorter = conf.generic_sorter({}), - }) - :find() - end + require("telescope.pickers") + .new({}, { + prompt_title = "Harpoon", + finder = require("telescope.finders").new_table({ + results = file_paths, + }), + previewer = conf.file_previewer({}), + sorter = conf.generic_sorter({}), + }) + :find() + end - -- Keymaps - vim.keymap.set("n", "", function() - toggle_telescope(harpoon:list()) - end, { desc = "Open Harpoon window" }) + -- Keymaps + vim.keymap.set("n", "", function() + toggle_telescope(harpoon:list()) + end, { desc = "Open Harpoon window" }) - vim.keymap.set("n", "a", function() - harpoon:list():add() - end, { desc = "[A]dd to harpoon list." }) - vim.keymap.set("n", "", function() - harpoon.ui:toggle_quick_menu(harpoon:list()) - end, { desc = "Toggle quick menu." }) + vim.keymap.set("n", "a", function() + harpoon:list():add() + end, { desc = "[A]dd to harpoon list." }) + vim.keymap.set("n", "", function() + harpoon.ui:toggle_quick_menu(harpoon:list()) + end, { desc = "Toggle quick menu." }) - -- Buffer key maps. Currently keeping all buffer movements - -- isolated to top left row of keys on keyboard and all begin - -- with the key. + -- Buffer key maps. Currently keeping all buffer movements + -- isolated to top left row of keys on keyboard and all begin + -- with the key. - -- Select buffer numbers. - vim.keymap.set("n", "", function() - harpoon:list():select(1) - end, { desc = "Select first harpoon buffer." }) - vim.keymap.set("n", "", function() - harpoon:list():select(2) - end, { desc = "Select second harpoon buffer." }) - vim.keymap.set("n", "", function() - harpoon:list():select(3) - end, { desc = "Select third harpoon buffer." }) - vim.keymap.set("n", "", function() - harpoon:list():select(4) - end, { desc = "Select fourth harpoon buffer." }) + -- Select buffer numbers. + vim.keymap.set("n", "", function() + harpoon:list():select(1) + end, { desc = "Select first harpoon buffer." }) + vim.keymap.set("n", "", function() + harpoon:list():select(2) + end, { desc = "Select second harpoon buffer." }) + vim.keymap.set("n", "", function() + harpoon:list():select(3) + end, { desc = "Select third harpoon buffer." }) + vim.keymap.set("n", "", function() + harpoon:list():select(4) + end, { desc = "Select fourth harpoon buffer." }) - -- Toggle previous and next buffers. - vim.keymap.set("n", "", function() - harpoon:list():prev() - end, { desc = "[P]revious harpoon buffer." }) - vim.keymap.set("n", "", function() - harpoon:list():next() - end, { desc = "[N]ext harpoon buffer." }) + -- Toggle previous and next buffers. + vim.keymap.set("n", "", function() + harpoon:list():prev() + end, { desc = "[P]revious harpoon buffer." }) + vim.keymap.set("n", "", function() + harpoon:list():next() + end, { desc = "[N]ext harpoon buffer." }) - -- Extensions - harpoon:extend({ - UI_CREATE = function(cx) - vim.keymap.set("n", "", function() - harpoon.ui:select_menu_item({ vsplit = true }) - end, { buffer = cx.buffer, desc = "Open in [V]split" }) - end, - }) - end, + -- Extensions + harpoon:extend({ + UI_CREATE = function(cx) + vim.keymap.set("n", "", function() + harpoon.ui:select_menu_item({ vsplit = true }) + end, { buffer = cx.buffer, desc = "Open in [V]split" }) + end, + }) + end, } diff --git a/nvim/m-housh/lua/plugins/lsp.lua b/nvim/m-housh/lua/plugins/lsp.lua index 78e13c9..0ea5730 100755 --- a/nvim/m-housh/lua/plugins/lsp.lua +++ b/nvim/m-housh/lua/plugins/lsp.lua @@ -1,105 +1,118 @@ --- The language servers to setup. -local lsp_servers = { - "bashls", - "clangd", - "dockerls", - "gopls", - "jsonls", - "lua_ls", - "marksman", - "sourcekit", - "yamlls", -} - return { - "neovim/nvim-lspconfig", - event = { "BufReadPre", "BufNewFile" }, - dependencies = { - -- "hrsh7th/cmp-nvim-lsp", - "saghen/blink.cmp", - { "antosha417/nvim-lsp-file-operations", config = true }, - "williamboman/mason.nvim", - "williamboman/mason-lspconfig.nvim", - { - "folke/lazydev.nvim", - ft = "lua", - opts = { - library = { - { path = "${3rd}/luv/library", words = { "vim%.uv" } }, + { + "neovim/nvim-lspconfig", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + "hrsh7th/cmp-nvim-lsp", + --"saghen/blink.cmp", + { "antosha417/nvim-lsp-file-operations", config = true }, + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + { + "folke/lazydev.nvim", + ft = "lua", + opts = { + library = { + { path = "${3rd}/luv/library", words = { "vim%.uv" } }, + }, }, }, }, - }, - config = function() - require("mason").setup() - require("mason-lspconfig").setup({ - opts = { - ensure_installed = lsp_servers, - }, - }) - local lspconfig = require("lspconfig") - --local cmp_nvim_lsp = require("cmp_nvim_lsp") - --local capabilities = cmp_nvim_lsp.default_capabilities() - local capabilities = require("blink.cmp").get_lsp_capabilities() - local opts = { noremap = true, silent = true } - local on_attach = function(_, bufnr) - opts.buffer = bufnr - - opts.desc = "Show line diagnostics" - vim.keymap.set("n", "d", vim.diagnostic.open_float, opts) - - opts.desc = "Show diagnostics in Telescope" - vim.keymap.set("n", "d", "Telescope diagnostics bufnr=0", opts) - - opts.desc = "Show documentation for what is under cursor" - vim.keymap.set("n", "", vim.lsp.buf.hover, opts) - - opts.desc = "[G]oto [D]efinition" - vim.keymap.set("n", "gd", "Telescope lsp_definitions trim_text=true", opts) - - opts.desc = "[G]oto [D]eclaration" - vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) - - opts.desc = "[G]oto [R]eferences" - vim.keymap.set("n", "gr", "Telescope lsp_references", opts) - - opts.desc = "LSP [C]ode [A]ction" - vim.keymap.set("n", "ca", vim.lsp.buf.code_action, opts) - - --opts.desc = "[R]e-[N]ame" - --vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) - - opts.desc = "[R]eload or start LSP" - vim.keymap.set("n", "rl", ":LspRestart | :LspStart", opts) - - opts.desc = "Goto previous diagnostic" - vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) - - opts.desc = "Goto next diagnostic" - vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) - end - - for _, lsp in ipairs(lsp_servers) do - lspconfig[lsp].setup({ - capabilities = capabilities, - on_attach = on_attach, - on_init = function(client) - -- HACK: to fix some issues with LSP - -- more details: https://github.com/neovim/neovim/issues/19237#issuecomment-2237037154 - client.offset_encoding = "utf-8" - end, - cmd = lsp == "sourcekit" and { vim.trim(vim.fn.system("xcrun -f sourcekit-lsp")) } or nil, + config = function() + require("mason").setup() + require("mason-lspconfig").setup({ + ensure_installed = { + "bashls", + "clangd", + "dockerls", + "gopls", + "jinja_lsp", + "jqls", + "jsonls", + "ltex", + "lua_ls", + "marksman", + "yamlls", + }, + automatic_installation = true, }) - end + local lspconfig = require("lspconfig") + local cmp_nvim_lsp = require("cmp_nvim_lsp") + local capabilities = cmp_nvim_lsp.default_capabilities() + --local capabilities = require("blink.cmp").get_lsp_capabilities() + local opts = { noremap = true, silent = true } + local on_attach = function(_, bufnr) + opts.buffer = bufnr - -- nice icons - local signs = { Error = " ", Warn = " ", Hint = "󰠠 ", Info = " " } - for type, icon in pairs(signs) do - local hl = "DiagnosticSign" .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) - end + opts.desc = "Show line diagnostics" + vim.keymap.set("n", "d", vim.diagnostic.open_float, opts) - -- For some reason I was having trouble getting this to work inside the on-attach, so it's here. - vim.keymap.set("n", "rn", vim.lsp.buf.rename, { desc = "[R]e-[N]ame" }) - end, + opts.desc = "Show diagnostics in Telescope" + vim.keymap.set("n", "d", "Telescope diagnostics bufnr=0", opts) + + opts.desc = "Show documentation for what is under cursor" + vim.keymap.set("n", "", vim.lsp.buf.hover, opts) + + opts.desc = "[G]oto [D]efinition" + vim.keymap.set("n", "gd", "Telescope lsp_definitions trim_text=true", opts) + + opts.desc = "[G]oto [D]eclaration" + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) + + opts.desc = "[G]oto [R]eferences" + vim.keymap.set("n", "gr", "Telescope lsp_references", opts) + + opts.desc = "LSP [C]ode [A]ction" + vim.keymap.set("n", "ca", vim.lsp.buf.code_action, opts) + + --opts.desc = "[R]e-[N]ame" + --vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) + + opts.desc = "[R]eload or start LSP" + vim.keymap.set("n", "rl", ":LspRestart | :LspStart", opts) + + opts.desc = "Goto previous diagnostic" + vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) + + opts.desc = "Goto next diagnostic" + vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) + end + + -- The language servers to setup. + local lsp_servers = { + "bashls", + "clangd", + "dockerls", + "gopls", + "jsonls", + "lua_ls", + "marksman", + "sourcekit", + "yamlls", + } + + for _, lsp in ipairs(lsp_servers) do + lspconfig[lsp].setup({ + capabilities = capabilities, + on_attach = on_attach, + on_init = function(client) + -- HACK: to fix some issues with LSP + -- more details: https://github.com/neovim/neovim/issues/19237#issuecomment-2237037154 + client.offset_encoding = "utf-8" + end, + cmd = lsp == "sourcekit" and { vim.trim(vim.fn.system("xcrun -f sourcekit-lsp")) } or nil, + }) + end + + -- nice icons + local signs = { Error = " ", Warn = " ", Hint = "󰠠 ", Info = " " } + for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) + end + + -- For some reason I was having trouble getting this to work inside the on-attach, so it's here. + vim.keymap.set("n", "rn", vim.lsp.buf.rename, { desc = "[R]e-[N]ame" }) + end, + }, } diff --git a/nvim/m-housh/lua/plugins/lualine.lua b/nvim/m-housh/lua/plugins/lualine.lua index 2af188e..b8ba1c3 100755 --- a/nvim/m-housh/lua/plugins/lualine.lua +++ b/nvim/m-housh/lua/plugins/lualine.lua @@ -1,22 +1,19 @@ +local function xcodebuild_device() + if vim.g.xcodebuild_platform == "macOS" then + return " macOS" + end + + if vim.g.xcodebuild_os then + return " " .. vim.g.xcodebuild_device_name .. " (" .. vim.g.xcodebuild_os .. ")" + end + + return " " .. vim.g.xcodebuild_device_name +end + return { "nvim-lualine/lualine.nvim", dependencies = { "nvim-tree/nvim-web-devicons" }, - config = function() - local lualine = require("lualine") - - local function xcodebuild_device() - if vim.g.xcodebuild_platform == "macOS" then - return " macOS" - end - - if vim.g.xcodebuild_os then - return " " .. vim.g.xcodebuild_device_name .. " (" .. vim.g.xcodebuild_os .. ")" - end - - return " " .. vim.g.xcodebuild_device_name - end - - lualine.setup({ + opts = { options = { globalstatus = true, theme = "auto", @@ -67,151 +64,6 @@ return { lualine_z = {}, }, extensions = { "nvim-dap-ui", "quickfix", "trouble", "nvim-tree", "lazy", "mason" }, - }) - end, + + }, } --- return { --- "nvim-lualine/lualine.nvim", --- config = function() --- local colors = { --- red = '#ca1243', --- grey = '#a0a1a7', --- black = '#383a42', --- white = '#f3f3f3', --- light_green = '#83a598', --- orange = '#fe8019', --- green = '#8ec07c', --- } --- --- local empty = require('lualine.component'):extend() --- function empty:draw(default_highlight) --- self.status = '' --- self.applied_separator = '' --- self:apply_highlights(default_highlight) --- self:apply_section_separators() --- return self.status --- end --- --- -- Put proper separators and gaps between components in sections --- local function process_sections(sections) --- for name, section in pairs(sections) do --- local left = name:sub(9, 10) < 'x' --- for pos = 1, name ~= 'lualine_z' and #section or #section - 1 do --- table.insert(section, pos * 2, { empty, color = { fg = colors.white, bg = colors.white } }) --- end --- for id, comp in ipairs(section) do --- if type(comp) ~= 'table' then --- comp = { comp } --- section[id] = comp --- end --- comp.separator = left and { right = '' } or { left = '' } --- end --- end --- return sections --- end --- --- local function search_result() --- if vim.v.hlsearch == 0 then --- return '' --- end --- local last_search = vim.fn.getreg '/' --- if not last_search or last_search == '' then --- return '' --- end --- local searchcount = vim.fn.searchcount { maxcount = 9999 } --- return last_search .. '(' .. searchcount.current .. '/' .. searchcount.total .. ')' --- end --- --- local function modified() --- if vim.bo.modified then --- return '+' --- elseif vim.bo.modifiable == false or vim.bo.readonly == true then --- return '-' --- end --- return '' --- end --- --- local function xcodebuild_device() --- if vim.g.xcodebuild_platform == "macOS" then --- return " macOS" --- end --- --- local deviceIcon = "" --- if vim.g.xcodebuild_platform:match("watch") then --- deviceIcon = "􀟤" --- elseif vim.g.xcodebuild_platform:match("tv") then --- deviceIcon = "􀡴 " --- elseif vim.g.xcodebuild_platform:match("vision") then --- deviceIcon = "􁎖 " --- end --- --- if vim.g.xcodebuild_os then --- return deviceIcon .. " " .. vim.g.xcodebuild_device_name .. " (" .. vim.g.xcodebuild_os .. ")" --- end --- --- return deviceIcon .. " " .. vim.g.xcodebuild_device_name --- end --- --- --- require('lualine').setup { --- options = { --- theme = 'auto', --- component_separators = '', --- section_separators = { left = '', right = '' }, --- }, --- sections = process_sections { --- lualine_a = { 'mode' }, --- lualine_b = { --- 'branch', --- 'diff', --- { --- 'diagnostics', --- source = { 'nvim' }, --- sections = { 'error' }, --- diagnostics_color = { error = { bg = colors.red, fg = colors.white } }, --- }, --- { --- 'diagnostics', --- source = { 'nvim' }, --- sections = { 'warn' }, --- diagnostics_color = { warn = { bg = colors.orange, fg = colors.white } }, --- }, --- { 'filename', file_status = false, path = 1 }, --- { modified, color = { bg = colors.red } }, --- { --- '%w', --- cond = function() --- return vim.wo.previewwindow --- end, --- }, --- { --- '%r', --- cond = function() --- return vim.bo.readonly --- end, --- }, --- { --- '%q', --- cond = function() --- return vim.bo.buftype == 'quickfix' --- end, --- }, --- }, --- lualine_c = {}, --- lualine_x = { --- { "' ' .. vim.g.xcodebuild_last_status", color = { fg = "Gray" } }, --- { "'󰙨 ' .. vim.g.xcodebuild_test_plan", color = { fg = "#a6e3a1", bg = "#161622" } }, --- { xcodebuild_device, color = { fg = "#f9e2af", bg = "#161622" } }, --- }, --- lualine_y = { search_result, 'filetype' }, --- lualine_z = { '%l:%c', '%p%%/%L' }, --- }, --- inactive_sections = { --- lualine_c = { '%f %y %m' }, --- lualine_x = {}, --- }, --- tabline = {}, --- extensions = {"nvim-tree"} --- } --- end --- } diff --git a/nvim/m-housh/lua/plugins/luasnip.lua b/nvim/m-housh/lua/plugins/luasnip.lua index d61635e..0e23182 100644 --- a/nvim/m-housh/lua/plugins/luasnip.lua +++ b/nvim/m-housh/lua/plugins/luasnip.lua @@ -2,44 +2,45 @@ return { "L3MON4D3/LuaSnip", version = "v2.*", event = "VeryLazy", - config = function() - local ls = require("luasnip") - local types = require("luasnip.util.types") - ls.setup({ - history = true, - enable_autosnippets = false, - updatevents = "TextChanged,TextChangedI", - extra_opts = { - [types.choiceNode] = { - active = { - virt_text = { { "choiceNode", "Comment" } }, - }, + opts = { + history = true, + enable_autosnippets = false, + updatevents = "TextChanged,TextChangedI", + extra_opts = { + [require("luasnip.utl.types").choiceNode] = { + active = { + virt_text = { { "choiceNode", "Comment" } }, }, }, - }) + }, + }, + keys = { + { + "", + mode = { "i", "s" }, + function() + local ls = require("luasnip") + if ls.expand_or_jumpable() then + ls.expand_or_jump() + end + end, + }, + { + "", + mode = { "i", "s" }, + function() + local ls = require("luasnip") + if ls.jumpable(-1) then + ls.jump(-1) + end + end, + }, + }, + config = function(_, opts) + local ls = require("luasnip") + ls.setup(opts) + require("luasnip.loaders.from_vscode").lazy_load() require("luasnip.loaders.from_lua").lazy_load({ paths = vim.fn.stdpath("config") .. "/snippets" }) - - -- Keymaps - local opts = { silent = true } - - -- Use k to expand snippets. - -- This will expand the current item or jump to the next item within the snippet. - vim.keymap.set({ "i", "s" }, "", function() - if ls.expand_or_jumpable() then - ls.expand_or_jump() - end - end, opts) - - -- Use j to jump backwards in a snippet. - -- This always moves to the previous item within a snippet. - vim.keymap.set({ "i", "s" }, "", function() - if ls.jumpable(-1) then - ls.jump(-1) - end - end, opts) - - -- Reload snippets. - vim.keymap.set("n", "s", "source ~/.config/m-housh/lua/user/plugin/luasnip.lua") end, } diff --git a/nvim/m-housh/lua/plugins/noice.lua b/nvim/m-housh/lua/plugins/noice.lua index c2872b5..98ad41f 100755 --- a/nvim/m-housh/lua/plugins/noice.lua +++ b/nvim/m-housh/lua/plugins/noice.lua @@ -1,47 +1,46 @@ return { - "folke/noice.nvim", - event = "VeryLazy", - -- config.lsp.signature.enabled = false - opts = { - lsp = { - -- override markdown rendering so that **cmp** and other plugins use **Treesitter** - override = { - ["vim.lsp.util.convert_input_to_markdown_lines"] = true, - ["vim.lsp.util.stylize_markdown"] = true, - ["cmp.entry.get_documentation"] = true, - }, - -- you can enable a preset for easier configuration - presets = { - bottom_search = true, -- use a classic bottom cmdline for search - command_palette = true, -- position the cmdline and popupmenu together - long_message_to_split = true, -- long messages will be sent to a split - inc_rename = false, -- enables an input dialog for inc-rename.nvim - lsp_doc_border = false, -- add a border to hover docs and signature help - }, - signature = { enabled = false }, - }, - routes = { - { -- enables messages for showing macro recording. - view = "notify", - filter = { event = "msg_showmode" }, - }, - { -- Hide the written messages. - view = 'notify', - filter = { - event = "msg_show", - kind = "", - find = "written" - }, - opts = { skip = true } - } - }, - }, - dependencies = { - -- if you lazy-load any plugin below, make sure to add proper `module="..."` entries - "MunifTanjim/nui.nvim", - -- OPTIONAL: - -- `nvim-notify` is only needed, if you want to use the notification view. - -- If not available, we use `mini` as the fallback - "rcarriga/nvim-notify", - }, + "folke/noice.nvim", + event = "VeryLazy", + dependencies = { + -- if you lazy-load any plugin below, make sure to add proper `module="..."` entries + "MunifTanjim/nui.nvim", + -- OPTIONAL: + -- `nvim-notify` is only needed, if you want to use the notification view. + -- If not available, we use `mini` as the fallback + "rcarriga/nvim-notify", + }, + opts = { + lsp = { + -- override markdown rendering so that **cmp** and other plugins use **Treesitter** + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + ["cmp.entry.get_documentation"] = true, + }, + -- you can enable a preset for easier configuration + presets = { + bottom_search = true, -- use a classic bottom cmdline for search + command_palette = true, -- position the cmdline and popupmenu together + long_message_to_split = true, -- long messages will be sent to a split + inc_rename = false, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = false, -- add a border to hover docs and signature help + }, + signature = { enabled = false }, + }, + routes = { + { -- enables messages for showing macro recording. + view = "notify", + filter = { event = "msg_showmode" }, + }, + { -- Hide the written messages. + view = "notify", + filter = { + event = "msg_show", + kind = "", + find = "written", + }, + opts = { skip = true }, + }, + }, + }, } diff --git a/nvim/m-housh/lua/plugins/oil.lua b/nvim/m-housh/lua/plugins/oil.lua index 673b5ee..b1c134f 100644 --- a/nvim/m-housh/lua/plugins/oil.lua +++ b/nvim/m-housh/lua/plugins/oil.lua @@ -35,34 +35,4 @@ return { desc = "Open directory in float.", }, }, - -- config = function() - -- require("oil").setup({ - -- columns = { "icon" }, - -- keymaps = { - -- [""] = false, - -- [""] = "actions.select_split", - -- [""] = { - -- "actions.select", - -- opts = { vertical = true }, - -- desc = "Open the entry in a vertical split", - -- }, - -- }, - -- view_options = { - -- is_hidden_file = function(name, _) -- second arg is bufnr, but not currently used. - -- -- Don't show .DS_Store in output. - -- local is_ds_store = name ~= ".DS_Store" - -- return not is_ds_store - -- end, - -- }, - -- }) - -- - -- -- Show the parent directory in current window. - -- vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory." }) - -- - -- -- Open parent directory in floating window. - -- vim.keymap.set("n", "-", require("oil").toggle_float) - -- - -- -- Old habits die hard, map what used to toggle neo-tree to just open a float. - -- vim.keymap.set("n", "", require("oil").toggle_float) - -- end, } diff --git a/nvim/m-housh/lua/plugins/todo-comments.lua b/nvim/m-housh/lua/plugins/todo-comments.lua index 796e1e0..679c3f4 100644 --- a/nvim/m-housh/lua/plugins/todo-comments.lua +++ b/nvim/m-housh/lua/plugins/todo-comments.lua @@ -4,26 +4,42 @@ return { "nvim-lua/plenary.nvim", "folke/trouble.nvim", }, - opts = {}, - config = function() - local todos = require("todo-comments") - - todos.setup({ - keywords = { - -- Adds the important keyword, I primarily use this in markdown - -- documents to be able to jump and color appropriately. - FIX = { alt = { "IMPORTANT" } }, - }, - }) - - vim.keymap.set("n", "tq", "Trouble todo toggle", { desc = "[T]odo [Q]uick fix list." }) - vim.keymap.set("n", "t", "TodoTelescope", { desc = "[T]odo telescope list." }) - vim.keymap.set("n", "tl", "TodoLocList", { desc = "[T]odo [L]ocation list." }) - vim.keymap.set("n", "]t", function() - todos.jump_next() - end, { desc = "Next [T]odo" }) - vim.keymap.set("n", "[t", function() - todos.jump_prev() - end, { desc = "Previous [T]odo" }) - end, + opts = { + keywords = { + -- Adds the important keyword, I primarily use this in markdown + -- documents to be able to jump and color appropriately. + FIX = { alt = { "IMPORTANT" } }, + }, + }, + keys = { + { + "tq", + "Trouble todo toggle", + desc = "Todo quick fix list.", + }, + { + "t", + "TodoTelescope", + desc = "Todo telescope list.", + }, + { + "tl", + "TodoLocList", + desc = "Todo location list.", + }, + { + "]t", + function() + require("todo-comments").jump_next() + end, + desc = "Next todo.", + }, + { + "[t", + function() + require("todo-comments").jump_prev() + end, + desc = "Previous todo.", + }, + }, } diff --git a/nvim/m-housh/lua/plugins/treesitter.lua b/nvim/m-housh/lua/plugins/treesitter.lua index 8ec0090..66d9471 100755 --- a/nvim/m-housh/lua/plugins/treesitter.lua +++ b/nvim/m-housh/lua/plugins/treesitter.lua @@ -6,73 +6,71 @@ return { }, build = ":TSUpdate", event = { "BufReadPre", "BufNewFile" }, - config = function() - require("nvim-treesitter.configs").setup({ - ensure_installed = { - "bash", - "cmake", - "dockerfile", - "go", - "hcl", - "html", - "java", - "javascript", - "json", - "latex", - "ledger", - "llvm", - "lua", - "make", - "markdown", - "python", - "swift", - "toml", - "xml", - "yaml", - }, -- one of "all", "maintained" (parsers with maintainers), or a list of languages - ignore_install = {}, -- List of parsers to ignore installing - highlight = { - enable = true, -- false will disable the whole extension - disable = {}, -- list of language that will be disabled + opts = { + ensure_installed = { + "bash", + "cmake", + "dockerfile", + "go", + "hcl", + "html", + "java", + "javascript", + "json", + "latex", + "ledger", + "llvm", + "lua", + "make", + "markdown", + "python", + "swift", + "toml", + "xml", + "yaml", + }, -- one of "all", "maintained" (parsers with maintainers), or a list of languages + ignore_install = {}, -- List of parsers to ignore installing + highlight = { + enable = true, -- false will disable the whole extension + disable = {}, -- list of language that will be disabled + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + scope_incremental = "", + node_incremental = "", + node_decremental = "", }, - incremental_selection = { + }, + indent = { enable = true }, + autopairs = { { enable = true } }, + textobjects = { + select = { enable = true, + -- Automatically jump forward to textobj, similar to targets.vim + lookahead = true, keymaps = { - init_selection = "", - scope_incremental = "", - node_incremental = "", - node_decremental = "", + -- You can use the capture groups defined in textobjects.scm + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", + ["al"] = "@loop.outer", + ["il"] = "@loop.inner", + ["ib"] = "@block.inner", + ["ab"] = "@block.outer", + ["ir"] = "@parameter.inner", + ["ar"] = "@parameter.outer", + ["a="] = "@assignment.outer", + ["i="] = "@assignment.inner", }, }, - indent = { enable = true }, - autopairs = { { enable = true } }, - textobjects = { - select = { - enable = true, - -- Automatically jump forward to textobj, similar to targets.vim - lookahead = true, - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ["af"] = "@function.outer", - ["if"] = "@function.inner", - ["ac"] = "@class.outer", - ["ic"] = "@class.inner", - ["al"] = "@loop.outer", - ["il"] = "@loop.inner", - ["ib"] = "@block.inner", - ["ab"] = "@block.outer", - ["ir"] = "@parameter.inner", - ["ar"] = "@parameter.outer", - ["a="] = "@assignment.outer", - ["i="] = "@assignment.inner", - }, - }, - }, - rainbow = { - enable = true, - extended_mode = true, -- Highlight also non-parentheses delimiters, boolean or table: lang -> boolean - max_file_lines = 2000, -- Do not enable for files with more than specified lines - }, - }) - end, + }, + rainbow = { + enable = true, + extended_mode = true, -- Highlight also non-parentheses delimiters, boolean or table: lang -> boolean + max_file_lines = 2000, -- Do not enable for files with more than specified lines + }, + }, } diff --git a/nvim/m-housh/lua/plugins/which-key.lua b/nvim/m-housh/lua/plugins/which-key.lua index 05531a2..ce7a4b6 100755 --- a/nvim/m-housh/lua/plugins/which-key.lua +++ b/nvim/m-housh/lua/plugins/which-key.lua @@ -1,8 +1,16 @@ return { - "folke/which-key.nvim", - event = "VeryLazy", - init = function() - vim.o.timeout = true - vim.o.timeoutlen = 300 - end, - } + "folke/which-key.nvim", + event = "VeryLazy", + opts = { + preset = "helix", + }, + keys = { + { + "?", + function() + require("which-key").show({ global = false }) + end, + desc = "Buffer Local Keymaps (which-key)", + }, + }, +}