Coder Social home page Coder Social logo

vim-symlink's Introduction

๐Ÿ‘‹ My name's Aymeric, I'm a Software Engineer living in Paris, France.

๐Ÿ”ญ I have a keen interest in Rust. I also like Go.

โœ๏ธ I sometime write on my blog.

๐Ÿ“ซ You can reach out to me by mail or on Twitter.

vim-symlink's People

Contributors

aymericbeaumet avatar faerryn avatar psliwka 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

Watchers

 avatar  avatar  avatar  avatar

vim-symlink's Issues

symlinks aren't resolved correctly

apologies for the vague title. this happens with neovim on ubuntu 20.04 when opening files from the command line, or from inside vim (:e). i ran into this issue when using rust.vim which doesn't autosave formatted code correctly when the file path is still a symlink.

example:

mkdir test
echo "hello" > test/hello.txt
mkdir test2 && cd test2
ln -s ../test
vim test/hello.txt

:files will show:

  1 %a   "test/hello.txt"              line 1

.. which is still a symlink.

the problem seems to be:

autocmd BufRead * nested call s:on_buf_read(expand('<afile>'))

once i changed it to:

autocmd BufRead * nested call s:on_buf_read(expand('%'))

it expands correctly:

  2 %a   "../test/hello.txt"            line 1 

Improve documentation a bit please?

  1. The Rationale section in https://github.com/aymericbeaumet/symlink.vim/blob/master/doc/symlink.txt#L27-L33 speaks about zsh and keybindings and seems to have been copied and pasted from a different plugin by accident? I can only guess at your motivation, but maybe something like

For example, if you keep your configuration files such as .bashrc in a Git repository and symlink ~/.bashrc -> ~/dotfiles/.bashrc, plugins like vim-fugitive will not realize the file is under version control as there's no ~/.git. But if you use this plugin, vim ~/.bashrc will edit ~/dotfiles/.bashrc instead, and you will be able to use vim-fugitive.

  1. The Introduction section doesn't explain what "follow symlinks" means in the Vim context. I suggest adding something like the following:

This means that if you edit a pathname that is a symlink, vim will instead open the file using the resolved target path.

Loadview not working when following a symlink

Consider the following minimal vimrc file (vimrc_min) which lives in a folder that is symlinked to $HOME/.config/nvim:

let $DOTVIM = expand('$HOME/.config/nvim')
"set runtimepath+=$DOTVIM/bundle/repos/github.com/aymericbeaumet/vim-symlink
nnoremap ,em :e $DOTVIM/vimrc_min<CR>

augroup session
    au!
    au BufWinLeave vimrc_min mkview
    au BufWinEnter vimrc_min silent! loadview
augroup END

Now, as in the GIF, do

  1. Open vim/nvim with nvim -u vimrc_min (so as to load the minimal vimrc file configuration)
  2. Press ,em to open/edit the symlinked file
  3. Notice that since vim-symlink plugin is disabled then the actual symlinked file is opened
  4. Move the cursor a aroud and then exit vim with :q
  5. Open vim again with nvim -u vimrc_min and press once again ,em to load the symlinked file
  6. Noticed that the cursor position is restored to the same position it was before quitting vim in step 4.

Now uncomment the set runtimepath line so as to enable vim-symlink plugin and repeat steps above (in 3. you'll obviously noticed that the original/target file is opened now instead of the symlink). After 6. you'll see that cursor position is not restored to the previous position but it's instead in the first line of the buffer. I naturally expect it to be restored to the "saved" position

Peek 2019-09-28 20-47

Does not work correctly with vimdiff

Thanks for your work on symlink. Probably worth pointing out this doesn't seem to work with vimdiff or vim -d (which is equivalent). Ordinarily, these commands make vim open with two or more panes for the files being compared, but with the symlink.vim plugin in place, only one pane is shown.

I currently work around this with:

    if ! &diff
        " Does not work correctly with diff mode
        Plug 'aymericbeaumet/symlink.vim'
    endif

(I use vim-plug)

However, this is not ideal. Ideally symlink.vim would either do this check itself, or even better, resolve the symlinks and continue to work in diff mode.

Thanks very much for your great work on this plugin!

Error with Neovim 0.9

Hi, this plugin has been working for me perfectly for some years (so much that I had forgotten I had it installed :) ). But I think that the latest version of neovim introduced a problem:

Error detected while processing BufReadPost Autocommands for "*":
Error executing lua callback: /usr/share/nvim/runtime/lua/editorconfig.lua:210: Invalid buffer id: 1                                                                                  
stack traceback:
        [C]: in function 'nvim_buf_get_name'
        /usr/share/nvim/runtime/lua/editorconfig.lua:210: in function 'config'
        /usr/share/nvim/runtime/plugin/editorconfig.lua:11: in function </usr/share/nvim/runtime/plugin/editorconfig.lua:4>

Do you think this is a problem with neovim or with vim-symlink? Do you think that this can be fixed easily? I tried today for a while, but I am not sure where the problem might be.

Feature request: don't follow all symlinks

Hi,

I'd like to request a feature: can we disable / enable symlink following? I want to follow some symlinks but not others. The current behavior is to automatically follow all symlinks.

vim-symlink fails with 'autocmd nesting too deep' when opening help files with a symlinked config directory

Thanks for all your hard work on this great plugin! Unfortunately, I've found an annoying corner case which I've hit which affects my usage of help files.

Recreation steps:

  • Use Neovim 0.4.3 (I suspect this will happen with other versions and regular Vim also, but I haven't tested).

  • Remove ~/.config/nvim if exists. Create a directory elsewhere (e.g. /tmp/test and symlink - cd ~/.config && ln -s /tmp/test nvim.

  • Copy the contents of this file into ~/.config/nvim as init.vim:

echom system('git clone https://github.com/kristijanhusak/vim-packager ' . $HOME . '/.config/nvim/pack/packager/opt/vim-packager')

packadd vim-packager
call packager#init()
call packager#add('kristijanhusak/vim-packager', { 'type': 'opt' })
call packager#add('moll/vim-bbye') " needed for vim-symlink
call packager#add('junegunn/fzf', { 'do': './install --bin' })
call packager#add('junegunn/fzf.vim')
call packager#add('aymericbeaumet/vim-symlink')
call packager#install()
  • Load neovim and wait for package installation to complete. Quit and restart. Ignore error about existing directory, I don't think it's relevant.

  • Type :help fzf. Expect that help loads. Instead see errors like this:

Error detected while processing function <SNR>29_on_buf_read[11]..<SNR>28_bdelete:
line   27:
E218: autocommand nesting too deep
E218: autocommand nesting too deep
E218: autocommand nesting too deep
Error detected while processing function <SNR>29_on_buf_read:
line   11:
E171: Missing :endif

Some observations:

  • I have created the above minimal setup to provide easier recreation; this happens with my full Neovim init.vim and other config also (I know the symlink is a bit unusual but I keep my config under source control so have symlinked it to elsewhere). I don't think it's that uncommon ;)

  • I don't think the fact that it's FZF is relevant; it appears this happens with any help file installed in ~/.config/nvim/pack.

  • It does not happen if ~/.config/nvim is not a symlink; if it's a regular directory the help is loaded as expected.

  • If you remove vim-bbye from the recreation init.vim, the help loads. However, this prevents vim -o working correctly with multiple files; only one window is opened.

:vim[grep] throws many errors and is extremely slow when searching in symlinked directories

Hi!

First I want to say thank you for this really helpful plugin (especially when combined with vim-fugitive).

When I search something recursively in Neovim 0.9.2 via the command

:vim /PATTERN/ /path/to/a/symlinked/dir/**/*

I get many E937: Attempt to delete a buffer that is in use: /some/path error messages.

When I uninstall vim-symlink the same command runs just fine and very quick.

BTW:
Installing the optional dependency moll/vim-bbye does also help. At the same time I'd be happy to avoid installing an additional plugin.

I created a Dockerfile with which one can easily reproduce the error.
To build the Docker image place a file named Dockerfile in some temp directory and run

docker build -t bug .

in that directory.

To run the Docker container run docker run --rm -it bug afterwards.

FROM fedora:38

RUN dnf install -y git neovim
RUN mkdir -p $HOME/.config/nvim/lua
RUN echo 'lua require("init")' > $HOME/.config/nvim/init.vim
RUN echo -e 'return {{"aymericbeaumet/vim-symlink"}}' > $HOME/.config/nvim/lua/plugins.lua
RUN echo -e '\
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"\n\
if not vim.loop.fs_stat(lazypath) then\n \
    vim.fn.system({\n \
        "git",\n \
        "clone",\n \
        "--filter=blob:none",\n \
        "https://github.com/folke/lazy.nvim.git",\n \
        "--branch=stable", -- latest stable release\n \
        lazypath,\n \
    })\n \
end\n \
vim.opt.rtp:prepend(lazypath)\n \
require("plugins")\n \
require("lazy").setup("plugins", {\n \
    ui = {\n \
        border = "rounded",\n \
        size = { width = 0.6, height = 0.9 },\n \
    }\n \
})\n' > $HOME/.config/nvim/lua/init.lua

RUN nvim --headless -c'Lazy sync' -c'q'
RUN ln -s /usr/share $HOME
CMD nvim -c'vim /PATTERN/ $HOME/share/**/*'

When the optional dependency moll/vim-bbye is being added (4th RUN statement below) the search runs without any error:

FROM fedora:38

RUN dnf install -y git neovim
RUN mkdir -p $HOME/.config/nvim/lua
RUN echo 'lua require("init")' > $HOME/.config/nvim/init.vim
RUN echo -e 'return {{"aymericbeaumet/vim-symlink", dependencies = {"moll/vim-bbye"}}}' > $HOME/.config/nvim/lua/plugins.lua
RUN echo -e '\
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"\n\
if not vim.loop.fs_stat(lazypath) then\n \
    vim.fn.system({\n \
        "git",\n \
        "clone",\n \
        "--filter=blob:none",\n \
        "https://github.com/folke/lazy.nvim.git",\n \
        "--branch=stable", -- latest stable release\n \
        lazypath,\n \
    })\n \
end\n \
vim.opt.rtp:prepend(lazypath)\n \
require("plugins")\n \
require("lazy").setup("plugins", {\n \
    ui = {\n \
        border = "rounded",\n \
        size = { width = 0.6, height = 0.9 },\n \
    }\n \
})\n' > $HOME/.config/nvim/lua/init.lua

RUN nvim --headless -c'Lazy sync' -c'q'
RUN ln -s /usr/share $HOME
CMD nvim -c'vim /PATTERN/ $HOME/share/**/*'

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.