GithubHelp home page GithubHelp logo

visual-whitespace.nvim's Introduction

🔎 visual-whitespace.nvim

Reveal whitespace characters in visual mode, similar to VSCode.

visual-ws

GIF: Highlighting in charwise-visual and linewise-visual

Installation and configuration

To install it with the default settings using Lazy:

  {
   'mcauley-penney/visual-whitespace.nvim',
    config = true
  }

visual-whitespace comes with the following default settings:

    opts = {
     highlight = { link = 'Visual' },
     space_char = '·',
     tab_char = '',
     nl_char = '',
     cr_char = ''
    },

Credit

visual-whitespace.nvim's People

Contributors

mcauley-penney avatar

Stargazers

Hanchin Hsieh avatar Alessandra Cristina avatar Rea avatar daru avatar  avatar darkdarcool avatar robin avatar Koen Verburg avatar Klas Segeljakt avatar  avatar 飞 avatar  avatar Max Jowett avatar O. Tadashi avatar Ignacy Buczek avatar Ama / Yuki Okugawa avatar Jimmy Jansen avatar Carlos Vigil-Vásquez avatar Dean Jackson avatar  avatar Andis Spriņķis avatar Stanimir Mladenov avatar Wasit Uzayer Faraizi avatar Ofir Gal avatar Vollow avatar Pavel Atanasov avatar Felix Zeller avatar Razy69 avatar Hisbaan Noorani avatar  avatar August Masquelier avatar Bruno Krugel avatar  avatar Jiahe Jiang avatar Rizky Ilham Pratama avatar Michael Wilgus avatar vadim avatar Socialhead  avatar Chaz avatar Nick Friday avatar  avatar Yuta Katayama avatar Marc Jakobi avatar Alex Fanat avatar Alejandro avatar Guozhu Liu avatar  avatar  avatar

Watchers

 avatar

visual-whitespace.nvim's Issues

[bug]: wrong background highlight

Description

The background on whitespaces keeps the highlight of the default background color, instead of the visual selection highlight.

Screenshots

example.mp4

Info

  • Windows 10 19045.4046
  • Windows Terminal 1.19.10573.0
  • NVIM v0.10.0-dev-ee276f8
  • visual-whitespace commit: 100c308

Error when using CRLF

When you have a file with CR + LF and you go to visual mode, the following error is thrown:

Error detected while processing ModeChanged Autocommands for "*:[vV]":
Error executing lua callback: ...im/lazy/visual-whitespace.nvim/lua/visual-whitespace.lua:104: Invalid 'col': out of range
stack traceback:
        [C]: in function 'nvim_buf_set_extmark'
        ...im/lazy/visual-whitespace.nvim/lua/visual-whitespace.lua:104: in function 'apply_marks'
        ...im/lazy/visual-whitespace.nvim/lua/visual-whitespace.lua:135: in function <...im/lazy/visual-whitespace.nvim/lua/visual-whitespace.lua:115>

Reproduction

  1. Open a file
  2. Enable :set fileformat=dos
  3. Enter some newlines
  4. Go to visual mode

Expected behavior

I think we should definitely show both charaacters (CR AND LF). We already got a character for LF. I'd recommend an arrow to the right for CR, something like:

or we could combine them into a single character like:

Exception when getting into visual mode

Error executing lua callback: ...im/lazy/visual-whitespace.nvim/lua/visual-whitespace.lua:60: attempt to call field 'unpack' (a nil value)                                                                                                                                        
stack traceback:                                                                                                                                                                                                                                                                  
        ...im/lazy/visual-whitespace.nvim/lua/visual-whitespace.lua:60: in function <...im/lazy/visual-whitespace.nvim/lua/visual-whitespace.lua:53>      

Both on 0.10 and 0.9.5

NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1703358377

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.9.5/share/nvim"

Run :checkhealth for more info

Show zero width characters

First of all: GREAT PLUGIN! I absolutely love it!

Second: I think it'd be extremely useful if the plugin could also show if there are zero width characters, such as:

yep, you cannot see this :)

While zero width characters are very rare, it will definitely save like hours of wasted time if one can find them very quickly.

perf: don't process the entire body of text for every movement

As of right now, the plugin gets the entire visual selection and parses it for whitespace on every CursorMoved. For example, if we have 100 lines selected and we move down one line, we get the entire 101 lines and parse it again, despite extmarks already existing. We do not need to parse the entire thing again.

We should be able to improve performance by only parsing the text between the last cursor position during visual mode and the current cursor position. For example, instead of parsing the entire 100 lines again just to add extmarks to one line, start at the last cursor position (row, col) and just parse up to the new row col.

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.