Browse Source

nixpkgs/neovim: switch to telescope.nvim

Thomas Dy 3 years ago
parent
commit
8dc20b943f
3 changed files with 26 additions and 12 deletions
  1. 4 5
      .config/nixpkgs/neovim/flake.nix
  2. 22 1
      .config/nixpkgs/neovim/init.lua
  3. 0 6
      .config/nixpkgs/neovim/vimrc

+ 4 - 5
.config/nixpkgs/neovim/flake.nix

@@ -19,15 +19,14 @@
       };
       let
         extraPath = [
-          fzf
-          bat
+          fd
           ripgrep
           nodePackages.typescript-language-server
           nodePackages.eslint_d
         ];
       in
       neovim.override {
-        extraMakeWrapperArgs = "--prefix PATH : ${lib.makeBinPath extraPath} --set BAT_THEME OneHalfDark";
+        extraMakeWrapperArgs = "--prefix PATH : ${lib.makeBinPath extraPath}";
         configure = {
           customRC = ''
             source ${./vimrc}
@@ -42,8 +41,8 @@
               vim-abolish
               undotree
               vim-merginal
-              fzf-vim
-              fzf-lsp-nvim
+              telescope-nvim
+              telescope-fzf-native-nvim
               mini-nvim
               gitsigns-nvim
               onedark-nvim

+ 22 - 1
.config/nixpkgs/neovim/init.lua

@@ -1,3 +1,20 @@
+require('telescope').setup({
+  defaults = {
+    mappings = {
+      i = {
+        ['jj'] = 'close',
+        ['<C-j>'] = 'move_selection_next',
+        ['<C-k>'] = 'move_selection_previous',
+      },
+    },
+    layout_config = {
+      prompt_position = 'top',
+    },
+    sorting_strategy = 'ascending',
+  },
+})
+require('telescope').load_extension('fzf')
+
 require('onedark').setup({
   term_colors = false,
   transparent = true,
@@ -59,6 +76,10 @@ vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', op
 vim.api.nvim_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setqflist({ severity = { min = vim.diagnostic.severity.WARN } })<CR>', opts)
 
 vim.api.nvim_set_keymap('n', '<Leader>q', '<cmd>lua MiniBufremove.delete()<CR>', opts)
+vim.api.nvim_set_keymap('n', '<C-P>', '<cmd>Telescope find_files<CR>', opts)
+vim.api.nvim_set_keymap('n', '<C-O>', '<cmd>Telescope buffers<CR>', opts)
+vim.api.nvim_set_keymap('n', '<Leader>ff', '<cmd>Telescope live_grep<CR>', opts)
+vim.api.nvim_set_keymap('n', '<Leader>fs', '<cmd>Telescope lsp_document_symbols<CR>', opts)
 
 -- Allow pressing enter to autocomplete
 vim.api.nvim_set_keymap('i', '<CR>', 'pumvisible() ? "\\<C-y>" : "\\<CR>"', { noremap = true, expr = true })
@@ -80,7 +101,7 @@ function on_attach(client, bufnr)
   vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
   vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
   vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
-  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>References<CR>', opts)
+  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>Telescope lsp_references<CR>', opts)
   vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
 end
 

+ 0 - 6
.config/nixpkgs/neovim/vimrc

@@ -69,12 +69,6 @@ vnoremap k gk
 " cursor display
 nnoremap <Leader>c :set cursorline! cursorcolumn!<CR>
 
-" fzf
-nnoremap <C-P> :GitFiles -o -c --exclude-standard<CR>
-nnoremap <C-O> :Buffers<CR>
-nnoremap <Leader>fs :DocumentSymbols<CR>
-nnoremap <Leader>ff :Rg<SPACE>
-
 " git
 nnoremap <Leader>gs :Git<CR>
 nnoremap <Leader>gb :Merginal<CR>