Compare commits
2 commits
012cbf5172
...
0972e97cfb
Author | SHA1 | Date | |
---|---|---|---|
0972e97cfb | |||
a61dc3486f |
5 changed files with 204 additions and 28 deletions
30
flake.lock
30
flake.lock
|
@ -9,11 +9,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1730056977,
|
"lastModified": 1730389505,
|
||||||
"narHash": "sha256-uiZX6iUpLAUiDqphhsoj59MK5SlPyWdCsVSCm37uiqs=",
|
"narHash": "sha256-gJwIy5cVBS+AzDm/dYQuHjrO6bIVHO8flC+bhBVk2Js=",
|
||||||
"owner": "Saghen",
|
"owner": "Saghen",
|
||||||
"repo": "blink.cmp",
|
"repo": "blink.cmp",
|
||||||
"rev": "1a55fd1e03193e10cb8bc866cc2bc47c9473061c",
|
"rev": "88f1c203465fa3d883f2309bc22412c90a9f6a08",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -31,11 +31,11 @@
|
||||||
"rust-analyzer-src": "rust-analyzer-src"
|
"rust-analyzer-src": "rust-analyzer-src"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1730010749,
|
"lastModified": 1730097176,
|
||||||
"narHash": "sha256-UBckyKItSD0z50+3YQOqfOuyvUI7UjPHiLbOPFUolqo=",
|
"narHash": "sha256-ufvRff76Y19mkRsmx+mAnxKE9A9VaNWC2mVY6TwumOw=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "fenix",
|
"repo": "fenix",
|
||||||
"rev": "5fa09829e74070c1e83b2aaa50b71bbc6da3f37c",
|
"rev": "482b57f3f27a9336e0fbc62fa99ee0f624ccf4d0",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -64,11 +64,11 @@
|
||||||
},
|
},
|
||||||
"nixCats": {
|
"nixCats": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1730063105,
|
"lastModified": 1730202844,
|
||||||
"narHash": "sha256-GWC9E6A+BOVgTSfZ2UyiHtU4Y438dYz4GpeW3b0rlU0=",
|
"narHash": "sha256-M4IBPRz/oVlgEERPi5s4Oe3MzoZOSjYXVgjCdsk+YSM=",
|
||||||
"owner": "BirdeeHub",
|
"owner": "BirdeeHub",
|
||||||
"repo": "nixCats-nvim",
|
"repo": "nixCats-nvim",
|
||||||
"rev": "765810b6c14fd581f906d1ac9b2514a6047242ff",
|
"rev": "553caacfe4728ea3ca3671b7edeb9f6fb6025dc7",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -79,11 +79,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1729980323,
|
"lastModified": 1730272153,
|
||||||
"narHash": "sha256-eWPRZAlhf446bKSmzw6x7RWEE4IuZgAp8NW3eXZwRAY=",
|
"narHash": "sha256-B5WRZYsRlJgwVHIV6DvidFN7VX7Fg9uuwkRW9Ha8z+w=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "86e78d3d2084ff87688da662cf78c2af085d8e73",
|
"rev": "2d2a9ddbe3f2c00747398f3dc9b05f7f2ebb0f53",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -149,11 +149,11 @@
|
||||||
"rust-analyzer-src": {
|
"rust-analyzer-src": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1729923686,
|
"lastModified": 1730028316,
|
||||||
"narHash": "sha256-Tc+5E/UmjpXlYGQQ6X2nGDv6J6VQgZ+pVOJLcNCIVQc=",
|
"narHash": "sha256-FsPsSjqnqMHBgDdM24DFLw4YOw0mFKYFJBcLaI6CvI8=",
|
||||||
"owner": "rust-lang",
|
"owner": "rust-lang",
|
||||||
"repo": "rust-analyzer",
|
"repo": "rust-analyzer",
|
||||||
"rev": "26d2fbaef2d68a2fccf55d725915188c2634439a",
|
"rev": "3b3a87fe9bd3f2a79942babc1d1e385b6805c384",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
6
init.lua
6
init.lua
|
@ -27,6 +27,10 @@ vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "␣" }
|
||||||
|
|
||||||
vim.opt.scrolloff = 10
|
vim.opt.scrolloff = 10
|
||||||
|
|
||||||
|
if os.getenv("TERM") == "xterm-kitty" then
|
||||||
|
require("scripts.chameleon").setup()
|
||||||
|
end
|
||||||
|
|
||||||
vim.cmd.colorscheme("rose-pine")
|
vim.cmd.colorscheme("rose-pine")
|
||||||
|
|
||||||
require("nvim-treesitter.configs").setup({
|
require("nvim-treesitter.configs").setup({
|
||||||
|
@ -69,3 +73,5 @@ vim.api.nvim_create_autocmd("TextYankPost", {
|
||||||
vim.highlight.on_yank({ higroup = "Visual", timeout = 300 })
|
vim.highlight.on_yank({ higroup = "Visual", timeout = 300 })
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- vim.keymap.set("i", "<Tab>", require("scripts.intellitab").indent)
|
||||||
|
|
|
@ -6,19 +6,30 @@ return {
|
||||||
-- for keymap, all values may be string | string[]
|
-- for keymap, all values may be string | string[]
|
||||||
-- use an empty table to disable a keymap
|
-- use an empty table to disable a keymap
|
||||||
keymap = {
|
keymap = {
|
||||||
show = "<C-space>",
|
["<C-space>"] = { "show", "show_documentation", "hide_documentation" },
|
||||||
hide = "<C-e>",
|
["<C-e>"] = { "hide" },
|
||||||
accept = "<Tab>",
|
|
||||||
select_prev = { "<Up>", "<C-p>" },
|
|
||||||
select_next = { "<Down>", "<C-n>" },
|
|
||||||
|
|
||||||
show_documentation = {},
|
["<Tab>"] = {
|
||||||
hide_documentation = {},
|
function(cmp)
|
||||||
scroll_documentation_up = "<C-b>",
|
if cmp.is_in_snippet() then
|
||||||
scroll_documentation_down = "<C-f>",
|
return cmp.accept()
|
||||||
|
else
|
||||||
|
return cmp.select_and_accept()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
"snippet_forward",
|
||||||
|
require("scripts.intellitab").indent,
|
||||||
|
"fallback",
|
||||||
|
},
|
||||||
|
["<S-Tab>"] = { "snippet_backward", "fallback" },
|
||||||
|
|
||||||
snippet_forward = "<Tab>",
|
["<Up>"] = { "select_prev", "fallback" },
|
||||||
snippet_backward = "<S-Tab>",
|
["<Down>"] = { "select_next", "fallback" },
|
||||||
|
["<C-p>"] = { "select_prev", "fallback" },
|
||||||
|
["<C-n>"] = { "select_next", "fallback" },
|
||||||
|
|
||||||
|
["<C-b>"] = { "scroll_documentation_up", "fallback" },
|
||||||
|
["<C-f>"] = { "scroll_documentation_down", "fallback" },
|
||||||
},
|
},
|
||||||
|
|
||||||
fuzzy = {
|
fuzzy = {
|
||||||
|
@ -27,8 +38,6 @@ return {
|
||||||
-- proximity bonus boosts the score of items with a value in the buffer
|
-- proximity bonus boosts the score of items with a value in the buffer
|
||||||
use_proximity = true,
|
use_proximity = true,
|
||||||
max_items = 200,
|
max_items = 200,
|
||||||
-- controls which sorts to use and in which order, these three are currently the only allowed options
|
|
||||||
sorts = { "label", "kind", "score" },
|
|
||||||
|
|
||||||
prebuiltBinaries = {
|
prebuiltBinaries = {
|
||||||
-- Whether or not to automatically download a prebuilt binary from github. If this is set to `false`
|
-- Whether or not to automatically download a prebuilt binary from github. If this is set to `false`
|
||||||
|
|
91
lua/scripts/chameleon.lua
Normal file
91
lua/scripts/chameleon.lua
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
-- MIT License
|
||||||
|
-- Copyright (c) 2023 Shaun
|
||||||
|
-- <https://github.com/shaun-mathew/Chameleon.nvim>
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
local fn = vim.fn
|
||||||
|
local api = vim.api
|
||||||
|
M.original_color = nil
|
||||||
|
|
||||||
|
local get_kitty_background = function()
|
||||||
|
if M.original_color == nil then
|
||||||
|
fn.jobstart({ "kitty", "@", "get-colors" }, {
|
||||||
|
on_stdout = function(_, d, _)
|
||||||
|
for _, result in ipairs(d) do
|
||||||
|
if string.match(result, "^background") then
|
||||||
|
local color = vim.split(result, "%s+")[2]
|
||||||
|
M.original_color = color
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
on_stderr = function(_, d, _)
|
||||||
|
if #d > 1 then
|
||||||
|
api.nvim_err_writeln("Chameleon.nvim: Error getting background. Make sure kitty remote control is turned on.")
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local change_background = function(color, sync)
|
||||||
|
local arg = 'background="' .. color .. '"'
|
||||||
|
local command = "kitty @ set-colors " .. arg
|
||||||
|
if not sync then
|
||||||
|
fn.jobstart(command, {
|
||||||
|
on_stderr = function(_, d, _)
|
||||||
|
if #d > 1 then
|
||||||
|
api.nvim_err_writeln(
|
||||||
|
"Chameleon.nvim: Error changing background. Make sure kitty remote control is turned on."
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
else
|
||||||
|
fn.system(command)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local setup_autocmds = function()
|
||||||
|
local autocmd = api.nvim_create_autocmd
|
||||||
|
local autogroup = api.nvim_create_augroup
|
||||||
|
local bg_change = autogroup("BackgroundChange", { clear = true })
|
||||||
|
|
||||||
|
autocmd({ "ColorScheme", "VimResume" }, {
|
||||||
|
pattern = "*",
|
||||||
|
callback = function()
|
||||||
|
local color = string.format("#%06X", vim.api.nvim_get_hl(0, { name = "Normal" }).bg)
|
||||||
|
change_background(color)
|
||||||
|
end,
|
||||||
|
group = bg_change,
|
||||||
|
})
|
||||||
|
|
||||||
|
autocmd("User", {
|
||||||
|
pattern = "NvChadThemeReload",
|
||||||
|
callback = function()
|
||||||
|
local color = string.format("#%06X", vim.api.nvim_get_hl(0, { name = "Normal" }).bg)
|
||||||
|
change_background(color)
|
||||||
|
end,
|
||||||
|
group = bg_change,
|
||||||
|
})
|
||||||
|
|
||||||
|
autocmd({ "VimLeavePre", "VimSuspend" }, {
|
||||||
|
callback = function()
|
||||||
|
if M.original_color ~= nil then
|
||||||
|
change_background(M.original_color, true)
|
||||||
|
-- Looks like it was silently fixed in NVIM 0.10. At least, I can't reproduce it anymore,
|
||||||
|
-- so for now disable it and see if anyone reports it again.
|
||||||
|
-- https://github.com/neovim/neovim/issues/21856
|
||||||
|
-- vim.cmd[[sleep 10m]]
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
group = autogroup("BackgroundRestore", { clear = true }),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
M.setup = function()
|
||||||
|
get_kitty_background()
|
||||||
|
setup_autocmds()
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
70
lua/scripts/intellitab.lua
Normal file
70
lua/scripts/intellitab.lua
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
-- Copyright 2021 Pedro Alves
|
||||||
|
|
||||||
|
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_get_option_value("indentexpr", { buf = 0 })
|
||||||
|
local expand = v.nvim_get_option_value("expandtab", { buf = 0 })
|
||||||
|
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_get_option_value("cindent", { buf = 0 }) 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 }
|
Loading…
Reference in a new issue