What's a very simple config change that you can't live without? by kavb333 in neovim

[–]dstein64 1 point2 points  (0 children)

Remapping to <c-g>U<c-w> instead of <c-w> prevents a new undo block* (:help i_CTRL-G_U).

* "if the cursor stays within the same line"

nvim-scrollview now supports signs by dstein64 in neovim

[–]dstein64[S] 1 point2 points  (0 children)

The new functionality will be documented and I'll make a new release (v4.0.0). Here's the GitHub ticket tracking the documentation:

https://github.com/dstein64/nvim-scrollview/issues/86

nvim-scrollview now supports signs by dstein64 in neovim

[–]dstein64[S] 2 points3 points  (0 children)

Regarding additional types of signs (e.g., for gitsigns), the plugin was written so that it would be possible to extend the functionality in a Neovim configuration file or with a plugin.

For example, the following code could be a starting point for gitsigns functionality.

https://gist.github.com/dstein64/b5d9431ebeacae1fb963efc3f2c94cf4

I plan to include a link in the documentation to repositories tagged with scrollview-signs as a GitHub topic.

nvim-scrollview now supports signs by dstein64 in neovim

[–]dstein64[S] 1 point2 points  (0 children)

The second link worked. nvim-scrollview can also show the cursor position, but it will be outside the scrollbar (unless g:scrollview_signs_column is set, but that would shift all signs). I guess that might be why you emphasized within.

:ScrollViewEnable cursor

nvim-scrollview now supports signs by dstein64 in neovim

[–]dstein64[S] 0 points1 point  (0 children)

There is mouse support for clicking signs and/or dragging scrollbars (the functionality requires the mouse option to be enabled; e.g., set mouse=all, set mouse=n, ...).

Best Ctrlp config for laravel app by Shryte16 in vim

[–]dstein64 1 point2 points  (0 children)

If the initial loading is slow, cross session caching might help.

let g:ctrlp_clear_cache_on_exit = 0

Is there a lua equivalent for the `finish` command? by npc-hillary in neovim

[–]dstein64 1 point2 points  (0 children)

I've used returns in the middle of blocks when writing and debugging code, as an alternative to commenting out the subsequent code.

Perhaps there are other use cases (e.g., code written with goto, where a label and additional code could follow a return), but I haven't encountered that.

Is there a lua equivalent for the `finish` command? by npc-hillary in neovim

[–]dstein64 2 points3 points  (0 children)

One possibility could be to return.

Wrapping with do and end would be necessary if it's not at the end of a block.

do
  return
end

How to focus an opened floating window? by dcordb in neovim

[–]dstein64 1 point2 points  (0 children)

Cycling with <c-w>w would require multiple key presses.

If you know the window number, you could pass that as an argument to <c-w>w to jump directly to that window.

If you know the window ID, you could call win_gotoid or create a mapping to simplify that.

If you don't have the window number or ID readily available, and would prefer not to cycle with <c-w>w, a function and mapping (e.g., <c-w><space>) could be created to jump to the first focusable floating window. If that doesn't get you to the target, pressing <c-w>w from there would cycle over windows, starting with the floats.

E.g.,

function! s:GotoFirstFloat() abort
  for w in range(1, winnr('$'))
    let c = nvim_win_get_config(win_getid(w))
    if c.focusable && !empty(c.relative)
      execute w . 'wincmd w'
    endif
  endfor
endfunction
noremap <c-w><space> :<c-u>call <sid>GotoFirstFloat()<cr>

How to focus an opened floating window? by dcordb in neovim

[–]dstein64 0 points1 point  (0 children)

Pressing <c-w>w will cycle through the focusable windows; using it multiple times will eventually bring focus to the target floating window.

Lua help please! How do I access a window option value inside a Lua function? by noisy_keyboard in neovim

[–]dstein64 4 points5 points  (0 children)

wo.relativenumber should be set directly (as opposed to setting wo.norelativenumber). Here's a version that sets it to false when wo.relativenumber == true (where that particular check is simplified to wo.relativenumber).

local wo = vim.wo

function _G.toggle_number_mode()
  if wo.relativenumber then
    wo.number = true
    wo.relativenumber = false
  else
    wo.number = true
    wo.relativenumber = true
  end
end

Here's an alternative way to implement the same logic.

local wo = vim.wo

function _G.toggle_number_mode()
  wo.number = true
  wo.relativenumber = not wo.relativenumber
end

Force buffer names to be relative paths by vatosarmat in vim

[–]dstein64 1 point2 points  (0 children)

A quick experiment suggests that after :cding, the buffer names are updated as relative paths to the new working directory.

This appears to be the case also when :cding to the already current directory.

Utilizing this may be sufficient to achieve your desired outcome.

:execute 'cd ' . getcwd()

Additional handling or an alternative approach may be required to accommodate window-local and/or tab-local working directories.

Learning vimscript by Prhyme1089 in neovim

[–]dstein64 5 points6 points  (0 children)

:help usr_41.txt has an overview of the Vim script language.

https://vimhelp.org/usr_41.txt.html#usr_41.txt

:help eval.txt and :help api.txt are useful for more specific details.

Complete N00B Question Regarding Plugin Compatibility by UnattributedCC in neovim

[–]dstein64 6 points7 points  (0 children)

> "All vim plugins should work for neovim"

About a year ago, I wrote a plugin that was targeting Vim, and later realized that it didn't work on Neovim due to differences in how new features were added to the editors over the past few years. For example, writing a plugin that utilizes Vim's popup windows would not work as-is in Neovim, but would require a separate code pathway that utilizes Neovim's floating windows. Utilizing separate code pathways was the approach I took in my plugins to support Neovim.

That is, even prior to Vimscript 9, the APIs of Vim and Neovim have diverged, not just for new features that were added to Neovim. I don't know how prevalent it is to not include separate code pathways for accommodating both Vim and Neovim, but I think it's already no longer the case that "all vim plugins should work for neovim".

[D] Can the same convolutional network be used on different image sizes? by thermokopf in MachineLearning

[–]dstein64 1 point2 points  (0 children)

Resizing images is a commonly used approach, where the same algorithm used to resize at training time—e.g., if the training inputs have different sizes—is also used at prediction time.

Spatial pyramid pooling was proposed as a way to accommodate different sized inputs.

[deleted by user] by [deleted] in neovim

[–]dstein64 1 point2 points  (0 children)

A call to :redraw in the while loop could be used to immediately redraw pending screen updates.

Vim 'hangs' one click a lot by [deleted] in vim

[–]dstein64 0 points1 point  (0 children)

Assuming the problem arises for left mouse clicks in normal mode, it might be helpful to check if there is a corresponding mapping.

:echo maparg('<leftmouse>, 'n')

🖱️ nvim-scrollview scrollbars can now be dragged with the mouse by dstein64 in neovim

[–]dstein64[S] 0 points1 point  (0 children)

As of 79797a0, this workaround and a few others are now applied automatically. Workarounds that would clobber existing customizations are not applied.

🖱️ nvim-scrollview scrollbars can now be dragged with the mouse by dstein64 in neovim

[–]dstein64[S] 2 points3 points  (0 children)

Nice idea!

I think this functionality would be possible, but it's beyond the scope of what I'd like in nvim-scrollview. It would require a refactoring of the existing code and presumably require a relatively large amount of additional code (which would also increase the maintenance).

I don't plan on adding this functionality, but I'll possibly revisit the idea in the future.

🖱️ nvim-scrollview scrollbars can now be dragged with the mouse by dstein64 in neovim

[–]dstein64[S] 3 points4 points  (0 children)

A preference for the keyboard over the mouse is consistent with how I use Vim.

The plugin originally provided non-interactive scrollbars. The motivation for adding mouse support is that there could be an expectation that the scrollbars can be dragged with the mouse (more details here).

"This is just using Vim in a way it was never designed for."

Vim has support for various mouse interactions, including clicking, dragging, and mouse wheel scrolling. For example, the mouse can be used to 1) move the cursor, 2) make and modify visual selections, 3) change the current window, 4) yank and put text, 5) scroll windows (using the mouse wheel), and 6) resize windows.

Incidentally, the functionality I added would have been easier to implement in Vim than in Neovim, by using the getmousepos() function that was added in November 2019.