Giter Site home page Giter Site logo

modes.nvim's Introduction

ciao bella 🥰

modes.nvim's People

Contributors

adriankarlen avatar fitrh avatar hinell avatar miloas avatar mvllow avatar pricehiller avatar theblob42 avatar zahimeen 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  avatar  avatar  avatar  avatar  avatar

modes.nvim's Issues

Cursor not resetting to normal color

Hi there! Nice plugin!

I like the plugin, and It works pretty well, except for the fact that the cursor color is not resetting to the default when I come from another mode (visual or yank)

Any clues why this might be happening?

THanks!

Normal mode doesn't cover the signcolumn

Hi,

It seems the normal mode doesn't cover the signcolumn:

image

While the insert mode covers:
image

Do you have any idea how can I fix it?

Nvim: v0.9.1
Config: require('modes').setup()

Default normal mode CursorLine highlight not used

Hi. When starting Neovim my normal CursorLine highlights are used but after going into insert or visual mode and returning into normal mode or if I press escape after startup, staying in normal mode, the CursorLine highlight isn't properly applied.

On startup:
on-open

After entering insert/visual mode and returning to normal mode or pressing escape:
after

The result of me running :hi CursorLine shows me that its guibg value is Grey40, rather than the expected hex value. The highlight is defined by my colorscheme. I believe what I'm seeing is some sort of fallback highlight, which isn't based on the CursorLine highlight.

Thanks

Ignore_filetypes fails for mode changes inside ignored file

Description

I use neo-tree for my file browser and recently noticed that the fuzzy_search functionality in it, when combined with modes.nvim, leaves my cursorline invisible in insert mode. The cursorline works as expected when I disable modes.nvim. My config has neo-tree & the neo-tree-popup in the ignore_filetypes and I still am getting an invisible cursorline in the fuzzy_search mode.

My relevant modes config:

local modes = require('modes')
modes.setup({
    colors = {
        visual = '#F959FF',
    },
    ignore_filetypes = {
        'neo-tree',
        'neo-tree-popup',
        'TelescopePrompt',
    },
})

Here's a gif of the bug in action:
NTInvisible

Here's a gif with modes removed & neo-tree working as expected:
NTCorrect

Potential Fix

It's 100% related to this single nvim_autocmd, when I remove it, the plugin works mostly as expected:

vim.api.nvim_create_autocmd('WinLeave', {
	pattern = '*',
	callback = M.disable_managed_ui,
})

Solution One

A fix would be to change the pattern to only act on non-excluded filetypes, or just live with the fact that it's going to highlight the other windows. I'm not sure what a proper fix to this is, but it makes it very difficult to use neo-tree.

The reason this occurs is because when a switch happens to the fuzzy finder, it invokes a WinLeave event which this then catches and disables the cursorline for, disabling the ability to actively browse the file tree with the search window up.

When I state mostly, there is also an issue with the insertenter not respecting the filetype beneath because it's setting the cursorline green when really it's just a picker.

Solution Two

The other way to fix this is to remove this single section in disable_managed_ui:

if config.set_cursorline then
	vim.opt.cursorline = false
end

When the above is removed it also works mostly as expected.

A potential way to "fix" this is to make a note of it in the docs and mention setting the cursorline to false in the setup and setting vim.opt.cursorline = true elsewhere by the user.

Solution Three

In the modes.nvim setup function, passing set_cursorline = false then setting vim.opt.cursorline = true elsewhere in the configuration works, but exited windows still keep their cursorlines as modes is no longer managing the WinLeave events to disable the cursorline.

Add tests

Usually when something is added or changed in modes, I test locally and push up. Unfortunately, issues arise almost every update due to how different everyone's environment is.

I would love to learn more about tests in lua, but also am unaware of what exactly to test. PR's are welcome and appreciated 😌

Colorscheme is not always respected

After #36, Rosé Pine theme (dark variant) doesn't use the colorscheme's palette. Light mode works as expected.

Users can pin to tag = v0.2.0 if using a theme that is affected by this.

Add extend cursorline option

I'd like to add an option not extend the cursorline in certain modes behind the line number and sign column. Currently, the cursorline is not extended when in Normal mode but is extended for other modes. Perhaps after this option is added we may want to extend the cursorline in Normal mode when extend is true.

This plugins breaks "Styler" plugin

This plugins resets highlight when switching between windows, and that breaks Styler plugin https://github.com/folke/styler.nvim

CURSORMODE

Styler allows setting a colorscheme per filetype and even per buffer. It does so by making use of vim.api.nvim_set_hl, but modes resets that...

Could you make this plugin work with Styler ?

Cursorline changed to visual mode when using LSP goto functions

Let's say I'm in Normal mode, then when I use my hotkey to go definition of the symbol under my cursor (vim.lsp.buf.definition()), the cursor line changes to visual mode color even though it's normal mode. If I press ESC, then it goes back to normal mode color.

I think other LSP functions are also affected by this too.

Removed fallbacks with transparent background throws error

(See bottom for a quick fix to skip all the troubleshooting, not sure if it's the best fix, but it does work)

Troubleshooting

The commit, 4e69c2a and later commits, have lead to some issues for my configuration. When pointing packer directly at that commit and later commits I get the following error:

Error executing vim.schedule lua callback: ...im/site/pack/packer/start/modes.nvim/lua/modes/utils.lua:7: Expected lua string
stack traceback:
        [C]: in function 'nvim_get_color_by_name'
        ...im/site/pack/packer/start/modes.nvim/lua/modes/utils.lua:7: in function 'get_color'
        ...im/site/pack/packer/start/modes.nvim/lua/modes/utils.lua:29: in function 'blend'
        ...are/nvim/site/pack/packer/start/modes.nvim/lua/modes.lua:89: in function 'define'
        ...are/nvim/site/pack/packer/start/modes.nvim/lua/modes.lua:163: in function ''
        vim/_editor.lua: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

This occurs both on the latest stable neovim 0.7 & on the latest version of neovim 0.8 I have traced it down to the removal of a fallback for the normal group, adding back the fallback:

default_colors = {
    cursor_line = utils.get_bg('CursorLine'),
    cursor_line_nr = utils.get_bg('CursorLineNr'),
    mode_msg = utils.get_fg('ModeMsg'),
    normal = utils.get_bg('Normal', 'Normal'), -- <<<< here
    visual = utils.get_bg('Visual'),
}

clears this error for me.

This error popped up for me due to tokyonight.nvim's transparency options. When I comment out vim.g.tokyonight_transparent* the error referenced above goes away.

I suspect this is because the group gets set to none by the transparency options.

Taking a look at the blended colors groups, I noticed the bg color passed to blend is the default_colors.normal:

blended_colors = {
    copy = utils.blend(
        colors.copy,
        default_colors.normal,
        config.line_opacity.copy
    ),
    delete = utils.blend(
        colors.delete,
        default_colors.normal,
    -- snip

and the default_colors.normal is defined as

default_colors = {
    -- snip
    normal = utils.get_bg('Normal'),
    -- snip
}

and as best I can tell utils.get_bg is the core of the problem here.

M.get_bg = function(name, fallback)
	vim.notify(vim.inspect(name))
	local id = vim.api.nvim_get_hl_id_by_name(name)
	vim.notify(vim.inspect(id))
	if not id then
		return fallback
	end

	local background = vim.fn.synIDattr(id, 'bg')
	vim.notify(vim.inspect(background))
	if not background or background == '' then
		return fallback
	end

	return background
end

I've popped in a few notify statements, and here's the output for the normal group:

"Normal" <- The name passed in, seems fine
64 <- We get a valid ID back
"none" <- synIDattr fails to get the background :/

The issue is with vim.fn.synIDattr, it's giving back a none value and since no fallback is defined this entire function throws back a none value leading to the error up top.

Recreating the Error

To recreate the error you can pass in the following commands to neovim's command line (assuming you have a proper installation of modes):

  1. highlight Normal guibg=#00000
  2. lua require("modes").setup()

At this point above, no errors should be shown as the Normal bg group is not none.

  1. highlight Normal guibg=NONE
  2. lua require("modes").setup()

Now the error should appear.

Potential Fix

The most expedient way to resolve this is to add back the fallback for the normal group:

default_colors = {
    -- snip
    normal = utils.get_bg('Normal', 'Normal'),
    -- snip
}

Extend default config when passing partial options

It looks like passing partial options, eg. require('modes').setup({ colors = { copy = '#fa8072' } }) replaces the defaults. This would require passing no options or all options. Instead, user config should extend the default config.

Add `opacity` per mode

Set opacity of the cursor line based per mode. For example. to set a higher opacity in visual mode, and lower on other modes

Inconsistent `replace` mode color

Not sure if this is a bug or intended feature.
Yet if it is a feature, my question is why?

The color of the replace mode changes because of certain actions.
When you first enter replace, it is the color of normal mode.
After you enter yank mode, replace mode is now the color of yank mode.
After you enter delete mode, replace mode is now the color of delete.

Once it changes color to yank or delete, it will not change back to normal.
It is not affected by any other modes.

Recording2024-05-16191627-ezgif com-optimize

Split not opening within Telescope

I use telescope for switching and finding new files. With this plug-in installed, when I use :Telescope git_files and press <C-v> to open the selected file in a new vertical split it just doesn't.

Any idea what might cause this?

Thanks. I love this plug-in otherwise!

<C-c> causes error first time

I use <C-c> to go back to normal mode instead of Escape however the very first time I get this error:

Error executing  vim.on_key Lua callback: vim.lua:498: Error executing 'on_key' with ns_ids '5'
    Messages: Keyboard interrupt
stack traceback:
        [C]: in function 'error'
        vim.lua:498: in function <vim.lua:485>

The following patch fixes it however it breaks getting out of visual mode:

 	local on_key = vim.on_key or vim.register_keystroke_callback
 	on_key(function(key)
+		if key == util.get_termcode('<C-c>') then
+			return
+		end
+
 		local current_mode = vim.fn.mode()

possibility to integrated into other plugins?

first off- thank you for the plugin. really nicely made and exactly what i needed

now to my request

would it be possible to integrate other plugins into modes?

my specific issue is this:
i dont want to see a cursorline when im in normal mode but want to have it in insert mode.

at first i did that via auto commands which diabled the cursorline in normal mode but with your plugin i basically set the normal mode cursorline color to the background color.

this leads to the same issue i had when i did it via autocommands. i dont have a cursorline in nvim tree

so would it be possible that i set a specific cursorline color for nvim tree with your plugin?

Disable cursor color in insert mode

Hello !

I tried this plugin and it works well !

However, I would love the option to disable the custom cursor color in insert mode:

Capture d’écran 2022-02-14 à 18 01 48

I find it a little bit distracting.. Or maybe providing some options to customize it ?

recent update raised "expected table, got nil"

Hi,

Recently, after an update, I got this error:

Error detected while processing /home/mort/.config/nvim/init.lua:
E5113: Error while calling lua chunk: vim/shared.lua:0: after the second argument: expected table, got nil
stack traceback:
        [C]: in function 'error'
        vim/shared.lua: in function 'validate'
        vim/shared.lua: in function 'tbl_extend'
        /home/mort/.local/share/nvim/lazy/modes.nvim/lua/modes.lua:204: in function 'setup'
        /home/mort/.config/nvim/lua/theme.lua:120: in main chunk
        [C]: in function 'require'
        /home/mort/.config/nvim/init.lua:8: in main chunk

My config:

require('modes').setup()

Nvim version:

NVIM v0.9.4
Build type: Release
LuaJIT 2.1.1693350652

RFC: Handling line number highlights

as you can see in SS, changing mode also changes the line highlight. either there should be option to change line color or this plugin should not affect the line number
image

hex_to_rgb: invalid hex_str: normal

modes.nvim not working.

image

My config:

--- init.lua
vim.o.cursorline = true
-- modes.lua
require('modes').setup({
  colors = {
    copy = "#f5c359",
    delete = "#c75c6a",
    insert = "#78ccc5",
    visual = "#9745be",
  },
  line_opacity = 0.9
})
nvim --version
NVIM v0.6.0-dev+43-g02bf251bb
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

Great package!!!

Respect user's `guicursor` settings

users may have options like these in their config.

vim.opt.guicursor = "a:block" -- no more line or underline cursors, just block and all block

by design, modes.nvim overwrites any user defined settings as it applies its own stuff.
(e.g. i-ci-ve:ver25-ModesInsert)

"well zahimeen, why not just do the setting after setup?"
the problem there is that the settings made by modes.nvim don't care. either they hold higher presidency for a reason i dont know about, or it could be that the plugin constantly sets the guicursor values, and because its the latest setting, it holds higher value.

when set_cursor = false, everything works dandy cause the plugin doesnt have to redefine guicursor. but i want my block cursor and highlights :(

idk whats going on man but this plugin is sick much love <3

Highlights get overwritten all the time

Hey 👋🏾

in your README you advertise the option to define the highlights directly in a traditional way without hex color values in the setup function call. I like that. The problem: it doesn't work. I looked into the code and you actually redefine the highlights very time the mode changes. That makes it impossible to set them as user. I set the highlight, the plugins overwrites them.

A very simple but effective solution would be to add the default argument (:help :highlight-default).
But honestly I'm not sure if redefining the highlight over and over and over again makes actually sense. I mean why? Isn't it also performance threatening? Setting a highlight causes a couple of more actions by NeoVim in background.

Looking forward to discuss this. Maybe you actually have a very good reason to do it like that. I'm open to make a PR myself.

Select mode

It would be nice if this plugin would support select mode as well, as this is used by snippet engines like luasnip.

Allow disabling `Visual` highlight

Hello! I would like to remove the colored backgrounds from modes, especially in visual. Is it possible?

edit: to clarify, I just would like it to make it possible that modes.nvim does not alter colors for modes like v-snip, because it creates a conflict with the implementation of configurable themes in my setup

Incompatibility with neo-tree fuzzy search cursorline highlight

Hi,

Not sure if I should post it here or on neo-tree issues.

I thought, at least I report it, so it is known.

But when using neo-tree, it has a fuzzy search functionality (default / when tree is open), where it opens a one-line floating window at the bottom of the tree window to type the search term in, it will then filter the tree to only show matching files (in tree form). While the cursor is in the floating window, it should have a cursorline highlight in the tree showing the current selected tree node, which can be altered with <up> and <down>. This highlight should be shown while the cursor remains in insert mode in the floating window with the search term.

When modes.nvim is installed, the described cursorline highlight is not visible.

I tried add the filetype 'neo-tree' to the ignore_filetypes configuration option, but that didn't seem to help.

Respect line number formatting

Bold (and possibly italic or other styles) are removed when the line number highlight changes. The correct format is restored once modes is no longer changing the line number highlight.

Can be reproduced via:

:set termguicolors
:colorscheme lunaperche
:set number
:set cursorline

The active line number should be bold by default. Once using a modes modifier, e.g. y, the entire line changes to yellow and the line number is no longer bold.

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.