inital commit,
initalized from nix flake init -t github:BirdeeHub/nixCats-nvim#example.
This commit is contained in:
		
						commit
						9a78fd2d53
					
				
					 21 changed files with 2208 additions and 0 deletions
				
			
		
							
								
								
									
										140
									
								
								lua/myLuaConf/plugins/completion.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										140
									
								
								lua/myLuaConf/plugins/completion.lua
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,140 @@
 | 
			
		|||
local load_w_after = function(name)
 | 
			
		||||
  vim.cmd.packadd(name)
 | 
			
		||||
  vim.cmd.packadd(name .. '/after')
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
return {
 | 
			
		||||
  {
 | 
			
		||||
    "cmp-cmdline",
 | 
			
		||||
    for_cat = "general.blink",
 | 
			
		||||
    on_plugin = { "blink.cmp" },
 | 
			
		||||
    load = load_w_after,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "blink.compat",
 | 
			
		||||
    for_cat = "general.blink",
 | 
			
		||||
    dep_of = { "cmp-cmdline" },
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "luasnip",
 | 
			
		||||
    for_cat = "general.blink",
 | 
			
		||||
    dep_of = { "blink.cmp" },
 | 
			
		||||
    after = function (_)
 | 
			
		||||
      local luasnip = require 'luasnip'
 | 
			
		||||
      require('luasnip.loaders.from_vscode').lazy_load()
 | 
			
		||||
      luasnip.config.setup {}
 | 
			
		||||
 | 
			
		||||
      local ls = require('luasnip')
 | 
			
		||||
 | 
			
		||||
      vim.keymap.set({ "i", "s" }, "<M-n>", function()
 | 
			
		||||
          if ls.choice_active() then
 | 
			
		||||
              ls.change_choice(1)
 | 
			
		||||
          end
 | 
			
		||||
      end)
 | 
			
		||||
    end,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "colorful-menu.nvim",
 | 
			
		||||
    for_cat = "general.blink",
 | 
			
		||||
    on_plugin = { "blink.cmp" },
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "blink.cmp",
 | 
			
		||||
    for_cat = "general.blink",
 | 
			
		||||
    event = "DeferredUIEnter",
 | 
			
		||||
    after = function (_)
 | 
			
		||||
      require("blink.cmp").setup({
 | 
			
		||||
        -- 'default' (recommended) for mappings similar to built-in completions (C-y to accept)
 | 
			
		||||
        -- See :h blink-cmp-config-keymap for configuring keymaps
 | 
			
		||||
        keymap =  {
 | 
			
		||||
          preset = 'default',
 | 
			
		||||
        },
 | 
			
		||||
        cmdline = {
 | 
			
		||||
          enabled = true,
 | 
			
		||||
          completion = {
 | 
			
		||||
            menu = {
 | 
			
		||||
              auto_show = true,
 | 
			
		||||
            },
 | 
			
		||||
          },
 | 
			
		||||
          sources = function()
 | 
			
		||||
            local type = vim.fn.getcmdtype()
 | 
			
		||||
            -- Search forward and backward
 | 
			
		||||
            if type == '/' or type == '?' then return { 'buffer' } end
 | 
			
		||||
            -- Commands
 | 
			
		||||
            if type == ':' or type == '@' then return { 'cmdline', 'cmp_cmdline' } end
 | 
			
		||||
            return {}
 | 
			
		||||
          end,
 | 
			
		||||
        },
 | 
			
		||||
        fuzzy = {
 | 
			
		||||
          sorts = {
 | 
			
		||||
            'exact',
 | 
			
		||||
            -- defaults
 | 
			
		||||
            'score',
 | 
			
		||||
            'sort_text',
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
        signature = {
 | 
			
		||||
          enabled = true,
 | 
			
		||||
          window = {
 | 
			
		||||
            show_documentation = true,
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
        completion = {
 | 
			
		||||
          menu = {
 | 
			
		||||
            draw = {
 | 
			
		||||
              treesitter = { 'lsp' },
 | 
			
		||||
              components = {
 | 
			
		||||
                label = {
 | 
			
		||||
                  text = function(ctx)
 | 
			
		||||
                    return require("colorful-menu").blink_components_text(ctx)
 | 
			
		||||
                  end,
 | 
			
		||||
                  highlight = function(ctx)
 | 
			
		||||
                    return require("colorful-menu").blink_components_highlight(ctx)
 | 
			
		||||
                  end,
 | 
			
		||||
                },
 | 
			
		||||
              },
 | 
			
		||||
            },
 | 
			
		||||
          },
 | 
			
		||||
          documentation = {
 | 
			
		||||
            auto_show = true,
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
        snippets = {
 | 
			
		||||
          preset = 'luasnip',
 | 
			
		||||
          active = function(filter)
 | 
			
		||||
            local snippet = require "luasnip"
 | 
			
		||||
            local blink = require "blink.cmp"
 | 
			
		||||
            if snippet.in_snippet() and not blink.is_visible() then
 | 
			
		||||
              return true
 | 
			
		||||
            else
 | 
			
		||||
              if not snippet.in_snippet() and vim.fn.mode() == "n" then snippet.unlink_current() end
 | 
			
		||||
              return false
 | 
			
		||||
            end
 | 
			
		||||
          end,
 | 
			
		||||
        },
 | 
			
		||||
        sources = {
 | 
			
		||||
          default = { 'lsp', 'path', 'snippets', 'buffer', 'omni' },
 | 
			
		||||
          providers = {
 | 
			
		||||
            path = {
 | 
			
		||||
              score_offset = 50,
 | 
			
		||||
            },
 | 
			
		||||
            lsp = {
 | 
			
		||||
              score_offset = 40,
 | 
			
		||||
            },
 | 
			
		||||
            snippets = {
 | 
			
		||||
              score_offset = 40,
 | 
			
		||||
            },
 | 
			
		||||
            cmp_cmdline = {
 | 
			
		||||
              name = 'cmp_cmdline',
 | 
			
		||||
              module = 'blink.compat.source',
 | 
			
		||||
              score_offset = -100,
 | 
			
		||||
              opts = {
 | 
			
		||||
                cmp_name = 'cmdline',
 | 
			
		||||
              },
 | 
			
		||||
            },
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
      })
 | 
			
		||||
    end,
 | 
			
		||||
  },
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										315
									
								
								lua/myLuaConf/plugins/init.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										315
									
								
								lua/myLuaConf/plugins/init.lua
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,315 @@
 | 
			
		|||
local colorschemeName = nixCats('colorscheme')
 | 
			
		||||
if not require('nixCatsUtils').isNixCats then
 | 
			
		||||
  colorschemeName = 'onedark'
 | 
			
		||||
end
 | 
			
		||||
-- Could I lazy load on colorscheme with lze?
 | 
			
		||||
-- sure. But I was going to call vim.cmd.colorscheme() during startup anyway
 | 
			
		||||
-- this is just an example, feel free to do a better job!
 | 
			
		||||
vim.cmd.colorscheme(colorschemeName)
 | 
			
		||||
 | 
			
		||||
local ok, notify = pcall(require, "notify")
 | 
			
		||||
if ok then
 | 
			
		||||
  notify.setup({
 | 
			
		||||
    on_open = function(win)
 | 
			
		||||
      vim.api.nvim_win_set_config(win, { focusable = false })
 | 
			
		||||
    end,
 | 
			
		||||
  })
 | 
			
		||||
  vim.notify = notify
 | 
			
		||||
  vim.keymap.set("n", "<Esc>", function()
 | 
			
		||||
      notify.dismiss({ silent = true, })
 | 
			
		||||
  end, { desc = "dismiss notify popup and clear hlsearch" })
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- NOTE: you can check if you included the category with the thing wherever you want.
 | 
			
		||||
if nixCats('general.extra') then
 | 
			
		||||
  -- I didnt want to bother with lazy loading this.
 | 
			
		||||
  -- I could put it in opt and put it in a spec anyway
 | 
			
		||||
  -- and then not set any handlers and it would load at startup,
 | 
			
		||||
  -- but why... I guess I could make it load
 | 
			
		||||
  -- after the other lze definitions in the next call using priority value?
 | 
			
		||||
  -- didnt seem necessary.
 | 
			
		||||
  vim.g.loaded_netrwPlugin = 1
 | 
			
		||||
  require("oil").setup({
 | 
			
		||||
    default_file_explorer = true,
 | 
			
		||||
    view_options = {
 | 
			
		||||
      show_hidden = true
 | 
			
		||||
    },
 | 
			
		||||
    columns = {
 | 
			
		||||
      "icon",
 | 
			
		||||
      "permissions",
 | 
			
		||||
      "size",
 | 
			
		||||
      -- "mtime",
 | 
			
		||||
    },
 | 
			
		||||
    keymaps = {
 | 
			
		||||
      ["g?"] = "actions.show_help",
 | 
			
		||||
      ["<CR>"] = "actions.select",
 | 
			
		||||
      ["<C-s>"] = "actions.select_vsplit",
 | 
			
		||||
      ["<C-h>"] = "actions.select_split",
 | 
			
		||||
      ["<C-t>"] = "actions.select_tab",
 | 
			
		||||
      ["<C-p>"] = "actions.preview",
 | 
			
		||||
      ["<C-c>"] = "actions.close",
 | 
			
		||||
      ["<C-l>"] = "actions.refresh",
 | 
			
		||||
      ["-"] = "actions.parent",
 | 
			
		||||
      ["_"] = "actions.open_cwd",
 | 
			
		||||
      ["`"] = "actions.cd",
 | 
			
		||||
      ["~"] = "actions.tcd",
 | 
			
		||||
      ["gs"] = "actions.change_sort",
 | 
			
		||||
      ["gx"] = "actions.open_external",
 | 
			
		||||
      ["g."] = "actions.toggle_hidden",
 | 
			
		||||
      ["g\\"] = "actions.toggle_trash",
 | 
			
		||||
    },
 | 
			
		||||
  })
 | 
			
		||||
  vim.keymap.set("n", "-", "<cmd>Oil<CR>", { noremap = true, desc = 'Open Parent Directory' })
 | 
			
		||||
  vim.keymap.set("n", "<leader>-", "<cmd>Oil .<CR>", { noremap = true, desc = 'Open nvim root directory' })
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
require('lze').load {
 | 
			
		||||
  { import = "myLuaConf.plugins.telescope", },
 | 
			
		||||
  { import = "myLuaConf.plugins.treesitter", },
 | 
			
		||||
  { import = "myLuaConf.plugins.completion", },
 | 
			
		||||
  {
 | 
			
		||||
    "markdown-preview.nvim",
 | 
			
		||||
    -- NOTE: for_cat is a custom handler that just sets enabled value for us,
 | 
			
		||||
    -- based on result of nixCats('cat.name') and allows us to set a different default if we wish
 | 
			
		||||
    -- it is defined in luaUtils template in lua/nixCatsUtils/lzUtils.lua
 | 
			
		||||
    -- you could replace this with enabled = nixCats('cat.name') == true
 | 
			
		||||
    -- if you didnt care to set a different default for when not using nix than the default you already set
 | 
			
		||||
    for_cat = 'general.markdown',
 | 
			
		||||
    cmd = { "MarkdownPreview", "MarkdownPreviewStop", "MarkdownPreviewToggle", },
 | 
			
		||||
    ft = "markdown",
 | 
			
		||||
    keys = {
 | 
			
		||||
      {"<leader>mp", "<cmd>MarkdownPreview <CR>", mode = {"n"}, noremap = true, desc = "markdown preview"},
 | 
			
		||||
      {"<leader>ms", "<cmd>MarkdownPreviewStop <CR>", mode = {"n"}, noremap = true, desc = "markdown preview stop"},
 | 
			
		||||
      {"<leader>mt", "<cmd>MarkdownPreviewToggle <CR>", mode = {"n"}, noremap = true, desc = "markdown preview toggle"},
 | 
			
		||||
    },
 | 
			
		||||
    before = function(plugin)
 | 
			
		||||
      vim.g.mkdp_auto_close = 0
 | 
			
		||||
    end,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "undotree",
 | 
			
		||||
    for_cat = 'general.extra',
 | 
			
		||||
    cmd = { "UndotreeToggle", "UndotreeHide", "UndotreeShow", "UndotreeFocus", "UndotreePersistUndo", },
 | 
			
		||||
    keys = { { "<leader>U", "<cmd>UndotreeToggle<CR>", mode = { "n" }, desc = "Undo Tree" }, },
 | 
			
		||||
    before = function(_)
 | 
			
		||||
      vim.g.undotree_WindowLayout = 1
 | 
			
		||||
      vim.g.undotree_SplitWidth = 40
 | 
			
		||||
    end,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "comment.nvim",
 | 
			
		||||
    for_cat = 'general.extra',
 | 
			
		||||
    event = "DeferredUIEnter",
 | 
			
		||||
    after = function(plugin)
 | 
			
		||||
      require('Comment').setup()
 | 
			
		||||
    end,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "indent-blankline.nvim",
 | 
			
		||||
    for_cat = 'general.extra',
 | 
			
		||||
    event = "DeferredUIEnter",
 | 
			
		||||
    after = function(plugin)
 | 
			
		||||
      require("ibl").setup()
 | 
			
		||||
    end,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "nvim-surround",
 | 
			
		||||
    for_cat = 'general.always',
 | 
			
		||||
    event = "DeferredUIEnter",
 | 
			
		||||
    -- keys = "",
 | 
			
		||||
    after = function(plugin)
 | 
			
		||||
      require('nvim-surround').setup()
 | 
			
		||||
    end,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "vim-startuptime",
 | 
			
		||||
    for_cat = 'general.extra',
 | 
			
		||||
    cmd = { "StartupTime" },
 | 
			
		||||
    before = function(_)
 | 
			
		||||
      vim.g.startuptime_event_width = 0
 | 
			
		||||
      vim.g.startuptime_tries = 10
 | 
			
		||||
      vim.g.startuptime_exe_path = nixCats.packageBinPath
 | 
			
		||||
    end,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "fidget.nvim",
 | 
			
		||||
    for_cat = 'general.extra',
 | 
			
		||||
    event = "DeferredUIEnter",
 | 
			
		||||
    -- keys = "",
 | 
			
		||||
    after = function(plugin)
 | 
			
		||||
      require('fidget').setup({})
 | 
			
		||||
    end,
 | 
			
		||||
  },
 | 
			
		||||
  -- {
 | 
			
		||||
  --   "hlargs",
 | 
			
		||||
  --   for_cat = 'general.extra',
 | 
			
		||||
  --   event = "DeferredUIEnter",
 | 
			
		||||
  --   -- keys = "",
 | 
			
		||||
  --   dep_of = { "nvim-lspconfig" },
 | 
			
		||||
  --   after = function(plugin)
 | 
			
		||||
  --     require('hlargs').setup {
 | 
			
		||||
  --       color = '#32a88f',
 | 
			
		||||
  --     }
 | 
			
		||||
  --     vim.cmd([[hi clear @lsp.type.parameter]])
 | 
			
		||||
  --     vim.cmd([[hi link @lsp.type.parameter Hlargs]])
 | 
			
		||||
  --   end,
 | 
			
		||||
  -- },
 | 
			
		||||
  {
 | 
			
		||||
    "lualine.nvim",
 | 
			
		||||
    for_cat = 'general.always',
 | 
			
		||||
    -- cmd = { "" },
 | 
			
		||||
    event = "DeferredUIEnter",
 | 
			
		||||
    -- ft = "",
 | 
			
		||||
    -- keys = "",
 | 
			
		||||
    -- colorscheme = "",
 | 
			
		||||
    after = function (plugin)
 | 
			
		||||
 | 
			
		||||
      require('lualine').setup({
 | 
			
		||||
        options = {
 | 
			
		||||
          icons_enabled = false,
 | 
			
		||||
          theme = colorschemeName,
 | 
			
		||||
          component_separators = '|',
 | 
			
		||||
          section_separators = '',
 | 
			
		||||
        },
 | 
			
		||||
        sections = {
 | 
			
		||||
          lualine_c = {
 | 
			
		||||
            {
 | 
			
		||||
              'filename', path = 1, status = true,
 | 
			
		||||
            },
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
        inactive_sections = {
 | 
			
		||||
          lualine_b = {
 | 
			
		||||
            {
 | 
			
		||||
              'filename', path = 3, status = true,
 | 
			
		||||
            },
 | 
			
		||||
          },
 | 
			
		||||
          lualine_x = {'filetype'},
 | 
			
		||||
        },
 | 
			
		||||
        tabline = {
 | 
			
		||||
          lualine_a = { 'buffers' },
 | 
			
		||||
          -- if you use lualine-lsp-progress, I have mine here instead of fidget
 | 
			
		||||
          -- lualine_b = { 'lsp_progress', },
 | 
			
		||||
          lualine_z = { 'tabs' }
 | 
			
		||||
        },
 | 
			
		||||
      })
 | 
			
		||||
    end,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "gitsigns.nvim",
 | 
			
		||||
    for_cat = 'general.always',
 | 
			
		||||
    event = "DeferredUIEnter",
 | 
			
		||||
    -- cmd = { "" },
 | 
			
		||||
    -- ft = "",
 | 
			
		||||
    -- keys = "",
 | 
			
		||||
    -- colorscheme = "",
 | 
			
		||||
    after = function (plugin)
 | 
			
		||||
      require('gitsigns').setup({
 | 
			
		||||
        -- See `:help gitsigns.txt`
 | 
			
		||||
        signs = {
 | 
			
		||||
          add = { text = '+' },
 | 
			
		||||
          change = { text = '~' },
 | 
			
		||||
          delete = { text = '_' },
 | 
			
		||||
          topdelete = { text = '‾' },
 | 
			
		||||
          changedelete = { text = '~' },
 | 
			
		||||
        },
 | 
			
		||||
        on_attach = function(bufnr)
 | 
			
		||||
          local gs = package.loaded.gitsigns
 | 
			
		||||
 | 
			
		||||
          local function map(mode, l, r, opts)
 | 
			
		||||
            opts = opts or {}
 | 
			
		||||
            opts.buffer = bufnr
 | 
			
		||||
            vim.keymap.set(mode, l, r, opts)
 | 
			
		||||
          end
 | 
			
		||||
 | 
			
		||||
          -- Navigation
 | 
			
		||||
          map({ 'n', 'v' }, ']c', function()
 | 
			
		||||
            if vim.wo.diff then
 | 
			
		||||
              return ']c'
 | 
			
		||||
            end
 | 
			
		||||
            vim.schedule(function()
 | 
			
		||||
              gs.next_hunk()
 | 
			
		||||
            end)
 | 
			
		||||
            return '<Ignore>'
 | 
			
		||||
          end, { expr = true, desc = 'Jump to next hunk' })
 | 
			
		||||
 | 
			
		||||
          map({ 'n', 'v' }, '[c', function()
 | 
			
		||||
            if vim.wo.diff then
 | 
			
		||||
              return '[c'
 | 
			
		||||
            end
 | 
			
		||||
            vim.schedule(function()
 | 
			
		||||
              gs.prev_hunk()
 | 
			
		||||
            end)
 | 
			
		||||
            return '<Ignore>'
 | 
			
		||||
          end, { expr = true, desc = 'Jump to previous hunk' })
 | 
			
		||||
 | 
			
		||||
          -- Actions
 | 
			
		||||
          -- visual mode
 | 
			
		||||
          map('v', '<leader>hs', function()
 | 
			
		||||
            gs.stage_hunk { vim.fn.line '.', vim.fn.line 'v' }
 | 
			
		||||
          end, { desc = 'stage git hunk' })
 | 
			
		||||
          map('v', '<leader>hr', function()
 | 
			
		||||
            gs.reset_hunk { vim.fn.line '.', vim.fn.line 'v' }
 | 
			
		||||
          end, { desc = 'reset git hunk' })
 | 
			
		||||
          -- normal mode
 | 
			
		||||
          map('n', '<leader>gs', gs.stage_hunk, { desc = 'git stage hunk' })
 | 
			
		||||
          map('n', '<leader>gr', gs.reset_hunk, { desc = 'git reset hunk' })
 | 
			
		||||
          map('n', '<leader>gS', gs.stage_buffer, { desc = 'git Stage buffer' })
 | 
			
		||||
          map('n', '<leader>gu', gs.undo_stage_hunk, { desc = 'undo stage hunk' })
 | 
			
		||||
          map('n', '<leader>gR', gs.reset_buffer, { desc = 'git Reset buffer' })
 | 
			
		||||
          map('n', '<leader>gp', gs.preview_hunk, { desc = 'preview git hunk' })
 | 
			
		||||
          map('n', '<leader>gb', function()
 | 
			
		||||
            gs.blame_line { full = false }
 | 
			
		||||
          end, { desc = 'git blame line' })
 | 
			
		||||
          map('n', '<leader>gd', gs.diffthis, { desc = 'git diff against index' })
 | 
			
		||||
          map('n', '<leader>gD', function()
 | 
			
		||||
            gs.diffthis '~'
 | 
			
		||||
          end, { desc = 'git diff against last commit' })
 | 
			
		||||
 | 
			
		||||
          -- Toggles
 | 
			
		||||
          map('n', '<leader>gtb', gs.toggle_current_line_blame, { desc = 'toggle git blame line' })
 | 
			
		||||
          map('n', '<leader>gtd', gs.toggle_deleted, { desc = 'toggle git show deleted' })
 | 
			
		||||
 | 
			
		||||
          -- Text object
 | 
			
		||||
          map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>', { desc = 'select git hunk' })
 | 
			
		||||
        end,
 | 
			
		||||
      })
 | 
			
		||||
      vim.cmd([[hi GitSignsAdd guifg=#04de21]])
 | 
			
		||||
      vim.cmd([[hi GitSignsChange guifg=#83fce6]])
 | 
			
		||||
      vim.cmd([[hi GitSignsDelete guifg=#fa2525]])
 | 
			
		||||
    end,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    "which-key.nvim",
 | 
			
		||||
    for_cat = 'general.extra',
 | 
			
		||||
    -- cmd = { "" },
 | 
			
		||||
    event = "DeferredUIEnter",
 | 
			
		||||
    -- ft = "",
 | 
			
		||||
    -- keys = "",
 | 
			
		||||
    -- colorscheme = "",
 | 
			
		||||
    after = function (plugin)
 | 
			
		||||
      require('which-key').setup({
 | 
			
		||||
      })
 | 
			
		||||
      require('which-key').add {
 | 
			
		||||
        { "<leader><leader>", group = "buffer commands" },
 | 
			
		||||
        { "<leader><leader>_", hidden = true },
 | 
			
		||||
        { "<leader>c", group = "[c]ode" },
 | 
			
		||||
        { "<leader>c_", hidden = true },
 | 
			
		||||
        { "<leader>d", group = "[d]ocument" },
 | 
			
		||||
        { "<leader>d_", hidden = true },
 | 
			
		||||
        { "<leader>g", group = "[g]it" },
 | 
			
		||||
        { "<leader>g_", hidden = true },
 | 
			
		||||
        { "<leader>m", group = "[m]arkdown" },
 | 
			
		||||
        { "<leader>m_", hidden = true },
 | 
			
		||||
        { "<leader>r", group = "[r]ename" },
 | 
			
		||||
        { "<leader>r_", hidden = true },
 | 
			
		||||
        { "<leader>s", group = "[s]earch" },
 | 
			
		||||
        { "<leader>s_", hidden = true },
 | 
			
		||||
        { "<leader>t", group = "[t]oggles" },
 | 
			
		||||
        { "<leader>t_", hidden = true },
 | 
			
		||||
        { "<leader>w", group = "[w]orkspace" },
 | 
			
		||||
        { "<leader>w_", hidden = true },
 | 
			
		||||
      }
 | 
			
		||||
    end,
 | 
			
		||||
  },
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										126
									
								
								lua/myLuaConf/plugins/telescope.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										126
									
								
								lua/myLuaConf/plugins/telescope.lua
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,126 @@
 | 
			
		|||
-- Telescope is a fuzzy finder that comes with a lot of different things that
 | 
			
		||||
-- it can fuzzy find! It's more than just a "file finder", it can search
 | 
			
		||||
-- many different aspects of Neovim, your workspace, LSP, and more!
 | 
			
		||||
--
 | 
			
		||||
-- The easiest way to use telescope, is to start by doing something like:
 | 
			
		||||
--  :Telescope help_tags
 | 
			
		||||
--
 | 
			
		||||
-- After running this command, a window will open up and you're able to
 | 
			
		||||
-- type in the prompt window. You'll see a list of help_tags options and
 | 
			
		||||
-- a corresponding preview of the help.
 | 
			
		||||
--
 | 
			
		||||
-- Two important keymaps to use while in telescope are:
 | 
			
		||||
--  - Insert mode: <c-/>
 | 
			
		||||
--  - Normal mode: ?
 | 
			
		||||
--
 | 
			
		||||
-- This opens a window that shows you all of the keymaps for the current
 | 
			
		||||
-- telescope picker. This is really useful to discover what Telescope can
 | 
			
		||||
-- do as well as how to actually do it!
 | 
			
		||||
 | 
			
		||||
-- [[ Configure Telescope ]]
 | 
			
		||||
-- See `:help telescope` and `:help telescope.setup()`
 | 
			
		||||
 | 
			
		||||
-- Telescope live_grep in git root
 | 
			
		||||
-- Function to find the git root directory based on the current buffer's path
 | 
			
		||||
local function find_git_root()
 | 
			
		||||
  -- Use the current buffer's path as the starting point for the git search
 | 
			
		||||
  local current_file = vim.api.nvim_buf_get_name(0)
 | 
			
		||||
  local current_dir
 | 
			
		||||
  local cwd = vim.fn.getcwd()
 | 
			
		||||
  -- If the buffer is not associated with a file, return nil
 | 
			
		||||
  if current_file == "" then
 | 
			
		||||
    current_dir = cwd
 | 
			
		||||
  else
 | 
			
		||||
    -- Extract the directory from the current file's path
 | 
			
		||||
    current_dir = vim.fn.fnamemodify(current_file, ":h")
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  -- Find the Git root directory from the current file's path
 | 
			
		||||
  local git_root = vim.fn.systemlist("git -C " .. vim.fn.escape(current_dir, " ") .. " rev-parse --show-toplevel")[1]
 | 
			
		||||
  if vim.v.shell_error ~= 0 then
 | 
			
		||||
    print("Not a git repository. Searching on current working directory")
 | 
			
		||||
    return cwd
 | 
			
		||||
  end
 | 
			
		||||
  return git_root
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Custom live_grep function to search in git root
 | 
			
		||||
local function live_grep_git_root()
 | 
			
		||||
  local git_root = find_git_root()
 | 
			
		||||
  if git_root then
 | 
			
		||||
    require('telescope.builtin').live_grep({
 | 
			
		||||
      search_dirs = { git_root },
 | 
			
		||||
    })
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
return {
 | 
			
		||||
  {
 | 
			
		||||
    "telescope.nvim",
 | 
			
		||||
    for_cat = 'general.telescope',
 | 
			
		||||
    cmd = { "Telescope", "LiveGrepGitRoot" },
 | 
			
		||||
    -- NOTE: our on attach function defines keybinds that call telescope.
 | 
			
		||||
    -- so, the on_require handler will load telescope when we use those.
 | 
			
		||||
    on_require = { "telescope", },
 | 
			
		||||
    -- event = "",
 | 
			
		||||
    -- ft = "",
 | 
			
		||||
    keys = {
 | 
			
		||||
      { "<leader>sM", '<cmd>Telescope notify<CR>', mode = {"n"}, desc = '[S]earch [M]essage', },
 | 
			
		||||
      { "<leader>sp",live_grep_git_root, mode = {"n"}, desc = '[S]earch git [P]roject root', },
 | 
			
		||||
      { "<leader>/", function()
 | 
			
		||||
        -- Slightly advanced example of overriding default behavior and theme
 | 
			
		||||
        -- You can pass additional configuration to telescope to change theme, layout, etc.
 | 
			
		||||
        require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
 | 
			
		||||
          winblend = 10,
 | 
			
		||||
          previewer = false,
 | 
			
		||||
        })
 | 
			
		||||
      end, mode = {"n"}, desc = '[/] Fuzzily search in current buffer', },
 | 
			
		||||
      { "<leader>s/", function()
 | 
			
		||||
        require('telescope.builtin').live_grep {
 | 
			
		||||
          grep_open_files = true,
 | 
			
		||||
          prompt_title = 'Live Grep in Open Files',
 | 
			
		||||
        }
 | 
			
		||||
      end, mode = {"n"}, desc = '[S]earch [/] in Open Files' },
 | 
			
		||||
      { "<leader><leader>s", function() return require('telescope.builtin').buffers() end, mode = {"n"}, desc = '[ ] Find existing buffers', },
 | 
			
		||||
      { "<leader>s.", function() return require('telescope.builtin').oldfiles() end, mode = {"n"}, desc = '[S]earch Recent Files ("." for repeat)', },
 | 
			
		||||
      { "<leader>sr", function() return require('telescope.builtin').resume() end, mode = {"n"}, desc = '[S]earch [R]esume', },
 | 
			
		||||
      { "<leader>sd", function() return require('telescope.builtin').diagnostics() end, mode = {"n"}, desc = '[S]earch [D]iagnostics', },
 | 
			
		||||
      { "<leader>sg", function() return require('telescope.builtin').live_grep() end, mode = {"n"}, desc = '[S]earch by [G]rep', },
 | 
			
		||||
      { "<leader>sw", function() return require('telescope.builtin').grep_string() end, mode = {"n"}, desc = '[S]earch current [W]ord', },
 | 
			
		||||
      { "<leader>ss", function() return require('telescope.builtin').builtin() end, mode = {"n"}, desc = '[S]earch [S]elect Telescope', },
 | 
			
		||||
      { "<leader>sf", function() return require('telescope.builtin').find_files() end, mode = {"n"}, desc = '[S]earch [F]iles', },
 | 
			
		||||
      { "<leader>sk", function() return require('telescope.builtin').keymaps() end, mode = {"n"}, desc = '[S]earch [K]eymaps', },
 | 
			
		||||
      { "<leader>sh", function() return require('telescope.builtin').help_tags() end, mode = {"n"}, desc = '[S]earch [H]elp', },
 | 
			
		||||
    },
 | 
			
		||||
    -- colorscheme = "",
 | 
			
		||||
    load = function (name)
 | 
			
		||||
        vim.cmd.packadd(name)
 | 
			
		||||
        vim.cmd.packadd("telescope-fzf-native.nvim")
 | 
			
		||||
        vim.cmd.packadd("telescope-ui-select.nvim")
 | 
			
		||||
    end,
 | 
			
		||||
    after = function (plugin)
 | 
			
		||||
      require('telescope').setup {
 | 
			
		||||
        -- You can put your default mappings / updates / etc. in here
 | 
			
		||||
        --  All the info you're looking for is in `:help telescope.setup()`
 | 
			
		||||
        --
 | 
			
		||||
        defaults = {
 | 
			
		||||
          mappings = {
 | 
			
		||||
            i = { ['<c-enter>'] = 'to_fuzzy_refine' },
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
        -- pickers = {}
 | 
			
		||||
        extensions = {
 | 
			
		||||
          ['ui-select'] = {
 | 
			
		||||
            require('telescope.themes').get_dropdown(),
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      -- Enable telescope extensions, if they are installed
 | 
			
		||||
      pcall(require('telescope').load_extension, 'fzf')
 | 
			
		||||
      pcall(require('telescope').load_extension, 'ui-select')
 | 
			
		||||
 | 
			
		||||
      vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {})
 | 
			
		||||
    end,
 | 
			
		||||
  },
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										78
									
								
								lua/myLuaConf/plugins/treesitter.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								lua/myLuaConf/plugins/treesitter.lua
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,78 @@
 | 
			
		|||
-- [[ Configure Treesitter ]]
 | 
			
		||||
-- See `:help nvim-treesitter`
 | 
			
		||||
return {
 | 
			
		||||
  {
 | 
			
		||||
    "nvim-treesitter",
 | 
			
		||||
    for_cat = 'general.treesitter',
 | 
			
		||||
    -- cmd = { "" },
 | 
			
		||||
    event = "DeferredUIEnter",
 | 
			
		||||
    -- ft = "",
 | 
			
		||||
    -- keys = "",
 | 
			
		||||
    -- colorscheme = "",
 | 
			
		||||
    load = function (name)
 | 
			
		||||
        vim.cmd.packadd(name)
 | 
			
		||||
        vim.cmd.packadd("nvim-treesitter-textobjects")
 | 
			
		||||
    end,
 | 
			
		||||
    after = function (plugin)
 | 
			
		||||
      -- [[ Configure Treesitter ]]
 | 
			
		||||
      -- See `:help nvim-treesitter`
 | 
			
		||||
      require('nvim-treesitter.configs').setup {
 | 
			
		||||
        highlight = { enable = true, },
 | 
			
		||||
        indent = { enable = false, },
 | 
			
		||||
        incremental_selection = {
 | 
			
		||||
          enable = true,
 | 
			
		||||
          keymaps = {
 | 
			
		||||
            init_selection = '<c-space>',
 | 
			
		||||
            node_incremental = '<c-space>',
 | 
			
		||||
            scope_incremental = '<c-s>',
 | 
			
		||||
            node_decremental = '<M-space>',
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
        textobjects = {
 | 
			
		||||
          select = {
 | 
			
		||||
            enable = true,
 | 
			
		||||
            lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
 | 
			
		||||
            keymaps = {
 | 
			
		||||
              -- You can use the capture groups defined in textobjects.scm
 | 
			
		||||
              ['aa'] = '@parameter.outer',
 | 
			
		||||
              ['ia'] = '@parameter.inner',
 | 
			
		||||
              ['af'] = '@function.outer',
 | 
			
		||||
              ['if'] = '@function.inner',
 | 
			
		||||
              ['ac'] = '@class.outer',
 | 
			
		||||
              ['ic'] = '@class.inner',
 | 
			
		||||
            },
 | 
			
		||||
          },
 | 
			
		||||
          move = {
 | 
			
		||||
            enable = true,
 | 
			
		||||
            set_jumps = true, -- whether to set jumps in the jumplist
 | 
			
		||||
            goto_next_start = {
 | 
			
		||||
              [']m'] = '@function.outer',
 | 
			
		||||
              [']]'] = '@class.outer',
 | 
			
		||||
            },
 | 
			
		||||
            goto_next_end = {
 | 
			
		||||
              [']M'] = '@function.outer',
 | 
			
		||||
              [']['] = '@class.outer',
 | 
			
		||||
            },
 | 
			
		||||
            goto_previous_start = {
 | 
			
		||||
              ['[m'] = '@function.outer',
 | 
			
		||||
              ['[['] = '@class.outer',
 | 
			
		||||
            },
 | 
			
		||||
            goto_previous_end = {
 | 
			
		||||
              ['[M'] = '@function.outer',
 | 
			
		||||
              ['[]'] = '@class.outer',
 | 
			
		||||
            },
 | 
			
		||||
          },
 | 
			
		||||
          swap = {
 | 
			
		||||
            enable = true,
 | 
			
		||||
            swap_next = {
 | 
			
		||||
              ['<leader>a'] = '@parameter.inner',
 | 
			
		||||
            },
 | 
			
		||||
            swap_previous = {
 | 
			
		||||
              ['<leader>A'] = '@parameter.inner',
 | 
			
		||||
            },
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
      }
 | 
			
		||||
    end,
 | 
			
		||||
  },
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue