wip
This commit is contained in:
parent
c72d894bbd
commit
0b833d555c
13 changed files with 719 additions and 46 deletions
15
README.md
15
README.md
|
@ -3,7 +3,7 @@
|
|||
## Running
|
||||
|
||||
### With Nix (Recommended)
|
||||
|
||||
nix run "."
|
||||
|
||||
### On any system
|
||||
|
||||
|
@ -18,3 +18,16 @@ Install neovim config (backup old version first if present):
|
|||
git clone https://github.com/RingOfStorms/nvim ~/.config/nvim
|
||||
nvim --headless "+Lazy! sync" +qa
|
||||
```
|
||||
|
||||
|
||||
|
||||
## NOTES/TODOS
|
||||
|
||||
|
||||
- Checkout cargo-bloat, cargo-cache, cargo-outdated - memcache sccache
|
||||
- For scratches, just make an input box for custom extension rather than predefined list
|
||||
- for find files, ignore git, capital F for find all
|
||||
|
||||
- plugins to check out:
|
||||
- https://github.com/declancm/cinnamon.nvim
|
||||
- https://github.com/folke/noice.nvim
|
||||
|
|
104
flake.nix
104
flake.nix
|
@ -4,10 +4,8 @@
|
|||
inputs = {
|
||||
nixpkgs.url = "nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
# inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
|
||||
# All my neovim plguins managed by flake. Lazy will only be used for loading/configuration with direct dir links to these.
|
||||
"nvim_plugin-folke/lazy.nvim" = {
|
||||
url = "github:folke/lazy.nvim";
|
||||
flake = false;
|
||||
|
@ -25,6 +23,7 @@
|
|||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
lib = nixpkgs.lib;
|
||||
|
||||
# This will look at all inputs and grab any prefixed with `nvim_plugin-`
|
||||
nvimPluginPaths = "NVIM_PLUGIN_PATHS=" + lib.generators.toLua
|
||||
{
|
||||
multiline = false;
|
||||
|
@ -42,10 +41,17 @@
|
|||
(builtins.attrNames inputs))
|
||||
)
|
||||
;
|
||||
nvimConfigStorePath = ''NVIM_CONFIG_STORE_PATH="${./.}"'';
|
||||
|
||||
runtimeDependencies = with pkgs; [
|
||||
ripgrep
|
||||
curl
|
||||
cowsay
|
||||
nodePackages.cspell
|
||||
];
|
||||
|
||||
treesitterParsers = builtins.attrValues pkgs.vimPlugins.nvim-treesitter.grammarPlugins;
|
||||
|
||||
# https://zimbatm.com/notes/1000-instances-of-nixpkgs
|
||||
# Read article for why we don't do the below version
|
||||
# pkgs = import nixpkgs {
|
||||
|
@ -69,31 +75,75 @@
|
|||
{
|
||||
packages = {
|
||||
default = self.packages.${system}.neovim;
|
||||
neovim = pkgs.wrapNeovimUnstable pkgs.neovim-unwrapped (
|
||||
pkgs.neovimUtils.makeNeovimConfig
|
||||
{
|
||||
customRC = ''
|
||||
lua print("HELLO WORLD 123! TEST")
|
||||
lua ${nvimPluginPaths}
|
||||
lua package.path =";${./.}/lua/?.lua" .. package.path
|
||||
luafile ${./.}/init.lua
|
||||
'';
|
||||
# set runtimepath^=${builtins.concatStringsSep "," treesitterParsers}
|
||||
}
|
||||
// {
|
||||
wrapperArgs = [
|
||||
# Add runtime dependencies to neovim path
|
||||
"--prefix"
|
||||
"PATH"
|
||||
":"
|
||||
"${lib.makeBinPath runtimeDependencies}"
|
||||
# Use custom XDG_CONFIG_HOME so it doesn't use the user's real one
|
||||
"--set"
|
||||
"XDG_CONFIG_HOME"
|
||||
"~/.config/ringofstorms_neovim"
|
||||
];
|
||||
}
|
||||
);
|
||||
neovim =
|
||||
(pkgs.wrapNeovimUnstable
|
||||
pkgs.neovim-unwrapped
|
||||
(pkgs.neovimUtils.makeNeovimConfig
|
||||
{
|
||||
withPython3 = false;
|
||||
customRC = ''
|
||||
lua ${nvimPluginPaths}
|
||||
lua ${nvimConfigStorePath}
|
||||
luafile ${./.}/init.lua
|
||||
set runtimepath^=${builtins.concatStringsSep "," treesitterParsers}
|
||||
'';
|
||||
# lua package.path = package.path .. ";${./.}/lua/?.lua"
|
||||
# lua print("HELLO WORLD 123! TEST")
|
||||
# lua print("${./.}")
|
||||
# -- lua package.runtimepath = "${./.}`
|
||||
# plugins = [
|
||||
# pkgs.vimPlugins.nvim-treesitter.withAllGrammars
|
||||
# ];
|
||||
# customRC = import ./lua { inherit lib self; };
|
||||
# wrapperArgs = [
|
||||
# # Add runtime dependencies to neovim path
|
||||
# "--prefix"
|
||||
# "PATH"
|
||||
# ":"
|
||||
# "${lib.makeBinPath runtimeDependencies}"
|
||||
# # Set the LAZY env path to the nix store
|
||||
# "--set"
|
||||
# "LAZY"
|
||||
# "${inputs.nvim_plugin-folke/lazy.nvim}"
|
||||
# # Use custom XDG_CONFIG_HOME so it doesn't use the user's real one
|
||||
# # TODO do I need to set all the XDG_ env vars? - or should I remove this entirely?
|
||||
# "--set"
|
||||
# "XDG_CONFIG_HOME"
|
||||
# "${./.}"
|
||||
# ];
|
||||
}
|
||||
|
||||
)
|
||||
).overrideAttrs
|
||||
(old: {
|
||||
generatedWrapperArgs = old.generatedWrapperArgs or [ ] ++ [
|
||||
# Add runtime dependencies to neovim path
|
||||
"--prefix"
|
||||
"PATH"
|
||||
":"
|
||||
"${lib.makeBinPath runtimeDependencies}"
|
||||
# Set the LAZY env path to the nix store
|
||||
"--set"
|
||||
"LAZY"
|
||||
"${inputs."nvim_plugin-folke/lazy.nvim"}"
|
||||
# Use custom XDG_CONFIG_HOME so it doesn't use the user's real one
|
||||
# TODO do I need to set all the XDG_ env vars? - or should I remove this entirely?
|
||||
"--set"
|
||||
"XDG_CONFIG_HOME"
|
||||
"~/.config/nvim_flaked"
|
||||
"--set"
|
||||
"XDG_DATA_HOME"
|
||||
"~/.local/share/nvim_flaked"
|
||||
"--set"
|
||||
"XDG_RUNTIME_DIR"
|
||||
"/tmp/nvim.user/nvim_flaked/xxx"
|
||||
"--set"
|
||||
"XDG_STATE_HOME"
|
||||
"~/.local/state/nvim_flaked"
|
||||
];
|
||||
})
|
||||
|
||||
;
|
||||
# neovim = pkgs.stdenv.mkDerivation {
|
||||
# name = "nvim";
|
||||
# nativeBuildInputs = with pkgs; [ makeWrapper rsync ];
|
||||
|
|
68
init.lua
68
init.lua
|
@ -1,4 +1,68 @@
|
|||
NVIM_PLUGIN_PATHS = NVIM_PLUGIN_PATHS or {}
|
||||
|
||||
if NVIM_CONFIG_STORE_PATH then
|
||||
-- Function to add subdirectories to package.path
|
||||
local function add_lua_subdirs_to_path(base_dir)
|
||||
local scan_dir
|
||||
scan_dir = function(dir)
|
||||
package.path = package.path .. ";" .. dir .. "?.lua"
|
||||
package.path = package.path .. ";" .. dir .. "?/init.lua"
|
||||
local paths = vim.fn.globpath(dir, '*/', 0, 1)
|
||||
for _, subdir in ipairs(paths) do
|
||||
scan_dir(subdir) -- Recursively add subdirectories
|
||||
end
|
||||
end
|
||||
scan_dir(base_dir)
|
||||
end
|
||||
-- Call the function with the base directory of your Lua modules
|
||||
add_lua_subdirs_to_path(NVIM_CONFIG_STORE_PATH .. "/lua/")
|
||||
end
|
||||
|
||||
require("options")
|
||||
require("keymaps")
|
||||
|
||||
print("NIX FLAKE NVIM: nvim packages " .. vim.inspect(NVIM_PLUGIN_PATHS))
|
||||
|
||||
-- When using nix, it will set lazy via LAZY env variable.
|
||||
local lazypath = vim.env.LAZY or (vim.fn.stdpath("data") .. "/lazy/lazy.nvim")
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
if vim.env.LAZY then
|
||||
error("LAZY environment variable provided but it does not exist at path: " .. vim.env.LAZY)
|
||||
return
|
||||
end
|
||||
-- For non nix systems, pull lazy stable to the normal XDG config path
|
||||
local output = vim.fn.system({
|
||||
"git",
|
||||
"clone",
|
||||
"--filter=blob:none",
|
||||
"https://github.com/folke/lazy.nvim.git",
|
||||
"--branch=stable", -- latest stable release
|
||||
lazypath,
|
||||
})
|
||||
if vim.api.nvim_get_vvar("shell_error") ~= 0 then
|
||||
error("Error cloning lazy.nvim repository...\n\n" .. output)
|
||||
end
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
print("TEST")
|
||||
local asd = require("catppuccin")
|
||||
print("TEST2 " .. vim.inspect(asd))
|
||||
|
||||
-- Setup lazy
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
{ import = "plugins" },
|
||||
},
|
||||
change_detection = {
|
||||
enabled = false,
|
||||
},
|
||||
defaults = {
|
||||
-- lazy = true
|
||||
},
|
||||
-- install = {
|
||||
-- colorscheme = { "catppuccin" },
|
||||
-- }
|
||||
})
|
||||
|
||||
-- vim.cmd("colorscheme catppuccin")
|
||||
require("tools")
|
||||
require("autocommands")
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
--function isEmpty()
|
||||
--return vim.api.nvim_buf_get_name(0) == ""
|
||||
--or vim.fn.filereadable(vim.api.nvim_buf_get_name(0)) == 0
|
||||
--or vim.fn.line("$") == 1 and vim.fn.col("$") == 1
|
||||
--end
|
||||
|
||||
--vim.api.nvim_create_autocmd({ "VimEnter" }, {
|
||||
-- callback = function()
|
||||
-- if isEmpty() then
|
||||
-- require('telescope.builtin').find_files()
|
||||
-- end
|
||||
-- end
|
||||
--})
|
||||
|
||||
vim.api.nvim_create_autocmd("BufRead", {
|
||||
pattern = ".env*",
|
||||
command = "set filetype=sh",
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("BufRead", {
|
||||
pattern = ".*rc",
|
||||
command = "set filetype=sh",
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("BufRead", {
|
||||
pattern = "Dockerfile.*",
|
||||
command = "set filetype=dockerfile",
|
||||
})
|
||||
|
||||
if vim.fn.exists(":CccHighlighterEnable") ~= 0 then
|
||||
vim.api.nvim_create_autocmd("BufRead", {
|
||||
callback = function()
|
||||
vim.cmd.CccHighlighterEnable()
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- AUto exit insert mode whenever we switch screens
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
|
||||
callback = function()
|
||||
if vim.bo.filetype ~= "TelescopePrompt" and vim.bo.filetype ~= nil and vim.bo.filetype ~= "" then
|
||||
vim.api.nvim_command("stopinsert")
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufEnter" }, {
|
||||
pattern = "*.http",
|
||||
command = "set filetype=http",
|
||||
})
|
||||
|
||||
--vim.api.nvim_create_autocmd('BufEnter', {
|
||||
-- callback = function ()
|
||||
-- local ts_avail, parsers = pcall(require, "nvim-treesitter.parsers")
|
||||
-- if ts_avail and parsers.has_parser() then vim.cmd.TSBufEnable "highlight" end
|
||||
-- end,
|
||||
--})
|
||||
|
||||
vim.api.nvim_create_autocmd("VimLeavePre", {
|
||||
callback = function()
|
||||
vim.cmd("NvimTreeClose")
|
||||
-- Close all buffers with the 'httpResult' type
|
||||
local buffers = vim.api.nvim_list_bufs()
|
||||
for _, bufnr in ipairs(buffers) do
|
||||
if vim.bo[bufnr].filetype == "httpResult" then
|
||||
vim.api.nvim_buf_delete(bufnr, { force = true })
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
177
lua/keymaps.lua
177
lua/keymaps.lua
|
@ -0,0 +1,177 @@
|
|||
-- Remap space as leader key
|
||||
vim.keymap.set("", "<Space>", "<Nop>", { silent = true })
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = " "
|
||||
|
||||
-- Modes test
|
||||
-- normal_mode = "n",
|
||||
-- insert_mode = "i",
|
||||
-- visual_mode = "v",
|
||||
-- visual_block_mode = "x",
|
||||
-- term_mode = "t",
|
||||
-- command_mode = "c",
|
||||
|
||||
local nvx = { "n", "v", "x" }
|
||||
|
||||
require("util").keymaps({
|
||||
-- =============
|
||||
-- n/v/x (normal + visual modes)
|
||||
-- =============
|
||||
{ ";", ":", desc = "No shift to enter command mode with semicolon. Alias ; to :", mode = nvx },
|
||||
{ "<leader>a", "<esc>ggVG", desc = "Select all", mode = nvx },
|
||||
{ "<leader>w", "<cmd>w<cr>", desc = "Save", mode = nvx },
|
||||
{
|
||||
"<leader>q",
|
||||
function()
|
||||
-- Use to have this which always closed and quit ont he last screen: "<cmd>confirm q<cr>"
|
||||
-- Instead I want this behavior:
|
||||
-- if only 1 screen is open then close all buffers, resulting in a blank unnamed buffer window similar to fresh session
|
||||
-- else if more than 1 screen, confirm q to close that screen
|
||||
-- Check the number of screens
|
||||
if vim.fn.winnr("$") == 1 then
|
||||
-- If only 1 screen is open then close all buffers, resulting in a blank unnamed buffer window similar to fresh session
|
||||
vim.cmd("bufdo bd")
|
||||
vim.cmd("SessionDelete")
|
||||
else
|
||||
-- If more than 1 screen, confirm q to close that screen
|
||||
vim.cmd("confirm q")
|
||||
end
|
||||
end,
|
||||
desc = "Quit",
|
||||
mode = nvx,
|
||||
},
|
||||
{ "Q", "<cmd>qa<CR>", desc = "Quit all", mode = nvx },
|
||||
-- { "Q", "<cmd>qa<CR>", desc = "Quit all", mode = nvx },
|
||||
{ "<leader>Q", "<nop>", mode = nvx }, -- don't do normal Q quit
|
||||
{
|
||||
"<leader>QQ",
|
||||
"<cmd>NvimTreeClose<cr><cmd>SessionDelete<cr><cmd>qa<CR>",
|
||||
desc = "Quit all, no session saved",
|
||||
mode = nvx,
|
||||
},
|
||||
{ "<leader>y", '"+y', desc = "Copy to system clipboard", mode = nvx },
|
||||
{ "<leader>p", '"+p', desc = "Paste from system clipboard", mode = nvx },
|
||||
{ "<leader>bq", "<cmd>bp|bd #<cr>", desc = "Close current buffer only", mode = nvx },
|
||||
{ "<leader>bn", "<cmd>enew<cr>", desc = "Open a new buffer in current screen", mode = nvx },
|
||||
{ "<leader>bt", "<cmd>terminal<cr>i", desc = "Open a terminal in current screen", mode = nvx },
|
||||
{ "<leader>tn", "<cmd>tabnew<cr>", desc = "Create new tab", mode = nvx },
|
||||
{ "<leader>tq", "<cmd>tabclose<cr>", desc = "Close current tab", mode = nvx },
|
||||
|
||||
{
|
||||
"<leader>S",
|
||||
"<cmd>set equalalways<cr><cmd>set noequalalways<cr>",
|
||||
desc = "Equalize/resize screens evenly",
|
||||
mode = nvx,
|
||||
},
|
||||
{ "<C-h>", "<C-W>h", desc = "Move window left current", mode = nvx },
|
||||
{ "<C-j>", "<C-W>j", desc = "Move window below current", mode = nvx },
|
||||
{ "<C-k>", "<C-W>k", desc = "Move window above current", mode = nvx },
|
||||
{ "<C-l>", "<C-W>l", desc = "Move window right current", mode = nvx },
|
||||
{ "B", "<cmd>b#<cr>", desc = "Switch to last buffer", mode = nvx },
|
||||
{
|
||||
"<leader>l<leader>",
|
||||
function()
|
||||
-- vim.cmd "SqlxFormat"
|
||||
vim.lsp.buf.format()
|
||||
end,
|
||||
desc = "Reformat file",
|
||||
mode = nvx,
|
||||
},
|
||||
{
|
||||
"<leader>ls<leader>",
|
||||
"<cmd>SqlxFormat<cr>",
|
||||
desc = "Format sqlx queries in rust raw string literals.",
|
||||
mode = nvx,
|
||||
},
|
||||
{
|
||||
"<leader>ld",
|
||||
function()
|
||||
vim.diagnostic.open_float()
|
||||
end,
|
||||
desc = "Show diagnostic message",
|
||||
mode = nvx,
|
||||
},
|
||||
{
|
||||
"<leader>ll",
|
||||
function()
|
||||
vim.diagnostic.setloclist()
|
||||
end,
|
||||
desc = "Show diagnostic list",
|
||||
mode = nvx,
|
||||
},
|
||||
|
||||
-- =============
|
||||
-- normal mode
|
||||
-- =============
|
||||
-- { "", "", desc = "" },
|
||||
{ "H", "<cmd>tabprevious<cr>", desc = "Move to previous tab" },
|
||||
{ "L", "<cmd>tabnext<cr>", desc = "Move to next tab" },
|
||||
{ "|", "<cmd>vsplit<cr>", desc = "Vertical Split" },
|
||||
{ "\\", "<cmd>split<cr>", desc = "Horizontal Split" },
|
||||
{ "n", "nzzzv", desc = "Next search result centered" },
|
||||
{ "N", "Nzzzv", desc = "Previous search result centered" },
|
||||
{ "<esc>", ":noh<CR><esc>", desc = "Clear search on escape" },
|
||||
{ "<return>", ":noh<CR><return>", desc = "Clear search on return" },
|
||||
{ "<C-d>", "<C-d>zz", desc = "Vertical half page down and center cursor" },
|
||||
{ "<C-u>", "<C-u>zz", desc = "Vertical half page up and center cursor" },
|
||||
{ "J", "mzJ`z", desc = "Move line below onto this line" },
|
||||
{ "<S-Tab>", "<C-o>", desc = "Go back <C-o>" },
|
||||
{
|
||||
"]d",
|
||||
function()
|
||||
vim.diagnostic.goto_next()
|
||||
end,
|
||||
desc = "Go to next diagnostic",
|
||||
},
|
||||
{
|
||||
"[d",
|
||||
function()
|
||||
vim.diagnostic.goto_prev()
|
||||
end,
|
||||
desc = "Go to next diagnostic",
|
||||
},
|
||||
|
||||
-- =============
|
||||
-- VISUAL
|
||||
-- =============
|
||||
{
|
||||
"J",
|
||||
":m '>+1<CR>gv=gv",
|
||||
desc = "Visually move block down",
|
||||
mode = "v",
|
||||
},
|
||||
{
|
||||
"K",
|
||||
":m '<-2<CR>gv=gv",
|
||||
desc = "Visually move block up",
|
||||
mode = "v",
|
||||
},
|
||||
{
|
||||
"<leader>,uu",
|
||||
'd:let @u = trim(tolower(system("uuidgen")))<cr>i<C-r>u',
|
||||
desc = "Generate and replace UUID",
|
||||
mode = "v",
|
||||
},
|
||||
{ "p", '"_dP', desc = "Paste without yanking replaced content", mode = "v" },
|
||||
{ "<C-r>", '"hy:%s/<C-r>h//g<left><left>', desc = "Replace current selection", mode = "v" },
|
||||
{ ">", "> gv", desc = "Indent selection", mode = "v" },
|
||||
{ "<", "< gv", desc = "Outdent selection", mode = "v" },
|
||||
|
||||
-- =============
|
||||
-- insert / command
|
||||
-- =============
|
||||
{ "<C-k>", "<Up>", desc = "Up", mode = { "i", "c" } },
|
||||
{ "<C-j>", "<Down>", desc = "Down", mode = { "i", "c" } },
|
||||
{ "<C-h>", "<Left>", desc = "Left", mode = { "i", "c" } },
|
||||
{ "<C-l>", "<Right>", desc = "Right", mode = { "i", "c" } },
|
||||
{ "<C-4>", "<End>", desc = "End", mode = { "i", "c" } },
|
||||
{ "<C-6>", "<Home>", desc = "Home", mode = { "i", "c" } },
|
||||
-- =============
|
||||
-- command
|
||||
-- =============
|
||||
-- { mode = "c" }
|
||||
-- =============
|
||||
-- terminal
|
||||
-- =============
|
||||
{ "<Esc>", "<C-\\><C-n>", desc = "Escape the terminal", mode = "t" },
|
||||
})
|
|
@ -1,3 +1,6 @@
|
|||
-- allow use of system keyboard
|
||||
-- vim.opt.clipboard = "unnamedplus"
|
||||
|
||||
-- global status line
|
||||
vim.opt.laststatus = 3
|
||||
|
||||
|
@ -56,19 +59,3 @@ vim.opt.diffopt:append("linematch:20")
|
|||
|
||||
-- enable colors for opacity changes
|
||||
vim.o.termguicolors = true
|
||||
|
||||
function dump(o)
|
||||
if type(o) == 'table' then
|
||||
local s = '{ '
|
||||
for k,v in pairs(o) do
|
||||
if type(k) ~= 'number' then k = '"'..k..'"' end
|
||||
s = s .. '['..k..'] = ' .. dump(v) .. ','
|
||||
end
|
||||
return s .. '} '
|
||||
else
|
||||
return tostring(o)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
print("NIX FLAKE NVIM: nvim package count " .. dump(NVIM_PLUGIN_PATHS))
|
||||
|
|
27
lua/plugins/catppuccin.lua
Normal file
27
lua/plugins/catppuccin.lua
Normal file
|
@ -0,0 +1,27 @@
|
|||
return {
|
||||
"catppuccin/nvim",
|
||||
dir = NVIM_PLUGIN_PATHS["nvim_plugin-catppuccin/nvim"] or nil,
|
||||
opts = {
|
||||
flavour = "mocha", -- latte, frappe, macchiato, mocha (default)
|
||||
color_overrides = {
|
||||
mocha = {
|
||||
-- My coal variant: https://gist.github.com/RingOfStorms/b2ff0c4e37f5be9f985c72c3ec9a3e62
|
||||
text = "#e0e0e0",
|
||||
subtext1 = "#cccccc",
|
||||
subtext0 = "#b8b8b8",
|
||||
overlay2 = "#a3a3a3",
|
||||
overlay1 = "#8c8c8c",
|
||||
overlay0 = "#787878",
|
||||
surface2 = "#636363",
|
||||
surface1 = "#4f4f4f",
|
||||
surface0 = "#3b3b3b",
|
||||
base = "#262626",
|
||||
mantle = "#1f1f1f",
|
||||
crust = "#171717",
|
||||
},
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("catppuccin").setup(opts)
|
||||
end,
|
||||
}
|
13
lua/tools/init.lua
Normal file
13
lua/tools/init.lua
Normal file
|
@ -0,0 +1,13 @@
|
|||
-- Require all files in this tools dir, minus this init.lua file
|
||||
function script_path()
|
||||
return debug.getinfo(2, "S").source:sub(2):match("(.*/)")
|
||||
end
|
||||
-- Extract the directory name from the script path
|
||||
local directory_name = script_path():match(".*/(.*)/")
|
||||
for _, file in ipairs(vim.fn.readdir(script_path(), [[v:val =~ '\.lua$']])) do
|
||||
if file ~= "init.lua" then
|
||||
local neighbor = string.sub(file, 0, -5)
|
||||
require(directory_name .. "." .. neighbor)
|
||||
end
|
||||
end
|
||||
|
20
lua/tools/quick-fix.lua
Normal file
20
lua/tools/quick-fix.lua
Normal file
|
@ -0,0 +1,20 @@
|
|||
-- Function to remove item from quickfix list
|
||||
function RemoveQFItem()
|
||||
local curqfidx = vim.fn.line(".") - 1
|
||||
local qfall = vim.fn.getqflist()
|
||||
table.remove(qfall, curqfidx + 1) -- Lua is 1-indexed
|
||||
vim.fn.setqflist(qfall, "r")
|
||||
vim.cmd(curqfidx .. "cfirst")
|
||||
vim.cmd("copen")
|
||||
end
|
||||
|
||||
-- Command to call the function
|
||||
vim.api.nvim_create_user_command("RemoveQFItem", RemoveQFItem, {})
|
||||
|
||||
-- Auto command to map 'dd' in quickfix window
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "qf",
|
||||
callback = function()
|
||||
vim.keymap.set("n", "dd", RemoveQFItem, { buffer = true, silent = true })
|
||||
end,
|
||||
})
|
112
lua/util.lua
Normal file
112
lua/util.lua
Normal file
|
@ -0,0 +1,112 @@
|
|||
local M = {}
|
||||
|
||||
function M.cmd_executable(cmd, callback)
|
||||
local executable = vim.fn.executable(cmd) == 1
|
||||
-- Check if a callback is provided and it is a function
|
||||
if executable and callback and type(callback) == "function" then
|
||||
callback()
|
||||
end
|
||||
|
||||
-- Check if a callback is provided and it is a table
|
||||
if type(callback) == "table" then
|
||||
if executable and (callback[1] or callback[true]) then
|
||||
-- Call the function associated with key 1 or true if the command is executable
|
||||
local func = callback[1] or callback[true]
|
||||
if type(func) == "function" then
|
||||
func()
|
||||
end
|
||||
elseif not executable and (callback[2] or callback[false]) then
|
||||
-- Call the function associated with key 2 or false if the command is not executable
|
||||
local func = callback[2] or callback[false]
|
||||
if type(func) == "function" then
|
||||
func()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return executable
|
||||
end
|
||||
|
||||
-- [1]: (string) lhs (required)
|
||||
-- [2]: (string|fun()) rhs (optional)
|
||||
-- mode: (string|string[]) mode (optional, defaults to "n")
|
||||
-- ft: (string|string[]) filetype for buffer-local keymaps (optional)
|
||||
-- any other option valid for vim.keymap.set
|
||||
function M.keymaps(keymaps)
|
||||
-- is not an array, will pass directly to keymaps
|
||||
if type(keymaps[1]) == "string" then
|
||||
M.keymap(keymaps)
|
||||
else
|
||||
-- is array will iterate over
|
||||
for _, keymap in pairs(keymaps) do
|
||||
M.keymap(keymap)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function M.keymap(keymap)
|
||||
local lhs = keymap[1]
|
||||
local rhs = keymap[2]
|
||||
local mode = keymap["mode"] or "n"
|
||||
local opts = {}
|
||||
for key, value in pairs(keymap) do
|
||||
if type(key) ~= "number" and key ~= "mode" then
|
||||
opts[key] = value
|
||||
end
|
||||
end
|
||||
|
||||
local status, err = pcall(function()
|
||||
vim.keymap.set(mode, lhs, rhs, opts)
|
||||
end)
|
||||
if not status then
|
||||
vim.notify("Failed to create keymap: " .. err, 3)
|
||||
end
|
||||
end
|
||||
|
||||
function M.spread(template)
|
||||
local result = {}
|
||||
for key, value in pairs(template) do
|
||||
result[key] = value
|
||||
end
|
||||
|
||||
return function(table)
|
||||
for key, value in pairs(table) do
|
||||
result[key] = value
|
||||
end
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
function M.table_contains(table, element)
|
||||
for _, value in pairs(table) do
|
||||
if value == element then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- From https://github.com/lukas-reineke/onedark.nvim/blob/master/lua/onedark.lua
|
||||
function M.highlight(group, options)
|
||||
local guifg = options.fg or "NONE"
|
||||
local guibg = options.bg or "NONE"
|
||||
local guisp = options.sp or "NONE"
|
||||
local gui = options.gui or "NONE"
|
||||
local blend = options.blend or 0
|
||||
local ctermfg = options.ctermfg or "NONE"
|
||||
|
||||
vim.cmd(
|
||||
string.format(
|
||||
"highlight %s guifg=%s ctermfg=%s guibg=%s guisp=%s gui=%s blend=%d",
|
||||
group,
|
||||
guifg,
|
||||
ctermfg,
|
||||
guibg,
|
||||
guisp,
|
||||
gui,
|
||||
blend
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
return M
|
134
test.nix
Normal file
134
test.nix
Normal file
|
@ -0,0 +1,134 @@
|
|||
{
|
||||
outputs =
|
||||
{ self
|
||||
, nixpkgs
|
||||
, neovim-src
|
||||
, ...
|
||||
}:
|
||||
let
|
||||
inherit (nixpkgs) lib;
|
||||
#
|
||||
# Funni helper function
|
||||
#
|
||||
withSystem =
|
||||
f:
|
||||
lib.fold lib.recursiveUpdate { } (
|
||||
map f [
|
||||
"x86_64-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-linux"
|
||||
"aarch64-darwin"
|
||||
]
|
||||
);
|
||||
in
|
||||
withSystem (
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
{
|
||||
#
|
||||
# Linter and formatter, run with "nix fmt"
|
||||
# You can use alejandra or nixpkgs-fmt instead of nixfmt if you wish
|
||||
#
|
||||
formatter.${system} = pkgs.writeShellApplication {
|
||||
name = "lint";
|
||||
runtimeInputs = [
|
||||
pkgs.nixfmt-rfc-style
|
||||
pkgs.deadnix
|
||||
pkgs.statix
|
||||
pkgs.fd
|
||||
pkgs.stylua
|
||||
];
|
||||
text = ''
|
||||
fd '.*\.nix' . -x statix fix -- {} \;
|
||||
fd '.*\.nix' . -X deadnix -e -- {} \; -X nixfmt {} \;
|
||||
fd '.*\.lua' . -X stylua --indent-type Spaces --indent-width 2 {} \;
|
||||
'';
|
||||
};
|
||||
|
||||
packages.${system} = {
|
||||
default = self.packages.${system}.neovim;
|
||||
|
||||
neovim =
|
||||
(pkgs.wrapNeovimUnstable
|
||||
(pkgs.neovim-unwrapped.overrideAttrs {
|
||||
#
|
||||
# Use neovim nightly
|
||||
#
|
||||
src = neovim-src;
|
||||
version = neovim-src.shortRev or "dirty";
|
||||
patches = [ ];
|
||||
preConfigure = ''
|
||||
sed -i cmake.config/versiondef.h.in -e "s/@NVIM_VERSION_PRERELEASE@/-dev-$version/"
|
||||
'';
|
||||
})
|
||||
(
|
||||
pkgs.neovimUtils.makeNeovimConfig {
|
||||
plugins =
|
||||
[
|
||||
#
|
||||
# Add plugins from nixpkgs here
|
||||
#
|
||||
pkgs.vimPlugins.nvim-treesitter.withAllGrammars
|
||||
]
|
||||
++ lib.mapAttrsToList
|
||||
(
|
||||
#
|
||||
# This generates plugins from npins sources
|
||||
#
|
||||
name: src: (pkgs.vimUtils.buildVimPlugin { inherit name src; })
|
||||
)
|
||||
(import ./npins/sources.nix pkgs);
|
||||
#
|
||||
# Use the string generated in ./lua/default.nix for init.vim
|
||||
#
|
||||
customRC = import ./lua { inherit lib self; };
|
||||
}
|
||||
)
|
||||
).overrideAttrs
|
||||
(old: {
|
||||
generatedWrapperArgs = old.generatedWrapperArgs or [ ] ++ [
|
||||
"--prefix"
|
||||
"PATH"
|
||||
":"
|
||||
(lib.makeBinPath [
|
||||
#
|
||||
# Runtime dependencies
|
||||
#
|
||||
pkgs.deadnix
|
||||
pkgs.statix
|
||||
pkgs.nil
|
||||
pkgs.ripgrep
|
||||
pkgs.fd
|
||||
pkgs.lua-language-server
|
||||
pkgs.stylua
|
||||
])
|
||||
];
|
||||
});
|
||||
};
|
||||
}
|
||||
);
|
||||
inputs = {
|
||||
nixpkgs = {
|
||||
type = "github";
|
||||
owner = "NixOS";
|
||||
repo = "nixpkgs";
|
||||
ref = "nixos-unstable";
|
||||
};
|
||||
neovim-src = {
|
||||
type = "github";
|
||||
owner = "neovim";
|
||||
repo = "neovim";
|
||||
ref = "f694d020c576fb037eb92bae3bbf03a69d8686b6";
|
||||
flake = false;
|
||||
};
|
||||
flake-compat = {
|
||||
type = "github";
|
||||
owner = "edolstra";
|
||||
repo = "flake-compat";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
6
~/.local/state/nvim_flaked/nvim/log
Normal file
6
~/.local/state/nvim_flaked/nvim/log
Normal file
|
@ -0,0 +1,6 @@
|
|||
WRN 2024-04-30T01:39:24.865 ?.1519525 server_start:164: Failed to start server: no such file or directory: /tmp/nvim.user/nvim_flaked/xxx/
|
||||
WRN 2024-04-30T10:45:55.120 ?.1604443 server_start:164: Failed to start server: no such file or directory: /tmp/nvim.user/nvim_flaked/xxx/
|
||||
WRN 2024-04-30T10:51:56.393 ?.1611908 server_start:164: Failed to start server: no such file or directory: /tmp/nvim.user/nvim_flaked/xxx/
|
||||
WRN 2024-04-30T10:54:55.143 ?.1619079 server_start:164: Failed to start server: no such file or directory: /tmp/nvim.user/nvim_flaked/xxx/
|
||||
WRN 2024-04-30T10:55:21.678 ?.1619181 server_start:164: Failed to start server: no such file or directory: /tmp/nvim.user/nvim_flaked/xxx/
|
||||
WRN 2024-04-30T10:55:38.457 ?.1625034 server_start:164: Failed to start server: no such file or directory: /tmp/nvim.user/nvim_flaked/xxx/
|
Loading…
Add table
Add a link
Reference in a new issue