Git Product home page Git Product logo

cder.nvim's Introduction

cder.nvim

A telescope.nvim extension for quickly changing your working directory.

preview

Dependencies

  • telescope.nvim
  • By default, the extension uses fd to list directories and bat to provide paging. You don't have to use these if you don't want to, but the default config will not work if you do not install them.
  • Additionally, bash is used to pipe the output of fd into bat, so if bash is not installed, the command_executor option will need to be changed.

Setup

Install using your favorite plugin manager:

packer.nvim:

use 'zane-/cder.nvim'

Load the extension into telescope:

require('telescope').load_extension('cder')

Default config:

-- The title of the prompt.
prompt_title = 'cder',

-- The command used to generate a list of directories.
-- Defaults to fd on the home directory.
-- Example for showing hidden directories:
--   dir_command = { 'fd', '--hidden', '--type=d', '.', os.getenv('HOME') },
dir_command = { 'fd', '--type=d', '.', os.getenv('HOME') },

-- The binary used to execute previewer_command | pager_command.
-- This is needed because termopen in Neovim does not support piping
-- multiple commands, so we get around this by just using bash -c.
command_executer = { 'bash', '-c' },

-- The command used to preview directories. Defaults to ls.
-- Example:
--   previewer_command = 'exa -a --icons'
previewer_command = 'ls -a',

-- The command used to page directory previews. Defaults to bat.
-- Receives the output of the previewer_command as input.
-- Example without bat:
--   pager_command = 'less -RS'
pager_command = 'bat --plain --paging=always --pager="less -RS"',

-- Function to create an entry in the picker given
-- a line outputted from the dir_command.
--   value is used as the directory in the :cd command
--   display is what is actually displayed, so this can
--     be a function that trims a path prefix for example.
entry_maker = function(line)
  return {
    value = line,
    display = function(entry)
      return '๏Š ' .. line:gsub(os.getenv('HOME') .. '/', ''), { { { 1, 3 }, 'Directory' } }
    end,
    ordinal = line,
  }
end,

To change these, use telescope's setup function. Below is the config used in the demo gif above:

require('telescope').setup({
  extensions = {
    cder = {
      previewer_command =
        'exa '..
        '-a '..
        '--color=always '..
        '-T '..
        '--level=3 '..
        '--icons '..
        '--git-ignore '..
        '--long '..
        '--no-permissions '..
        '--no-user '..
        '--no-filesize '..
        '--git '..
        '--ignore-glob=.git',
    },
  },
})

Usage

  • Open the extension with :Telescope cder
  • Search for a directory name, pressing enter on the selection will change Neovim's working directory

Mappings

Mapping Action
Ctrl + d Scroll the preview down
Ctrl + u Scroll the preview up

cder.nvim's People

Contributors

zane- avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.