1

Regenerate nvim config

This commit is contained in:
2024-06-02 03:29:20 +02:00
parent 75eea0c030
commit ef2e28883d
5576 changed files with 604886 additions and 503 deletions

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,19 @@
Copyright 2021 Pedro Alves
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,48 @@
# IntelliTab
IntelliTab is a small neovim plugin that fixes an annoying gripe I've had with
vim's tab completion implementation for ages: pressing tab on a blank line only
indents by a single space, instead of automatically indenting to your specified
location.
With IntelliTab, pressing Tab works like it does on editors such as VSCode, by
indenting to the same place `smartindent` would have indented it to if it were
a new line.
## Installation
Install using your favourite package manager:
```vim
Plug 'pta2002/intellitab.nvim'
```
Now, just rebind `<Tab>`:
```vim
inoremap <Tab> <CMD>lua require("intellitab").indent()<CR>
```
That's it!
### If you are using CoC
CoC wants to have its own binding for Tab, which means it won't be compatible with intellitab by default. A solution to this is to bind Tab to this instead:
```vim
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? <CMD>lua require("intellitab").indent()<CR> :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
```
### If you are using nvim-cmp
On the `nvim-cmp` setup, add this binding for tab:
```lua
['<Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_next_item() -- or whatever else you want nvim-cmp to do when you press tab
else
require("intellitab").indent()
end
end
```

View File

@ -0,0 +1,68 @@
local v = vim.api
local treesitter = require("nvim-treesitter")
local function get_line_indent(line, sw)
local indent = 0;
for c in line:gmatch("%s") do
if c == "\t" then
indent = indent + sw
else
indent = indent + 1
end
end
return indent
end
local function indent()
local cursor = v.nvim_win_get_cursor(0)
local line = v.nvim_buf_get_lines(0, cursor[1] - 1, cursor[1], false)[1]
local indentexpr = v.nvim_buf_get_option(0, "indentexpr")
local expand = v.nvim_buf_get_option(0, "expandtab")
local shiftwidth = v.nvim_eval("shiftwidth()")
local tab_char = v.nvim_replace_termcodes("<Tab>", true, true, true)
local indent_goal
if treesitter ~= nil and treesitter.get_indent ~= nil then
indent_goal = treesitter.get_indent(line)
end
if indent_goal == nil or indent_goal < 0 then
if indentexpr ~= "" then
indent_goal = v.nvim_eval(indentexpr)
elseif v.nvim_buf_get_option(0, "cindent") then
indent_goal = v.nvim_call_function("cindent", {cursor[1]})
else
indent_goal = v.nvim_call_function("indent", {cursor[1]})
end
end
if indent_goal == -1 and cursor[1] ~= 1 then
local prev_line = v.nvim_buf_get_lines(0, cursor[1] - 2, cursor[1] - 1, false)[1]
indent_goal = get_line_indent(prev_line, shiftwidth)
end
-- Reset the cursor, since the functions are free to move it
v.nvim_win_set_cursor(0, cursor)
if cursor[2] == 0 and line == "" and indent_goal ~= nil and indent_goal > 0 then
local i = 0
while i < indent_goal do
if expand then
v.nvim_feedkeys(" ", 'n', true)
i = i + 1
else
v.nvim_feedkeys(tab_char, 'n', true)
i = i + shiftwidth
end
end
print(i, indent_goal)
else
v.nvim_feedkeys(tab_char, 'n', true)
end
end
return {indent = indent}