kennykaye / vim-relativity Goto Github PK
View Code? Open in Web Editor NEWToggle relative line numbers with ease.
Toggle relative line numbers with ease.
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?
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
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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.