update #16

Merged
jalil merged 2 commits from update into main 2024-07-02 09:52:58 +02:00
4 changed files with 227 additions and 103 deletions
Showing only changes of commit dc130e4723 - Show all commits

View file

@ -12,28 +12,38 @@ in {
group = "highlightOnYank";
event = "TextYankPost";
pattern = "*";
callback = mkRaw ''
function()
vim.highlight.on_yank {
higroup = (
vim.fn['hlexists'] 'HighlightedyankRegion' > 0 and 'HighlightedyankRegion' or 'IncSearch'
),
timeout = 200,
}
end
'';
callback =
mkRaw
/*
lua
*/
''
function()
vim.highlight.on_yank {
higroup = (
vim.fn['hlexists'] 'HighlightedyankRegion' > 0 and 'HighlightedyankRegion' or 'IncSearch'
),
timeout = 200,
}
end
'';
}
{
group = "restoreCursorPosition";
event = "BufReadPost";
pattern = "*";
callback = mkRaw ''
function()
if vim.fn.line '\'"' > 0 and vim.fn.line '\'"' <= vim.fn.line '$' then
vim.cmd [[execute "normal! g'\""]]
callback =
mkRaw
/*
lua
*/
''
function()
if vim.fn.line '\'"' > 0 and vim.fn.line '\'"' <= vim.fn.line '$' then
vim.cmd [[execute "normal! g'\""]]
end
end
end
'';
'';
}
{
group = "lspConfig";
@ -42,7 +52,11 @@ in {
callback = let
opts = "noremap = true, buffer = bufnr";
in
mkRaw ''
mkRaw
/*
lua
*/
''
function(opts)
local bufnr = opts.buf
local client = vim.lsp.get_client_by_id(opts.data.client_id)

View file

@ -51,99 +51,180 @@ in {
{
mode = "n";
key = "<leader>dj";
action = mkRaw "vim.diagnostic.goto_next";
action =
mkRaw
# lua
''
vim.diagnostic.goto_next
'';
options.desc = "Diagnostics next [J]";
}
{
mode = "n";
key = "<leader>dk";
action = mkRaw "vim.diagnostic.goto_prev";
action =
mkRaw
# lua
''
vim.diagnostic.goto_prev
'';
options.desc = "Diagnostics previous [K]";
}
{
mode = "n";
key = "<leader>xx";
action = mkRaw "require('trouble').toggle";
action =
mkRaw
# lua
''
require('trouble').toggle
'';
options.desc = "Toggle trouble";
}
{
mode = "n";
key = "<leader>xw";
action = mkRaw "function() require('trouble').toggle('workspace_diagnostics') end";
action =
mkRaw
# lua
''
function() require('trouble').toggle('workspace_diagnostics') end
'';
options.desc = "Toggle Workspace trouble";
}
{
mode = "n";
key = "<leader>xd";
action = mkRaw "function() require('trouble').toggle('document_diagnostics') end";
action =
mkRaw
# lua
''
function() require('trouble').toggle('document_diagnostics') end
'';
options.desc = "Toggle Document trouble";
}
{
mode = "n";
key = "<leader>xq";
action = mkRaw "function() require('trouble').toggle('quickfix') end";
action =
mkRaw
# lua
''
function() require('trouble').toggle('quickfix') end
'';
options.desc = "Toggle Quickfix trouble";
}
{
mode = "n";
key = "<leader>xl";
action = mkRaw "function() require('trouble').toggle('loclist') end";
action =
mkRaw
# lua
''
function() require('trouble').toggle('loclist') end
'';
options.desc = "Toggle Loclist trouble";
}
{
mode = "n";
key = "gR";
action = mkRaw "function() require('trouble').toggle('lsp_references') end";
action =
mkRaw
# lua
''
function() require('trouble').toggle('lsp_references') end
'';
options.desc = "Toggle lsp References trouble";
}
# Telescope
{
mode = "n";
key = "<leader>ff";
action = mkRaw "require('telescope.builtin').find_files";
action =
mkRaw
# lua
''
require('telescope.builtin').find_files
'';
options.desc = "Find Files";
}
{
mode = "n";
key = "<leader>fg";
action = mkRaw "require('telescope.builtin').live_grep";
action =
mkRaw
# lua
''
require('telescope.builtin').live_grep
'';
options.desc = "Find Grep";
}
{
mode = "n";
key = "<leader>fh";
action = mkRaw "require('telescope.builtin').help_tags";
action =
mkRaw
# lua
''
require('telescope.builtin').help_tags
'';
options.desc = "Find Help";
}
{
mode = "n";
key = "<leader>fb";
action = mkRaw "require('telescope.builtin').buffers";
action =
mkRaw
# lua
''
require('telescope.builtin').buffers
'';
options.desc = "Find Buffer";
}
{
mode = "n";
key = "<leader>fd";
action = mkRaw "require('telescope.builtin').diagnostics";
action =
mkRaw
# lua
''
require('telescope.builtin').diagnostics
'';
options.desc = "Find Diagnostics";
}
{
mode = "n";
key = "<leader>fq";
action = mkRaw "require('telescope.builtin').quickfix";
action =
mkRaw
# lua
''
require('telescope.builtin').quickfix
'';
options.desc = "Find Quickfix";
}
{
mode = "n";
key = "<leader>w";
action = mkRaw "require('conform').format";
action =
mkRaw
# lua
''
require('conform').format
'';
options.desc = "Format buffer";
}
# Nvim Silicon
{
mode = "v";
key = "<leader>sc";
action = mkRaw "require('nvim-silicon').clip";
action =
mkRaw
# lua
''
require('nvim-silicon').clip
'';
options.desc = "Snap Code (to clipboard)";
}
];

View file

@ -15,14 +15,28 @@ in {
enable = true;
cmdline = {
"/" = {
mapping = mkRaw "cmp.mapping.preset.cmdline()";
mapping =
mkRaw
/*
lua
*/
''
cmp.mapping.preset.cmdline()
'';
sources = [
{name = "rg";}
{name = "buffer";}
];
};
":" = {
mapping = mkRaw "cmp.mapping.preset.cmdline()";
mapping =
mkRaw
/*
lua
*/
''
cmp.mapping.preset.cmdline()
'';
sources = [
{name = "path";}
{name = "cmdline";}
@ -31,7 +45,13 @@ in {
};
settings = {
# Snippets
snippet.expand = "function(args) require('luasnip').lsp_expand(args.body) end";
snippet.expand =
/*
lua
*/
''
function(args) require('luasnip').lsp_expand(args.body) end
'';
# Completion Sources
sources = [
{
@ -83,42 +103,47 @@ in {
groupIndex = 1;
}
];
mapping = mkRaw ''
cmp.mapping.preset.insert({
["<C-n>"] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif require("luasnip").expand_or_jumpable() then
require("luasnip").expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end,
["<C-p>"] = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then
require("luasnip").jump(-1)
else
fallback()
end
end,
["<C-u>"] = cmp.mapping(function(fallback)
if require("luasnip").choice_active() then
require("luasnip").next_choice()
else
fallback()
end
end),
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete { },
["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm { select = true },
})
'';
mapping =
mkRaw
/*
lua
*/
''
cmp.mapping.preset.insert({
["<C-n>"] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif require("luasnip").expand_or_jumpable() then
require("luasnip").expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end,
["<C-p>"] = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then
require("luasnip").jump(-1)
else
fallback()
end
end,
["<C-u>"] = cmp.mapping(function(fallback)
if require("luasnip").choice_active() then
require("luasnip").next_choice()
else
fallback()
end
end),
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete { },
["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm { select = true },
})
'';
};
};
# FIXME: doesn't include formatters

View file

@ -55,37 +55,41 @@
pkgs.unstable.typos
pkgs.unstable.yamlfmt
];
extraConfigLuaPre = ''
-- Lua Pre Config
if vim.fn.has 'termguicolors' then
-- Enable RGB colors
vim.g.termguicolors = true
end
extraConfigLuaPre =
# lua
''
-- Lua Pre Config
if vim.fn.has 'termguicolors' then
-- Enable RGB colors
vim.g.termguicolors = true
end
-- Useful function
local has_words_before = function()
-- unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0
and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match '%s' == nil
end
-- END: Lua Pre Config
'';
extraConfigLua = ''
-- Lua Config
require("nvim-silicon").setup {
theme = "gruvbox-dark",
pad_horiz = 16,
pad_vert = 16,
-- Current buffer name
window_title = function()
return vim.fn.fnamemodify(
vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf()),
":t"
)
end,
}
-- END: Lua Config
'';
-- Useful function
local has_words_before = function()
-- unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0
and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match '%s' == nil
end
-- END: Lua Pre Config
'';
extraConfigLua =
# lua
''
-- Lua Config
require("nvim-silicon").setup {
theme = "gruvbox-dark",
pad_horiz = 16,
pad_vert = 16,
-- Current buffer name
window_title = function()
return vim.fn.fnamemodify(
vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf()),
":t"
)
end,
}
-- END: Lua Config
'';
};
}