Pārlūkot izejas kodu

add telescope config + use wilder

Noah Vogt 3 gadi atpakaļ
vecāks
revīzija
9ff1508b16

+ 1 - 0
dot-config/nvim/init.vim

@@ -12,6 +12,7 @@ source $XDG_CONFIG_HOME/nvim/plug-conf/sneak.vim
 source $XDG_CONFIG_HOME/nvim/plug-conf/airline.vim
 source $XDG_CONFIG_HOME/nvim/plug-conf/startify.vim
 source $XDG_CONFIG_HOME/nvim/plug-conf/editorconfig.vim
+source $XDG_CONFIG_HOME/nvim/plug-conf/wilder.vim
 lua require 'treesitter'
 lua require 'indent-blankline'
 lua require 'telescope'

+ 106 - 0
dot-config/nvim/lua/telescope.lua

@@ -0,0 +1,106 @@
+local status_ok, telescope = pcall(require, "telescope")
+if not status_ok then
+  return
+end
+
+telescope.load_extension('media_files')
+
+local actions = require "telescope.actions"
+
+telescope.setup {
+  defaults = {
+
+    prompt_prefix = " ",
+    selection_caret = " ",
+    path_display = { "smart" },
+
+    mappings = {
+      i = {
+        ["<C-n>"] = actions.cycle_history_next,
+        ["<C-p>"] = actions.cycle_history_prev,
+
+        ["<C-j>"] = actions.move_selection_next,
+        ["<C-k>"] = actions.move_selection_previous,
+
+        ["<C-c>"] = actions.close,
+
+
+        ["<CR>"] = actions.select_default,
+        ["<C-x>"] = actions.select_horizontal,
+        ["<C-v>"] = actions.select_vertical,
+        ["<C-t>"] = actions.select_tab,
+
+        -- use arrow key
+        ["<Down>"] = actions.move_selection_next,
+        ["<Up>"] = actions.move_selection_previous,
+
+        -- scrolling up and down the preview
+        ["<C-u>"] = actions.preview_scrolling_up,
+        ["<C-d>"] = actions.preview_scrolling_down,
+        ["<PageUp>"] = actions.results_scrolling_up,
+        ["<PageDown>"] = actions.results_scrolling_down,
+
+        ["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
+        ["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
+        ["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
+        ["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
+        ["<C-l>"] = actions.complete_tag,
+        ["<C-_>"] = actions.which_key, -- keys from pressing <C-/>
+      },
+
+      n = {
+        ["<esc>"] = actions.close,
+        ["<CR>"] = actions.select_default,
+        ["<C-x>"] = actions.select_horizontal,
+        ["<C-v>"] = actions.select_vertical,
+        ["<C-t>"] = actions.select_tab,
+
+        ["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
+        ["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
+        ["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
+        ["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
+
+        ["?"] = actions.which_key,
+
+        -- standard vim-like keys
+        ["j"] = actions.move_selection_next,
+        ["<Down>"] = actions.move_selection_next,
+        ["k"] = actions.move_selection_previous,
+        ["<Up>"] = actions.move_selection_previous,
+        ["H"] = actions.move_to_top,
+        ["M"] = actions.move_to_middle,
+        ["L"] = actions.move_to_bottom,
+        ["gg"] = actions.move_to_top,
+        ["G"] = actions.move_to_bottom,
+
+        -- scrolling up and down the preview
+        ["<C-u>"] = actions.preview_scrolling_up,
+        ["<C-d>"] = actions.preview_scrolling_down,
+        ["<PageUp>"] = actions.results_scrolling_up,
+        ["<PageDown>"] = actions.results_scrolling_down,
+      },
+    },
+  },
+  pickers = {
+    -- Default configuration for builtin pickers goes here:
+    -- picker_name = {
+    --   picker_config_key = value,
+    --   ...
+    -- }
+    -- Now the picker_config_key will be applied every time you call this
+    -- builtin picker
+  },
+  extensions = {
+    media_files = {
+        -- filetypes whitelist
+        -- defaults to {"png", "jpg", "mp4", "webm", "pdf"}
+        filetypes = {"png", "webp", "jpg", "jpeg"},
+        find_cmd = "rg" -- find command (defaults to `fd`)
+      }
+    -- Your extension configuration goes here:
+    -- extension_name = {
+    --   extension_config_key = value,
+    -- }
+    -- please take a look at the readme of the extension you want to configure
+  },
+}

+ 58 - 0
dot-config/nvim/plug-conf/wilder.vim

@@ -0,0 +1,58 @@
+call wilder#enable_cmdline_enter()
+set wildcharm=<Tab>
+cmap <expr> <Tab> wilder#in_context() ? wilder#next() : "\<Tab>"
+cmap <expr> <S-Tab> wilder#in_context() ? wilder#previous() : "\<S-Tab>"
+call wilder#set_option('modes', ['/', '?', ':'])
+
+" default keys mappings
+call wilder#setup({
+      \ 'modes': [':', '/', '?'],
+      \ 'next_key': '<Tab>',
+      \ 'previous_key': '<S-Tab>',
+      \ 'accept_key': '<Down>',
+      \ 'reject_key': '<Up>',
+      \ })
+
+"DONT FUZZY MATCH COMMANDS IT IS ANNOYING (cmdpipeline)
+call wilder#set_option('pipeline', [
+      \   wilder#branch(
+      \     wilder#cmdline_pipeline({
+      \       'fuzzy': 1,
+      \       'fuzzy_filter': wilder#vim_fuzzy_filter(),
+      \ }),
+      \     wilder#python_search_pipeline({
+      \       'pattern': 'fuzzy',
+      \     }),
+      \   ),
+      \ ])
+
+let s:highlighters = [
+        \ wilder#pcre2_highlighter(),
+        \ wilder#basic_highlighter(),
+        \ ]
+
+let s:scale = ['#f4468f', '#fd4a85', '#ff507a', '#ff566f', '#ff5e63',
+      \ '#ff6658', '#ff704e', '#ff7a45', '#ff843d', '#ff9036',
+      \ '#f89b31', '#efa72f', '#e6b32e', '#dcbe30', '#d2c934',
+      \ '#c8d43a', '#bfde43', '#b6e84e', '#aff05b']
+let s:gradient = map(s:scale, {i, fg -> wilder#make_hl(
+      \ 'WilderGradient' . i, 'Pmenu', [{}, {}, {'foreground': fg}]
+      \ )})
+
+
+call wilder#set_option('renderer', wilder#popupmenu_renderer(wilder#popupmenu_border_theme({
+      \ 'highlights': {
+      \   'gradient': s:gradient,
+      \ },
+      \ 'highlighter': s:highlighters,
+      \   'left': [
+      \     wilder#popupmenu_devicons(),
+      \   ],
+      \   'right': [
+      \     ' ',
+      \     wilder#popupmenu_scrollbar(),
+      \   ],
+      \ 'min_height': '0%',
+      \ 'max_height': '50%',
+      \ 'border': 'rounded',
+      \ })))