Git Product home page Git Product logo

vim-relativity's People

Contributors

choco avatar kennykaye avatar

Stargazers

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

Watchers

 avatar  avatar

Forkers

choco

vim-relativity's Issues

Start from number 2?

Is it possible to start relative line numbering from number 2, not from 1? I mean, shouldn't the current line count as 1, and shouldn't then the next one below count as 2?

Don't mess with number and relative numbers if they both are disabled with ftplugin

My ~/.vim/ftplugin/markdown.vim file has,

setlocal nonumber
setlocal norelativenumber

and this plugin doesn't respect my own settings and overrides them. So, if user explicitly has set nonumber and norelativenumber this plugin shouldn't override them.

This also potentially will solve the problem with g:relativity_filetype_ignore variable. Instead of blacklisting common buffer names, check their number and relativenumber options first.

PS: I don't use this plugin, I just came to look your code and this is my friendly feedback.

I've been using something like this instead of this plugin, FYI.

augroup togglerelativelinenumbers
	autocmd!
	autocmd InsertEnter,BufLeave,WinLeave,FocusLost *
		\ if &l:number && empty(&buftype) |
			\ setlocal norelativenumber |
		\ endif
	autocmd InsertLeave,BufEnter,WinEnter,FocusGained *
		\ if &l:number && empty(&buftype) |
			\ setlocal relativenumber |
		\ endif
augroup end

Tip: Setup with Lazy.nvim

I've struggled a little bit to get the plugin properly working with Lazy.nvim, but I do have a solution now !

Since the repo doesn't get much activity, I figured I'd take the initiative to post this issue as an example of working Lazy config for those who might need it and wanna avoid scratching their head for an hour fiddling around.

  {
    'kennykaye/vim-relativity',

    -- Only load the plugin when leaving a buffer
    event = 'BufLeave',

    -- Initial configuration
    -- Since this plugin uses Vim globals and will be loaded most of the times, it is ideal that
    -- this is done on opening NeoVim, to ensure everything is ready when the plugin's actually loaded.
    init = function()
      local ignored_fts = { -- Assigning directly to vim.g.relativity_filetype_ignore doesn't work. See `:h lua-vim-variables`
        -- Add your ignores here.
      }

      vim.o.number = true
      vim.o.relativenumber = true
      vim.g.relativity_filetype_ignore = ignored_fts
    end,

    config = function()
      -- Force the plugin to be activated when loaded
      vim.cmd.Relativity()
    end,
  }

Hope this can help some people!

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.