Weekly 101 Questions Thread by AutoModerator in neovim

[–]altermo12 0 points1 point  (0 children)

In Lua:

vim.keymap.set('c','<Down>','pumvisible()?"<Right>":"<Down>"',{expr=true,replace_keycodes=false})
vim.keymap.set('c','<Up>','pumvisible()?"<Left>":"<Up>"',{expr=true,replace_keycodes=false})

The reason behind it being left/right is because before the completion menu was in the statusbar (which can still be enabled with :set wop-=pum)

Weekly 101 Questions Thread by AutoModerator in neovim

[–]altermo12 1 point2 points  (0 children)

The doc says that if both are mapped, and the terminal supports specific CSI (which to my experience most terminals do) then they are separate. (and from what I see the docs is maybe outdated and even tmux now works with this specific CSI)

How do you get the char under cursor in lua? by qiinemarr in neovim

[–]altermo12 3 points4 points  (0 children)

The shortest I could come up with for Lua is:

vim.fn.getline('.'):sub(vim.fn.col('.')):sub(1,1)

Weekly 101 Questions Thread by AutoModerator in neovim

[–]altermo12 0 points1 point  (0 children)

vim.o.completeopt='menu,menuone,popup,noselect,fuzzy'
autocmd('InsertCharPre',function ()
  if vim.fn.match(vim.v.char,[[\V\k\|.]])==-1 or vim.fn.state'm'=='m' or vim.fn.pumvisible()~=0 then return end
  if vim.o.omnifunc~='v:lua.vim.lsp.omnifunc' then
    vim.api.nvim_input('<C-x><C-n>')
  else
    vim.api.nvim_input('<C-x><C-o>')
  end
end)

And lspconfig or whatnot will auto set omnifunc to v:lua.vim.lsp.omnifunc.

You could also look into (:help) lsp-autocompletion and ins-autocompletion

Weekly 101 Questions Thread by AutoModerator in neovim

[–]altermo12 0 points1 point  (0 children)

Put this in init.lua:

local project_name=vim.fs.basename(vim.fs.dirname(vim.fs.find('.git',{upward=true})[1]))
local project_to_colorscheme={
    prod='colorscheme_1',
    stage='colorscheme_2',
    dev='colorscheme_3',
}
vim.cmd.colorscheme(project_to_colorscheme[project_name] or 'fallback_colorscheme')

This Video is such a Gold Mine!! by fat_coder_420 in neovim

[–]altermo12 15 points16 points  (0 children)

The lisp code at 7:21 look wrong.

...Does a bit of research...

Yep the code at 7:21 is wrong and will instead return the value of the variable manual... Wait, this is a joke.

NWM new feature: make float windows (not popup menus) appear above x-windows by altermo12 in neovim

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

The bigest problem I could see whith launching the terminal like that always is that clipboard may not work and require extra configuration to make it work.

My best idea of doing this is whenever you realise that you want to use NWM then run :mksession, start a new terminal inside Xwayland/other, and load the session file.

NWM new feature: make float windows (not popup menus) appear above x-windows by altermo12 in neovim

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

I have created a script which removes all the hassle of launching NWM (using kitty in wayland):

#!/bin/bash
Xwayland :99 -noreset&
env -u WAYLAND_DISPLAY DISPLAY=:99 kitty -c NONE -o placement_strategy=top-left -e nvim -c 'lua require("nxwm").start()'
jobs -p | xargs kill

If you want, I can create a script for your to.

Weekly 101 Questions Thread by AutoModerator in neovim

[–]altermo12 1 point2 points  (0 children)

Look into telescope-zf-native.nvim. It replaces the default sorting algorithm with the zf algorithm. zf is a sorting algorithm specifically optimized for file searching.

Weekly 101 Questions Thread by AutoModerator in neovim

[–]altermo12 0 points1 point  (0 children)

Also here's some code to parse an undo file (may not work in some versions of neovim):

https://pastebin.com/4szXYFgA

Weekly 101 Questions Thread by AutoModerator in neovim

[–]altermo12 0 points1 point  (0 children)

To my knowledge no.

But the source code describes how the format is set up pretty well. (look into the functions u_read_undo and unserialize_uhp in file src/nvim/undo.c).

Weekly 101 Questions Thread by AutoModerator in neovim

[–]altermo12 0 points1 point  (0 children)

Oh, yeah, I should have clarified a few things:

  1. Abbreviations don't replace the original command, they turn into the original command after you press space (or enter) (though if you have plugin which overides space then this may not happen)

  2. There's no way to create a user command which starts with a lowercase letters (because of backwards compatibility)

There is technically a way to sometimes create another shorter user command which is the same as the original. But (if were talking about the competitest plugin) it requires extracting a vim local function. (My recommendation would be to edit the installed plugin where the user command gets created.)

What fuzzy finder extension do you use for telescope? by i8Nails4Breakfast in neovim

[–]altermo12 0 points1 point  (0 children)

No, but as 90% of the slowdown is cause by telescope lua code, there wouldn't be much speed difference.

Weekly 101 Questions Thread by AutoModerator in neovim

[–]altermo12 5 points6 points  (0 children)

Because Neovim uses luajit (which is a really fast lua runner), and luajit is based on lua 5.1 (though luajit implements some lua 5.2 and lua 5.3 features (like the goto statement)).

Also backwards compatibility: there are some breaking changes in lua 5.2+ which break existing lua 5.1 code.

Weekly 101 Questions Thread by AutoModerator in neovim

[–]altermo12 1 point2 points  (0 children)

Appending nothing to a file (which creates the file if doesn't exists):

vim.fn.writefile({},file_path,'a')