Code Monkey home page Code Monkey logo

reach.nvim's People

Contributors

nacho114 avatar toppair avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

reach.nvim's Issues

More intelligent / dynamic handles?

Hi, and thanks for this plugin. It's my go-to buffer switcher 🐵

However! I've never had this plugin working as I want it. Look at the gif in the readme:

image

Reach seems to be advertising a really intuitive sort of handle naming. When I first came across Reach, I imagined that I could open it up in my Neovim project session and immediately see something like:

[il] init.lua
[iv] init.vim
[p] plugins.lua
[tn] todo-neovim
[tt] todo-telescope

That is, I thought the handle naming would be intelligent, and subtle! Why isn't it? Surely there is a way to make it work. And if not, have you considered it?

I had in mind the sort of set-up where I could easily build up the muscle memory of pressing F9 (my Reach key) and then p to e.g. jump directly to plugins.lua in my Neovim project session. To reach effortlessly, thoughtlessly into the bufferspace and pull out exactly the file I need. With eyes closed!

Show short path instead of filename only?

How can we display buffer with its short path like: ~/.con/nv/pa/d/s/vi/README.md (as full path of ~/.config/nvim/pack/default/start/vim-bufferline) instead of display only file name README.md?

this is because we can have multiple buffers with same filename, and showing path as above will help distinguish buffers better.

Search by name

Thank you for this plugin, it's very cool, it does one thing and does it well 👍

This is a feature request: I am wondering if it would be possible to search for a buffer name (currently I type :b name and then choose the right one), I know there is telescope and so on but I wouldn't use all their options so …

Escape deletion mode on <Esc>

Now the switcher is closed on <Esc>, but that'd be nice if we could switch modes like <Space> for Delete mode and then <Esc> for Normal mode to switch buffer after some cleanup.

Tab to switch to most recent buffer

I currently map tab to open reach, but I was wondering if I could somehow tab again after opening reach to switch to my most recently visited buffer.

Bug: buffer remains open after split option

When using reach like so:

  require("reach").setup({ notifications = true })
  require("reach").buffers({
    modified_icon = "*",
    filter = function(bufnr)
      local buftype = vim.api.nvim_buf_get_option(bufnr, "buftype")
      if buftype == "terminal" then
        return false
      end

      return true
    end,
    actions = {
      -- Need to be upper case as this is what `getcharstr` and `keytrans` output
      split = "<C-X>",
      vertsplit = "<C-V>",
      tabsplit = "<C-T>",
      delete = "<C-Q>",
    },
  })

I can do the following:

  1. :edit buffer A
  2. :edit buffer B
  3. Open reach
  4. Press <C-V> with the goal of vertically splitting buffer A
  5. Press 2 to select buffer A
  6. Buffer is vertically split as expected
  7. reach buffer is left open

Like so:

reach_popup-2022-10-03_17.38.49.mp4

At the end there, I would expect the reach buffer to not reopen. This could also very much be user error, so let me know if there needs to be clarification or if there's anything I should be doing differently.

`keytrans` keycodes might not match user keycodes

Thanks for the additions on #11!

The intention of this issue is to report something else, but just FYI on that feature it requires that you send keycodes as they are returned by vim.fn.keytrans - e.g. <C-v> does not work, but <C-V> does. Not sure if there is something that can be done with the vim.tbl_contains to convert values to lowercase without messing up other things, but that might be a good way to allow users to specify keycodes however they like.

Global configuration with optional override in functions

A global configuration table passed into the .setup method. For example (pseudo code):

require('reach').setup({
  global = {
    ...
  },
  buffers = {
    ...
  },
  marks = {
    ...
  },
  colorschemes = {
    ...
  },
  tabpages = {
    ...
  },
})

The functions used to open the pickers would then use the above configuration as a default except when additional options were given as parameters. For example:

require('reach').buffers({ show_current = false })

How to to call ReachOpen buffers with options.

Hi,

I am new to lua based config, so this is probably trivial if you do know it, but how do I run ReachOpen buffers with options (i.e. custom config)?

:ReachOpen buffers, works as intended, I also added my on options as shown in the Readme (which does not change the behavior of ReachOpen buffers, which is expected from the doc).

But how do I run ReachOpen buffers with my options?

-- default
local options = {
  handle = 'auto',              -- 'bufnr' or 'dynamic' or 'auto'
  show_icons = true,
  show_current = false,         -- Include current buffer in the list
  show_modified = true,         -- Show buffer modified indicator
  modified_icon = '',          -- Character to use as modified indicator
  grayout_current = true,       -- Wheter to gray out current buffer entry
  force_delete = {},            -- List of filetypes / buftypes to use
                                -- 'bdelete!' on, e.g. { 'terminal' }
  filter = nil,                 -- Function taking bufnr as parameter,
                                -- returning true or false
  sort = nil,                   -- Comparator function (bufnr, bufnr) -> bool
  terminal_char = '\\',         -- Character to use for terminal buffer handles
                                -- when options.handle is 'dynamic'
  grayout = true,               -- Gray out non matching entries

  -- A list of characters to use as handles when options.handle == 'auto'
  auto_handles = require('reach.buffers.constant').auto_handles,

  auto_exclude_handles = {'1', '2', '3'},    -- A list of characters not to use as handles when
                                -- options.handle == 'auto', e.g. { '8', '9', 'j', 'k' }
  previous = {
    enable = true,              -- Mark last used buffers with specified chars and colors
    depth = 2,                  -- Maximum number of buffers to mark
    chars = { '' },            -- Characters to use as markers,
                                -- last one is used when depth > #chars
    groups = {                  -- Highlight groups for markers,
      'String',                 -- last one is used when depth > #groups
      'Comment',
    },
  },
  -- A map of action to key that should be used to invoke it
  actions = {
    split = '-',
    vertsplit = '|',
    tabsplit = ']',
    delete = '<Space>',
    priority = '=',
  },
}
require('reach').buffers(options)

I tried something like this:

vim.keymap.set('n', '<leader>rb', require('reach').buffers(options), {})

but I get a RHS nil error, so I guess this is not how it is intended. If you could tell me how to call it that would be great!

Love the plugin otherwise!

Add `per_tabpage` to reach.buffers options

This would be the missing piece to make reach integrate with neovim tabs the way they were designed to be used, As separate work spaces.

Here are some places that implement it:

I think reach.marks can benefit from this as well but I don't use marks and hence I can't tell for sure.
LMK what you think.

Harpoon like bookmark

Hi, awesome project here, love the UI.

Would be awesome to have a file bookmark by cwd using reach.

i know that is possible to do it with marks (using uppercase letters), but a only file bookmark (without line), that auto-assigns to 1,2,3,4 and works based on cwd would be incredible with reach.

ReachOpen buffers not working

Hi,
After installing the plugin, without any configuration, I got all ReachOpen commands working fine, but the buffers argument.
The command ReachOpen buffers throws the following error message:

E5108: Error executing lua ...im/site/pack/packer/start/reach.nvim/lua/reach/cache.lua:126: attempt to index upvalue 'cache_cwd' (a nil value)                        
stack traceback:
        ...im/site/pack/packer/start/reach.nvim/lua/reach/cache.lua:126: in function 'get'
        .../pack/packer/start/reach.nvim/lua/reach/buffers/sort.lua:31: in function 'sort_priority'
        ...cker/start/reach.nvim/lua/reach/buffers/make_buffers.lua:91: in function 'make_buffers'
        ...vim/site/pack/packer/start/reach.nvim/lua/reach/init.lua:34: in function 'buffers'
        [string ":lua"]:1: in main chunk

Thanks for your time.

Add `handle_chars` to reach.buffers options

currently one can exclude handle chars using the auto_exclude_handles which works great but there's a bit left to be desired, consider the following use case:

I wanted my buffers handle chars to be selected in this order
1 2 3 4 q w e r a s d f z x c v

I've tried excluding everything else in auto_exclude_handles but of course the selection is now alphabetically ordered like so
1 2 3 4 a c d e f q r s v w x z
which is really disorienting

I figured the best non-breaking way of doing this would be to give the user the ability to override buffers.constant.auto_handles with an option maybe called handle_chars

Let me know what you think.

Couple hairs in the soup

Amazing work, a couple hairs in the soup tho:

1. Current Buffer hiding

Currently my current buffer is hidden from the list, which really messes with the mental list of open buffers.
I've set hide_current() to always return true for now, My hope is this becoming something configurable, maybe gray it out as well.

2. Modified buffer icon

show_modified is great, It would be nice to have an option to customize its icon (currently hardcoded here)

3. Instant switching

It would be great to switch buffers without opening :ReachOpen buffers. It seems to me that the switching logic is coded inline inside a state machine, It would have to be abstracted into a separate function/s first before this can be achieved.

Let me know what you think, cheers!

Customize split keys

Right now it appears that things like |, -, etc. are all hard-coded:

local split_commands = {
  ['|'] = 'vertical sbuffer',
  ['-'] = 'sbuffer',
  [']'] = 'tab sbuffer',
}

and private. It would be nice to be able to set something up like <C-v> to vertically split a window to be more aligned with the way I have other keymaps setup in my config.

Is something like this possible?

ReachOpen crashes when the number of buffers is huge

Hello,

I tried to open the buffer windows with the default configuration and a huge number of buffers (999), it resulted in the following crash:

E5108: Error executing lua ...vim/site/pack/packer/start/reach.nvim/lua/reach/init.lua:49: attempt to get length of field 'handle' (a nil value)
stack traceback:
        ...vim/site/pack/packer/start/reach.nvim/lua/reach/init.lua:49: in function 'buffers'
        [string ":lua"]:1: in main chunk
Press ENTER or type command to continue

After some search I noticed that it fails when you have 94 or more buffers.

ReachOpen buffers triggers attempt to index upvalue 'cache_cwd' (a nil value)

Currently doing ReachOpen buffers gives the following error:

E5108: Error executing lua ...im/site/pack/packer/start/reach.nvim/lua/reach/cache.lua:126: attempt to index upvalue 'cache_cwd' (a nil value)
stack traceback:
        ...im/site/pack/packer/start/reach.nvim/lua/reach/cache.lua:126: in function 'get'
        .../pack/packer/start/reach.nvim/lua/reach/buffers/sort.lua:31: in function 'sort_priority'
        ...cker/start/reach.nvim/lua/reach/buffers/make_buffers.lua:91: in function 'make_buffers'
        ...vim/site/pack/packer/start/reach.nvim/lua/reach/init.lua:30: in function 'buffers'
        [string ":lua"]:1: in main chunk

nvim --version:

NVIM v0.7.0-dev+1242-gab456bc30
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/jemag/Projects/github-reference/neovim/src/build/config -I/home/jemag/Projects/github-reference/neovim/src/src -I/home/jemag/Projects/github-reference/neovim/src/.deps/usr/include -I/usr/include -I/home/jemag/Projects/github-reference/neovim/src/build/src/nvim/auto -I/home/jemag/Projects/github-reference/neovim/src/build/include
Compiled by jemag@archhome

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/home/jemag/Projects/github-reference/neovim/build/share/nvim"

Run :checkhealth for more info

Reproduction steps:

  1. Open a file with minimal_init.lua: nvim --noplugin -u minimal_init.lua error.yaml
  2. Enter the cmd: ReachOpen buffers
  3. Notice error

minimal_init.lua:

local on_windows = vim.loop.os_uname().version:match 'Windows'
vim.api.nvim_command("!rm -rf /tmp/nvim")

local function join_paths(...)
  local path_sep = on_windows and '\\' or '/'
  local result = table.concat({ ... }, path_sep)
  return result
end

vim.cmd [[set runtimepath=$VIMRUNTIME]]

local temp_dir = vim.loop.os_getenv 'TEMP' or '/tmp'

vim.cmd('set packpath=' .. join_paths(temp_dir, 'nvim', 'site'))

local package_root = join_paths(temp_dir, 'nvim', 'site', 'pack')
local install_path = join_paths(package_root, 'packer', 'start', 'packer.nvim')
local compile_path = join_paths(install_path, 'plugin', 'packer_compiled.lua')

local function load_plugins()
  require('packer').startup {
    {
      'wbthomason/packer.nvim',
      'toppair/reach.nvim'
    },
    config = {
      package_root = package_root,
      compile_path = compile_path,
    },
  }
end



if vim.fn.isdirectory(install_path) == 0 then
  vim.fn.system { 'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path }
  load_plugins()
  require('packer').sync()
else
  load_plugins()
  require('packer').sync()
end

Marks and tabpages work fine

Ctrl-C breaks function when handling keystroke

Reproduce:

  1. Run :ReachOpen buffers.
  2. Press Ctrl-C.

Behavior:
Show this error log, and leave floating window opened, no normal way to close it.

E5108: Error executing lua: Keyboard interrupt
stack traceback:
        [C]: in function 'getcharstr'
        .../pack/packer/start/reach.nvim/lua/reach/buffers/init.lua:146: in function 'on_enter'
        .../site/pack/packer/start/reach.nvim/lua/reach/machine.lua:15: in function 'init'
        ...vim/site/pack/packer/start/reach.nvim/lua/reach/init.lua:84: in function <...vim/site/pack/packer/start/reach.nvim/lua/reach/init.lua:31>

https://github.com/toppair/reach.nvim/blob/50d91d2fed/lua/reach/buffers/init.lua#L146

Maybe use pcall(vim.fn.getcharstr) instead?

Error when starting reach when .cache/nvim does not exist

Hi,

When doing a setup on a clean machine I got an error (see bellow); I suspect it was not able to create reach_cache since the folder .cache/nvim did not exist. (I fixed it by creating the .cache/nvim folder.

Is this expected behavior? Or should it create the cache nvim folder if it does not exist? (Happy to give a hand!)

This is the error that occurs:

Error detected while processing /Users/nacho/.config/nvim/init.vim:
line  216:
E5108: Error executing lua Vim:E482: Can't open file /Users/nacho/.cache/nvim/reach_cache for writing: no such file or directory
stack traceback:
        [C]: in function 'writefile'
        ...acho/.config/nvim/plugged/reach.nvim/lua/reach/cache.lua:46: in function 'read_cache'
        ...acho/.config/nvim/plugged/reach.nvim/lua/reach/cache.lua:74: in function 'load'
        ...acho/.config/nvim/plugged/reach.nvim/lua/reach/cache.lua:63: in function 'setup'
        ...nacho/.config/nvim/plugged/reach.nvim/lua/reach/init.lua:28: in function 'setup'
        /Users/nacho/.config/nvim/lua/init.lua:1: in main chunk
        [C]: in function 'require'
        [string ":lua"]:1: in main chunk
Press ENTER or type command to continue

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.