Code Monkey home page Code Monkey logo

move.nvim's Introduction

Hello there ๐Ÿ‘‹

counter

Editors

neovim eclipse vscode

๐Ÿ’ป OS's

nix arch debian windows

๐Ÿ“ˆ Stats

trophies

summary

move.nvim's People

Contributors

fedepujol avatar frank1998sj 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

move.nvim's Issues

Allow using some characters as "wrapper" and "anchor"

Thanks for the great plugin! I would like to ask for something extra. It would be great if move.nvim can detect some popular wrapper and anchor characters and use it to swap horizontally everything between.

Please see examples below, | is the cursor:

Example of config:

require("move.nvim").setup({
    custom_anchors: { "{,}", "<,>" },
})

Example in usages:

In TypeScript, sometimes I want to swap the imports:

// before
import { |Something, type Other, Else } from 'somewhere';

// move.nvim can detect my cursor is inside the wrapper `{ ... }` with `,` anchor,
// so if I use MoveWord(1), it will become:
import { type Other, |Something, Else } from 'somewhere';

This is also useful in some cases like:

// before
forwardRef<SomeProps, typeof Other>(...)

// move.nvim can detect my cursor is inside `< ... >` wrapper with `,` anchor
// so if I use MoveWord(), it will become:
forwardRef<typeof Other, SomeProps>(...)

Unpredictable behavior

This plugin kind of works sometimes, and sometimes it does not in an unpredictable way and I can't really find a pattern in here.

record

I have followed the installation instructions (without Legendary) and I'm using LazyNvim.

return {
  "fedepujol/move.nvim",
  config = function()
    local opts = { noremap = true, silent = true }

    -- Normal-mode commands
    vim.keymap.set('n', '<A-j>', ':MoveLine(1)<CR>', opts)
    vim.keymap.set('n', '<A-k>', ':MoveLine(-1)<CR>', opts)
    vim.keymap.set('n', '<A-h>', ':MoveHChar(-1)<CR>', opts)
    vim.keymap.set('n', '<A-l>', ':MoveHChar(1)<CR>', opts)
    vim.keymap.set('n', '<leader>wf', ':MoveWord(1)<CR>', opts)
    vim.keymap.set('n', '<leader>wb', ':MoveWord(-1)<CR>', opts)

    -- Visual-mode commands
    vim.keymap.set('v', '<A-j>', ':MoveBlock(1)<CR>', opts)
    vim.keymap.set('v', '<A-k>', ':MoveBlock(-1)<CR>', opts)
    vim.keymap.set('v', '<A-h>', ':MoveHBlock(-1)<CR>', opts)
    vim.keymap.set('v', '<A-l>', ':MoveHBlock(1)<CR>', opts)
  end,
}

Is there something I'm missing?

Require mappings don't work

This mappings:

vnoremap <silent> <A-j> <cmd>lua require('move').MoveBlock(1)<CR>
vnoremap <silent> <A-k> <cmd>lua require('move').MoveBlock(-1)<CR>
vnoremap <silent> <A-l> <cmd>lua require('move').MoveHBlock(1)<CR>
vnoremap <silent> <A-h> <cmd>lua require('move').MoveHBlock(-1)<CR>

and their lua equivalent:

vim.keymap.set('v', '<A-j>', "<Cmd>lua require('move').MoveBlock(1)<CR>", { noremap = true, silent = true })
vim.keymap.set('v', '<A-k>', "<Cmd>lua require('move').MoveBlock(-1)<CR>", { noremap = true, silent = true })
vim.keymap.set('v', '<A-l>', "<Cmd>lua require('move').MoveHBlock(1)<CR>", { noremap = true, silent = true })
vim.keymap.set('v', '<A-h>', "<Cmd>lua require('move').MoveHBlock(-1)<CR>", { noremap = true, silent = true })

Single line/char operations works fine.

Change namespace

Would love to have a Lua alternative to vim-move but currently this plugin does not work at all with my config, because I have my own lua file in my config called utils.lua, so it creates a namespace collision with your plugin.

Your directory structure should look like this:

lua/
  - move/
    - init.lua <-- move.lua contents should be moved here
    - utils.lua
    - core/
      - horiz.lua
      - vert.lua

Attempt to compare nil with number

immagine

I have those mappings:

vim.api.nvim_set_keymap('v', '<A-j>', ":MoveBlock(1)<CR>", { noremap = true, silent = true})
vim.api.nvim_set_keymap('v', '<A-k>', ":MoveBlock(-1)<CR>", { noremap = true, silent = true})

weird MoveBlock selection when moved through a foldable region

I've recorded it here, It only happens when moving the block downwards.

This was tested with more than one fold setting so I wouldn't say the issue lies there

I should point that I've faced the same issue with my hacky block-moving keybind, in fact my hope was using a more maintained solution like this plugin would fix it.

here's the same text block for testing purposes

--- defines div and mul
-- @module side

--- multiplies two numbers.
function mul(p1, p2)
  return p1 * p2
end

--- divides two numbers.
function div(p1, p2)
  return p1 / p2
end

-- entities: This &lt;foo&gt;, quot: &quot;, ampersand: &amp;
-- escaped markdown: __foo\_bar__
-- **bold** *italic*
local foo = 123

-- escaped markdown: `foo\_bar`
local bar = 123

local a = {}

local ASD = 123
local ASD = 123

Feature request: Add option to move word by word

I think it's more useful to move words around (like M-t in emacs for transposing words) than simply moving characters. dawwP and dawbP can do the same except for last word in the line. So it'll be good if this plugin can handle that.

If it's not too much to ask, I'd like to suggest more variants such as for WORDS, function arguments, sentences, paragraphs, etc. (i.e. to directly swap/move without having to enter visual mode and navigate character by character or line by line).

Thanks.

Not an editor command: MoveLine(1)

๐Ÿ‘‹๐Ÿป

I've only just noticed that this plugin has stopped working for me and it now just displays a message that suggests the plugin isn't installed correctly?

E492: Not an editor command: MoveLine(1)

Here is my config...

  {
    "fedepujol/move.nvim",
    config = function()
      local opts = { noremap = true, silent = true }
      -- Normal-mode commands
      vim.keymap.set('n', '<C-j>', ':MoveLine(1)<CR>', opts)
      vim.keymap.set('n', '<C-k>', ':MoveLine(-1)<CR>', opts)
      vim.keymap.set('n', '<C-h>', ':MoveHChar(-1)<CR>', opts)
      vim.keymap.set('n', '<C-l>', ':MoveHChar(1)<CR>', opts)

      -- Visual-mode commands
      vim.keymap.set('v', '<S-j>', ':MoveBlock(1)<CR>', opts)
      vim.keymap.set('v', '<S-k>', ':MoveBlock(-1)<CR>', opts)
      vim.keymap.set('v', '<S-h>', ':MoveHBlock(-1)<CR>', opts)
      vim.keymap.set('v', '<S-l>', ':MoveHBlock(1)<CR>', opts)
    end
  }

You can see my lazy.nvim lock file here:
https://github.com/Integralist/nvim/blob/main/lazy-lock.json#L39

It's showing as being on the latest commit for this plugin.

I'm not sure why I would be seeing this specific type of error.

Any ideas?

Thanks!

Autodetect mode

I request to make a general API that detects current user mode (normal, visual or insert) automatically by using built-in nvim_get_mode() API so we don't have to bind separate keys for moving a line or chunk of text (in visual/block mode).

Thanks!

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.