Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opening files in split or vertical split doesn't work #66

Closed
Clish254 opened this issue Sep 12, 2022 · 2 comments
Closed

Opening files in split or vertical split doesn't work #66

Clish254 opened this issue Sep 12, 2022 · 2 comments

Comments

@Clish254
Copy link

Clish254 commented Sep 12, 2022

I've tried to setup nnn.nvim to open files in split and vsplit but it doesn't work. Instead 0 selected is logged.
Here is my config

require("nnn").setup({
  picker = {
    cmd = "nnn -o",      
    style = {
      width = 0.4,   
      height = 0.6,   
      border = "rounded"
    },
  },
  auto_open = {
    setup = "explorer",      
    tabpage = "explorer",     
    empty = true,     
    ft_ignore = {      
      "gitcommit",
    }
  },
  auto_close = false,  
  replace_netrw = "picker", 
})
local builtin = require("nnn").builtin
mappings = {
  { "<C-t>", builtin.open_in_tab },       -- open file(s) in tab
  { "<C-s>", builtin.open_in_split },     -- open file(s) in split
  { "<C-v>", builtin.open_in_vsplit },    -- open file(s) in vertical split
  { "<C-p>", builtin.open_in_preview },   -- open file in preview split keeping nnn focused
  { "<C-y>", builtin.copy_to_clipboard }, -- copy file(s) to clipboard
  { "<C-w>", builtin.cd_to_path },        -- cd to file directory
  { "<C-e>", builtin.populate_cmdline },  -- populate cmdline (:) with file(s)
}
@luukvbaal
Copy link
Owner

Sorry for the late response, the mapping part of your config is outside the config table. It should be:

local builtin = require("nnn").builtin
require("nnn").setup({
  picker = {
    cmd = "nnn -o",      
    style = {
      width = 0.4,   
      height = 0.6,   
      border = "rounded"
    },
  },
  auto_open = {
    setup = "explorer",      
    tabpage = "explorer",     
    empty = true,     
    ft_ignore = {      
      "gitcommit",
    }
  },
  auto_close = false,  
  replace_netrw = "picker", 
  mappings = {
    { "<C-t>", builtin.open_in_tab },       -- open file(s) in tab
    { "<C-s>", builtin.open_in_split },     -- open file(s) in split
    { "<C-v>", builtin.open_in_vsplit },    -- open file(s) in vertical split
    { "<C-p>", builtin.open_in_preview },   -- open file in preview split keeping nnn focused
    { "<C-y>", builtin.copy_to_clipboard }, -- copy file(s) to clipboard
    { "<C-w>", builtin.cd_to_path },        -- cd to file directory
    { "<C-e>", builtin.populate_cmdline },  -- populate cmdline (:) with file(s)
  }
})

@Clish254
Copy link
Author

Oh, I just copied from the readme, my bad. Works now, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants