refactor: notebook configration
This commit is contained in:
10
hosts/nb/modules/development/coding.nix
Normal file
10
hosts/nb/modules/development/coding.nix
Normal file
@@ -0,0 +1,10 @@
|
||||
{ config, pkgs, ... }:
|
||||
let
|
||||
# unstable = import (fetchTarball https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz) {
|
||||
# config = { allowUnfree = true; };
|
||||
# };
|
||||
in {
|
||||
environment.systemPackages = with pkgs; [
|
||||
claude-code
|
||||
];
|
||||
}
|
||||
@@ -8,6 +8,32 @@ let
|
||||
};
|
||||
in {
|
||||
imports = [
|
||||
./mcp.nix
|
||||
# ./mcp.nix
|
||||
./coding.nix
|
||||
./nvim/default.nix
|
||||
];
|
||||
environment.systemPackages = with pkgs; [
|
||||
ddev
|
||||
gcc
|
||||
git
|
||||
glib
|
||||
go
|
||||
nodejs_22
|
||||
rbw
|
||||
bento
|
||||
docker-compose
|
||||
drone-cli
|
||||
git-filter-repo
|
||||
nix-prefetch-git
|
||||
jq
|
||||
mkcert
|
||||
mqttui
|
||||
vim
|
||||
wget
|
||||
wireguard-tools
|
||||
unzip
|
||||
wol
|
||||
];
|
||||
|
||||
virtualisation.docker.enable = true;
|
||||
}
|
||||
|
||||
13
hosts/nb/modules/development/nvim/chatgpt.nix
Normal file
13
hosts/nb/modules/development/nvim/chatgpt.nix
Normal file
@@ -0,0 +1,13 @@
|
||||
self: super: {
|
||||
vimPlugins = super.vimPlugins // {
|
||||
chatgpt-nvim = super.vimUtils.buildVimPlugin {
|
||||
pname = "chatgpt-nvim";
|
||||
version = "1.0.0";
|
||||
src = super.fetchgit {
|
||||
url = "https://git.cloonar.com/Cloonar/chatgpt.vim.git";
|
||||
rev = "7fb8671840181ca5166fcf7b8a8d5f5e10a5efa7";
|
||||
sha256 = "sha256-g4sEUoZqxlliKHj1TAxwNXN400yLN+QB4wV3drmvf9w=";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
221
hosts/nb/modules/development/nvim/config/bufferline.lua
Normal file
221
hosts/nb/modules/development/nvim/config/bufferline.lua
Normal file
@@ -0,0 +1,221 @@
|
||||
local function is_ft(b, ft)
|
||||
return vim.bo[b].filetype == ft
|
||||
end
|
||||
|
||||
local function diagnostics_indicator(num, _, diagnostics, _)
|
||||
local result = {}
|
||||
local symbols = {
|
||||
error = Icons.diagnostics.Error,
|
||||
warning = Icons.diagnostics.Warning,
|
||||
info = Icons.diagnostics.Information,
|
||||
}
|
||||
for name, count in pairs(diagnostics) do
|
||||
if symbols[name] and count > 0 then
|
||||
table.insert(result, symbols[name] .. " " .. count)
|
||||
end
|
||||
end
|
||||
result = table.concat(result, " ")
|
||||
return #result > 0 and result or ""
|
||||
end
|
||||
|
||||
local function custom_filter(buf, buf_nums)
|
||||
local logs = vim.tbl_filter(function(b)
|
||||
return is_ft(b, "log")
|
||||
end, buf_nums)
|
||||
if vim.tbl_isempty(logs) then
|
||||
return true
|
||||
end
|
||||
local tab_num = vim.fn.tabpagenr()
|
||||
local last_tab = vim.fn.tabpagenr "$"
|
||||
local is_log = is_ft(buf, "log")
|
||||
if last_tab == 1 then
|
||||
return true
|
||||
end
|
||||
-- only show log buffers in secondary tabs
|
||||
return (tab_num == last_tab and is_log) or (tab_num ~= last_tab and not is_log)
|
||||
end
|
||||
|
||||
|
||||
local config = {
|
||||
active = true,
|
||||
on_config_done = nil,
|
||||
keymap = {
|
||||
normal_mode = {},
|
||||
},
|
||||
highlights = {
|
||||
background = {
|
||||
italic = true,
|
||||
},
|
||||
buffer_selected = {
|
||||
bold = true,
|
||||
},
|
||||
},
|
||||
options = {
|
||||
mode = "buffers", -- set to "tabs" to only show tabpages instead
|
||||
numbers = "none", -- can be "none" | "ordinal" | "buffer_id" | "both" | function
|
||||
close_command = function(bufnr) -- can be a string | function, see "Mouse actions"
|
||||
buf_kill("bd", bufnr, false)
|
||||
end,
|
||||
right_mouse_command = "vert sbuffer %d", -- can be a string | function, see "Mouse actions"
|
||||
left_mouse_command = "buffer %d", -- can be a string | function, see "Mouse actions"
|
||||
middle_mouse_command = nil, -- can be a string | function, see "Mouse actions"
|
||||
indicator = {
|
||||
icon = Icons.ui.BoldLineLeft, -- this should be omitted if indicator style is not 'icon'
|
||||
style = "icon", -- can also be 'underline'|'none',
|
||||
},
|
||||
buffer_close_icon = Icons.ui.Close,
|
||||
modified_icon = Icons.ui.Circle,
|
||||
close_icon = Icons.ui.BoldClose,
|
||||
left_trunc_marker = Icons.ui.ArrowCircleLeft,
|
||||
right_trunc_marker = Icons.ui.ArrowCircleRight,
|
||||
--- name_formatter can be used to change the buffer's label in the bufferline.
|
||||
--- Please note some names can/will break the
|
||||
--- bufferline so use this at your discretion knowing that it has
|
||||
--- some limitations that will *NOT* be fixed.
|
||||
name_formatter = function(buf) -- buf contains a "name", "path" and "bufnr"
|
||||
-- remove extension from markdown files for example
|
||||
if buf.name:match "%.md" then
|
||||
return vim.fn.fnamemodify(buf.name, ":t:r")
|
||||
end
|
||||
end,
|
||||
max_name_length = 18,
|
||||
max_prefix_length = 15, -- prefix used when a buffer is de-duplicated
|
||||
truncate_names = true, -- whether or not tab names should be truncated
|
||||
tab_size = 18,
|
||||
diagnostics = "nvim_lsp",
|
||||
diagnostics_update_in_insert = false,
|
||||
diagnostics_indicator = diagnostics_indicator,
|
||||
-- NOTE: this will be called a lot so don't do any heavy processing here
|
||||
custom_filter = custom_filter,
|
||||
offsets = {
|
||||
{
|
||||
filetype = "undotree",
|
||||
text = "Undotree",
|
||||
highlight = "PanelHeading",
|
||||
padding = 1,
|
||||
},
|
||||
{
|
||||
filetype = "NvimTree",
|
||||
text = "Explorer",
|
||||
highlight = "PanelHeading",
|
||||
padding = 1,
|
||||
},
|
||||
{
|
||||
filetype = "DiffviewFiles",
|
||||
text = "Diff View",
|
||||
highlight = "PanelHeading",
|
||||
padding = 1,
|
||||
},
|
||||
{
|
||||
filetype = "flutterToolsOutline",
|
||||
text = "Flutter Outline",
|
||||
highlight = "PanelHeading",
|
||||
},
|
||||
{
|
||||
filetype = "packer",
|
||||
text = "Packer",
|
||||
highlight = "PanelHeading",
|
||||
padding = 1,
|
||||
},
|
||||
},
|
||||
color_icons = true, -- whether or not to add the filetype icon highlights
|
||||
show_buffer_icons = true, -- disable filetype icons for buffers
|
||||
show_buffer_close_icons = true,
|
||||
show_close_icon = false,
|
||||
show_tab_indicators = true,
|
||||
persist_buffer_sort = true, -- whether or not custom sorted buffers should persist
|
||||
-- can also be a table containing 2 custom separators
|
||||
-- [focused and unfocused]. eg: { '|', '|' }
|
||||
separator_style = "thin",
|
||||
enforce_regular_tabs = false,
|
||||
always_show_bufferline = false,
|
||||
hover = {
|
||||
enabled = false, -- requires nvim 0.8+
|
||||
delay = 200,
|
||||
reveal = { "close" },
|
||||
},
|
||||
sort_by = "id",
|
||||
},
|
||||
}
|
||||
|
||||
--require('keymappings').load(config.keymap)
|
||||
|
||||
require("bufferline").setup({
|
||||
options = config.options,
|
||||
highlights = config.highlights,
|
||||
})
|
||||
|
||||
--stylua: ignore
|
||||
|
||||
-- Common kill function for bdelete and bwipeout
|
||||
-- credits: based on bbye and nvim-bufdel
|
||||
---@param kill_command? string defaults to "bd"
|
||||
---@param bufnr? number defaults to the current buffer
|
||||
---@param force? boolean defaults to false
|
||||
function buf_kill(kill_command, bufnr, force)
|
||||
kill_command = kill_command or "bd"
|
||||
|
||||
local bo = vim.bo
|
||||
local api = vim.api
|
||||
local fmt = string.format
|
||||
local fnamemodify = vim.fn.fnamemodify
|
||||
|
||||
if bufnr == 0 or bufnr == nil then
|
||||
bufnr = api.nvim_get_current_buf()
|
||||
end
|
||||
|
||||
local bufname = api.nvim_buf_get_name(bufnr)
|
||||
|
||||
if not force then
|
||||
local warning
|
||||
if bo[bufnr].modified then
|
||||
warning = fmt([[No write since last change for (%s)]], fnamemodify(bufname, ":t"))
|
||||
elseif api.nvim_buf_get_option(bufnr, "buftype") == "terminal" then
|
||||
warning = fmt([[Terminal %s will be killed]], bufname)
|
||||
end
|
||||
if warning then
|
||||
vim.ui.input({
|
||||
prompt = string.format([[%s. Close it anyway? [y]es or [n]o (default: no): ]], warning),
|
||||
}, function(choice)
|
||||
if choice:match "ye?s?" then force = true end
|
||||
end)
|
||||
if not force then return end
|
||||
end
|
||||
end
|
||||
|
||||
-- Get list of windows IDs with the buffer to close
|
||||
local windows = vim.tbl_filter(function(win)
|
||||
return api.nvim_win_get_buf(win) == bufnr
|
||||
end, api.nvim_list_wins())
|
||||
|
||||
if force then
|
||||
kill_command = kill_command .. "!"
|
||||
end
|
||||
|
||||
-- Get list of active buffers
|
||||
local buffers = vim.tbl_filter(function(buf)
|
||||
return api.nvim_buf_is_valid(buf) and bo[buf].buflisted
|
||||
end, api.nvim_list_bufs())
|
||||
|
||||
-- If there is only one buffer (which has to be the current one), vim will
|
||||
-- create a new buffer on :bd.
|
||||
-- For more than one buffer, pick the previous buffer (wrapping around if necessary)
|
||||
if #buffers > 1 and #windows > 0 then
|
||||
for i, v in ipairs(buffers) do
|
||||
if v == bufnr then
|
||||
local prev_buf_idx = i == 1 and (#buffers - 1) or (i - 1)
|
||||
local prev_buffer = buffers[prev_buf_idx]
|
||||
for _, win in ipairs(windows) do
|
||||
api.nvim_win_set_buf(win, prev_buffer)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Check if buffer still exists, to ensure the target buffer wasn't killed
|
||||
-- due to options like bufhidden=wipe.
|
||||
if api.nvim_buf_is_valid(bufnr) and bo[bufnr].buflisted then
|
||||
vim.cmd(string.format("%s %d", kill_command, bufnr))
|
||||
end
|
||||
end
|
||||
|
||||
2
hosts/nb/modules/development/nvim/config/copilot.lua
Normal file
2
hosts/nb/modules/development/nvim/config/copilot.lua
Normal file
@@ -0,0 +1,2 @@
|
||||
vim.api.nvim_set_keymap('i', '<C-J>', 'copilot#Accept("<CR>")', { expr=true, noremap = true, silent = true })
|
||||
vim.g.copilot_no_tab_map = true
|
||||
155
hosts/nb/modules/development/nvim/config/icons.lua
Normal file
155
hosts/nb/modules/development/nvim/config/icons.lua
Normal file
@@ -0,0 +1,155 @@
|
||||
Icons = {
|
||||
kind = {
|
||||
Array = "",
|
||||
Boolean = "蘒",
|
||||
Class = "",
|
||||
Color = "",
|
||||
Constant = "",
|
||||
Constructor = "",
|
||||
Enum = "",
|
||||
EnumMember = "",
|
||||
Event = "",
|
||||
Field = "",
|
||||
File = "",
|
||||
Folder = "",
|
||||
Function = "",
|
||||
Interface = "",
|
||||
Key = "",
|
||||
Keyword = "",
|
||||
Method = "",
|
||||
Module = "",
|
||||
Namespace = "",
|
||||
Null = "ﳠ",
|
||||
Number = "",
|
||||
Object = "",
|
||||
Operator = "",
|
||||
Package = "",
|
||||
Property = "",
|
||||
Reference = "",
|
||||
Snippet = "",
|
||||
String = "",
|
||||
Struct = "",
|
||||
Text = "",
|
||||
TypeParameter = "",
|
||||
Unit = "",
|
||||
Value = "",
|
||||
Variable = "",
|
||||
},
|
||||
git = {
|
||||
LineAdded = "",
|
||||
LineModified = "",
|
||||
LineRemoved = "",
|
||||
FileDeleted = "",
|
||||
FileIgnored = "◌",
|
||||
FileRenamed = "➜",
|
||||
FileStaged = "S",
|
||||
FileUnmerged = "",
|
||||
FileUnstaged = "",
|
||||
FileUntracked = "U",
|
||||
Diff = "",
|
||||
Repo = "",
|
||||
Octoface = "",
|
||||
Branch = "",
|
||||
},
|
||||
ui = {
|
||||
ArrowCircleDown = "",
|
||||
ArrowCircleLeft = "",
|
||||
ArrowCircleRight = "",
|
||||
ArrowCircleUp = "",
|
||||
BoldArrowDown = "",
|
||||
BoldArrowLeft = "",
|
||||
BoldArrowRight = "",
|
||||
BoldArrowUp = "",
|
||||
BoldClose = "",
|
||||
BoldDividerLeft = "",
|
||||
BoldDividerRight = "",
|
||||
BoldLineLeft = "▎",
|
||||
BookMark = "",
|
||||
BoxChecked = "",
|
||||
Bug = "",
|
||||
Stacks = " ",
|
||||
Scopes = "",
|
||||
Watches = "",
|
||||
DebugConsole = " ",
|
||||
Calendar = "",
|
||||
Check = "",
|
||||
ChevronRight = ">",
|
||||
ChevronShortDown = "",
|
||||
ChevronShortLeft = "",
|
||||
ChevronShortRight = "",
|
||||
ChevronShortUp = "",
|
||||
Circle = "",
|
||||
Close = "",
|
||||
CloudDownload = "",
|
||||
Code = "",
|
||||
Comment = "",
|
||||
Dashboard = "",
|
||||
DividerLeft = "",
|
||||
DividerRight = "",
|
||||
DoubleChevronRight = "»",
|
||||
Ellipsis = "…",
|
||||
EmptyFolder = "",
|
||||
EmptyFolderOpen = "",
|
||||
File = "",
|
||||
FileSymlink = "",
|
||||
Files = "",
|
||||
FindFile = "",
|
||||
FindText = "",
|
||||
Fire = "",
|
||||
Folder = "",
|
||||
FolderOpen = "",
|
||||
FolderSymlink = "",
|
||||
Forward = "",
|
||||
Gear = "",
|
||||
History = "",
|
||||
Lightbulb = "",
|
||||
LineLeft = "▏",
|
||||
LineMiddle = "│",
|
||||
List = "",
|
||||
Lock = "",
|
||||
NewFile = "",
|
||||
Note = "",
|
||||
Package = "",
|
||||
Pencil = "",
|
||||
Plus = "",
|
||||
Project = "",
|
||||
Search = "",
|
||||
SignIn = "",
|
||||
SignOut = "",
|
||||
Tab = "",
|
||||
Table = "",
|
||||
Target = "",
|
||||
Telescope = "",
|
||||
Text = "",
|
||||
Tree = "",
|
||||
Triangle = "契",
|
||||
TriangleShortArrowDown = "",
|
||||
TriangleShortArrowLeft = "",
|
||||
TriangleShortArrowRight = "",
|
||||
TriangleShortArrowUp = "",
|
||||
},
|
||||
diagnostics = {
|
||||
BoldError = "",
|
||||
Error = "",
|
||||
BoldWarning = "",
|
||||
Warning = "",
|
||||
BoldInformation = "",
|
||||
Information = "",
|
||||
BoldQuestion = "",
|
||||
Question = "",
|
||||
BoldHint = "",
|
||||
Hint = "",
|
||||
Debug = "",
|
||||
Trace = "✎",
|
||||
},
|
||||
misc = {
|
||||
Robot = "ﮧ",
|
||||
Squirrel = "",
|
||||
Tag = "",
|
||||
Watch = "",
|
||||
Smiley = "ﲃ",
|
||||
Package = "",
|
||||
CircuitBoard = "",
|
||||
},
|
||||
}
|
||||
|
||||
87
hosts/nb/modules/development/nvim/config/init.lua
Normal file
87
hosts/nb/modules/development/nvim/config/init.lua
Normal file
@@ -0,0 +1,87 @@
|
||||
-- vim.opt.expandtab = true
|
||||
-- vim.opt.hidden = true
|
||||
-- vim.opt.incsearch = true
|
||||
-- vim.opt.mouse = "a"
|
||||
-- vim.opt.number = true
|
||||
-- vim.opt.shiftwidth = 2
|
||||
-- vim.opt.splitbelow = true
|
||||
-- vim.opt.splitright = true
|
||||
-- vim.opt.signcolumn = "yes:3"
|
||||
-- vim.opt.tabstop = 2
|
||||
-- vim.opt.timeoutlen = 0
|
||||
-- vim.wo.wrap = false
|
||||
-- vim.opt.exrc = true
|
||||
-- vim.cmd("syntax on")
|
||||
|
||||
vim.opt.backup = false -- creates a backup file
|
||||
vim.opt.clipboard = "unnamedplus" -- allows neovim to access the system clipboard
|
||||
vim.opt.cmdheight = 2 -- more space in the neovim command line for displaying messages
|
||||
vim.opt.colorcolumn = "99999" -- fixes indentline for now
|
||||
vim.opt.completeopt = { "menuone", "noselect" }
|
||||
vim.opt.conceallevel = 0 -- so that `` is visible in markdown files
|
||||
vim.opt.fileencoding = "utf-8" -- the encoding written to a file
|
||||
vim.opt.foldmethod = "manual" -- folding set to "expr" for treesitter based folding
|
||||
vim.opt.foldexpr = "" -- set to "nvim_treesitter#foldexpr()" for treesitter based folding
|
||||
vim.opt.guifont = "monospace:h17" -- the font used in graphical neovim applications
|
||||
vim.opt.hidden = true -- required to keep multiple buffers and open multiple buffers
|
||||
vim.opt.hlsearch = true -- highlight all matches on previous search pattern
|
||||
vim.opt.ignorecase = true -- ignore case in search patterns
|
||||
vim.opt.mouse = "a" -- allow the mouse to be used in neovim
|
||||
vim.opt.pumheight = 10 -- pop up menu height
|
||||
vim.opt.showmode = false -- we don't need to see things like -- INSERT -- anymore
|
||||
vim.opt.showtabline = 2 -- always show tabs
|
||||
vim.opt.smartcase = true -- smart case
|
||||
vim.opt.smartindent = true -- make indenting smarter again
|
||||
vim.opt.splitbelow = true -- force all horizontal splits to go below current window
|
||||
vim.opt.splitright = true -- force all vertical splits to go to the right of current window
|
||||
vim.opt.swapfile = false -- creates a swapfile
|
||||
vim.opt.termguicolors = true -- set term gui colors (most terminals support this)
|
||||
vim.opt.timeoutlen = 100 -- time to wait for a mapped sequence to complete (in milliseconds)
|
||||
vim.opt.title = true -- set the title of window to the value of the titlestring
|
||||
vim.opt.titlestring = "%<%F%=%l/%L - nvim" -- what the title of the window will be set to
|
||||
vim.opt.undodir = vim.fn.stdpath "cache" .. "/undo"
|
||||
vim.opt.undofile = true -- enable persistent undo
|
||||
vim.opt.updatetime = 300 -- faster completion
|
||||
vim.opt.writebackup = false -- if a file is being edited by another program it is not allowed to be edited
|
||||
vim.opt.expandtab = true -- convert tabs to spaces
|
||||
vim.opt.shiftwidth = 2 -- the number of spaces inserted for each indentation
|
||||
vim.opt.tabstop = 2 -- insert 2 spaces for a tab
|
||||
vim.opt.cursorline = true -- highlight the current line
|
||||
vim.opt.number = true -- set numbered lines
|
||||
vim.opt.relativenumber = false -- set relative numbered lines
|
||||
vim.opt.numberwidth = 4 -- set number column width to 2 {default 4}
|
||||
vim.opt.signcolumn = "yes" -- always show the sign column otherwise text shifts each time
|
||||
vim.opt.wrap = false -- display lines as one long line
|
||||
vim.opt.spell = false
|
||||
vim.opt.spelllang = "en"
|
||||
vim.opt.scrolloff = 8 -- keep 8 lines above/below the cursor
|
||||
vim.opt.sidescrolloff = 8
|
||||
|
||||
-- Automatically disable heavy features for very large files
|
||||
local largefile_group = vim.api.nvim_create_augroup("LargeFile", { clear = true })
|
||||
vim.api.nvim_create_autocmd("BufReadPre", {
|
||||
group = largefile_group,
|
||||
pattern = "*",
|
||||
callback = function(args)
|
||||
local max_filesize = 1 * 1024 * 1024 -- 1 MB in bytes
|
||||
local file = vim.fn.expand("<afile>")
|
||||
if vim.fn.getfsize(file) > max_filesize then
|
||||
-- Turn off syntax highlighting
|
||||
vim.cmd("syntax off")
|
||||
-- Disable Treesitter's highlight for this buffer
|
||||
pcall(vim.cmd, "TSBufDisable highlight")
|
||||
|
||||
-- Optionally disable LSP for this buffer
|
||||
for _, client in pairs(vim.lsp.get_active_clients()) do
|
||||
if client ~= nil and client.attached_buffers[args.buf] then
|
||||
client.detach(args.buf)
|
||||
end
|
||||
end
|
||||
|
||||
-- You can also disable or reduce other settings if needed, e.g.:
|
||||
vim.opt.foldmethod = "manual"
|
||||
vim.opt.wrap = false
|
||||
vim.opt.hlsearch = false
|
||||
end
|
||||
end,
|
||||
})
|
||||
149
hosts/nb/modules/development/nvim/config/keymappings.lua
Normal file
149
hosts/nb/modules/development/nvim/config/keymappings.lua
Normal file
@@ -0,0 +1,149 @@
|
||||
local generic_opts_any = { noremap = true, silent = true }
|
||||
|
||||
local generic_opts = {
|
||||
insert_mode = generic_opts_any,
|
||||
normal_mode = generic_opts_any,
|
||||
visual_mode = generic_opts_any,
|
||||
visual_block_mode = generic_opts_any,
|
||||
command_mode = generic_opts_any,
|
||||
term_mode = { silent = true },
|
||||
}
|
||||
|
||||
local mode_adapters = {
|
||||
insert_mode = "i",
|
||||
normal_mode = "n",
|
||||
term_mode = "t",
|
||||
visual_mode = "v",
|
||||
visual_block_mode = "x",
|
||||
command_mode = "c",
|
||||
}
|
||||
|
||||
---@class Keys
|
||||
---@field insert_mode table
|
||||
---@field normal_mode table
|
||||
---@field terminal_mode table
|
||||
---@field visual_mode table
|
||||
---@field visual_block_mode table
|
||||
---@field command_mode table
|
||||
|
||||
local defaults = {
|
||||
insert_mode = {
|
||||
-- Move current line / block with Alt-j/k ala vscode.
|
||||
["<A-j>"] = "<Esc>:m .+1<CR>==gi",
|
||||
-- Move current line / block with Alt-j/k ala vscode.
|
||||
["<A-k>"] = "<Esc>:m .-2<CR>==gi",
|
||||
-- navigation
|
||||
["<A-Up>"] = "<C-\\><C-N><C-w>k",
|
||||
["<A-Down>"] = "<C-\\><C-N><C-w>j",
|
||||
["<A-Left>"] = "<C-\\><C-N><C-w>h",
|
||||
["<A-Right>"] = "<C-\\><C-N><C-w>l",
|
||||
},
|
||||
|
||||
normal_mode = {
|
||||
-- Better window movement
|
||||
-- ["<C-h>"] = "<C-w>h",
|
||||
-- ["<C-j>"] = "<C-w>j",
|
||||
-- ["<C-k>"] = "<C-w>k",
|
||||
-- ["<C-l>"] = "<C-w>l",
|
||||
["<C-j>"] = ":tabprevious<CR><CR>",
|
||||
["<C-k>"] = ":tabnext<CR><CR>",
|
||||
["<C-n>"] = ":tabnew<CR><CR>",
|
||||
["<C-q>"] = ":tabclose<CR><CR>",
|
||||
|
||||
-- Resize with arrows
|
||||
["<C-Up>"] = ":resize -2<CR>",
|
||||
["<C-Down>"] = ":resize +2<CR>",
|
||||
["<C-Left>"] = ":vertical resize -2<CR>",
|
||||
["<C-Right>"] = ":vertical resize +2<CR>",
|
||||
|
||||
-- Move current line / block with Alt-j/k a la vscode.
|
||||
["<A-j>"] = ":m .+1<CR>==",
|
||||
["<A-k>"] = ":m .-2<CR>==",
|
||||
|
||||
-- QuickFix
|
||||
["]q"] = ":cnext<CR>",
|
||||
["[q"] = ":cprev<CR>",
|
||||
["<C-q>"] = ":call QuickFixToggle()<CR>",
|
||||
},
|
||||
|
||||
term_mode = {
|
||||
-- Terminal window navigation
|
||||
["<C-h>"] = "<C-\\><C-N><C-w>h",
|
||||
["<C-j>"] = "<C-\\><C-N><C-w>j",
|
||||
["<C-k>"] = "<C-\\><C-N><C-w>k",
|
||||
["<C-l>"] = "<C-\\><C-N><C-w>l",
|
||||
},
|
||||
|
||||
visual_mode = {
|
||||
-- Better indenting
|
||||
["<"] = "<gv",
|
||||
[">"] = ">gv",
|
||||
|
||||
-- ["p"] = '"0p',
|
||||
-- ["P"] = '"0P',
|
||||
},
|
||||
|
||||
visual_block_mode = {
|
||||
-- Move current line / block with Alt-j/k ala vscode.
|
||||
["<A-j>"] = ":m '>+1<CR>gv-gv",
|
||||
["<A-k>"] = ":m '<-2<CR>gv-gv",
|
||||
},
|
||||
|
||||
command_mode = {
|
||||
-- navigate tab completion with <c-j> and <c-k>
|
||||
-- runs conditionally
|
||||
["<C-j>"] = { 'pumvisible() ? "\\<C-n>" : "\\<C-j>"', { expr = true, noremap = true } },
|
||||
["<C-k>"] = { 'pumvisible() ? "\\<C-p>" : "\\<C-k>"', { expr = true, noremap = true } },
|
||||
},
|
||||
}
|
||||
|
||||
if vim.fn.has "mac" == 1 then
|
||||
defaults.normal_mode["<A-Up>"] = defaults.normal_mode["<C-Up>"]
|
||||
defaults.normal_mode["<A-Down>"] = defaults.normal_mode["<C-Down>"]
|
||||
defaults.normal_mode["<A-Left>"] = defaults.normal_mode["<C-Left>"]
|
||||
defaults.normal_mode["<A-Right>"] = defaults.normal_mode["<C-Right>"]
|
||||
Log:debug "Activated mac keymappings"
|
||||
end
|
||||
|
||||
function set_keymaps(mode, key, val)
|
||||
local opt = generic_opts[mode] or generic_opts_any
|
||||
if type(val) == "table" then
|
||||
opt = val[2]
|
||||
val = val[1]
|
||||
end
|
||||
if val then
|
||||
vim.keymap.set(mode, key, val, opt)
|
||||
else
|
||||
pcall(vim.api.nvim_del_keymap, mode, key)
|
||||
end
|
||||
end
|
||||
|
||||
function load_mode(mode, keymaps)
|
||||
mode = mode_adapters[mode] or mode
|
||||
for k, v in pairs(keymaps) do
|
||||
set_keymaps(mode, k, v)
|
||||
end
|
||||
end
|
||||
|
||||
function load(keymaps)
|
||||
keymaps = keymaps or {}
|
||||
for mode, mapping in pairs(keymaps) do
|
||||
load_mode(mode, mapping)
|
||||
end
|
||||
end
|
||||
|
||||
function load_defaults()
|
||||
load(get_defaults())
|
||||
keys = keys or {}
|
||||
for idx, _ in pairs(defaults) do
|
||||
if not keys[idx] then
|
||||
keys[idx] = {}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function get_defaults()
|
||||
return defaults
|
||||
end
|
||||
|
||||
load_defaults()
|
||||
54
hosts/nb/modules/development/nvim/config/lspconfig.lua
Normal file
54
hosts/nb/modules/development/nvim/config/lspconfig.lua
Normal file
@@ -0,0 +1,54 @@
|
||||
local status, lspc = pcall(require, 'lspconfig')
|
||||
if (not status) then return end
|
||||
|
||||
lspc.clangd.setup{}
|
||||
|
||||
local buf_map = function(bufnr, mode, lhs, rhs, opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, mode, lhs, rhs, opts or {
|
||||
silent = true,
|
||||
})
|
||||
end
|
||||
|
||||
local protocol = require('vim.lsp.protocol')
|
||||
|
||||
local on_attach = function(client, buffnr)
|
||||
if client.server.capabilities.documentFormattingProvider then
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = vim.api.nvim_create_augroup("format", { clear = true }),
|
||||
buffer = buffnr,
|
||||
callback = function() vim.lsp.buf.formatting_seq_sync() end
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
||||
|
||||
local servers = { 'ts_ls', 'lua_ls', 'cssls', 'yamlls', 'intelephense', 'gopls' }
|
||||
for _, lsp in pairs(servers) do
|
||||
require('lspconfig')[lsp].setup {
|
||||
-- on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
end
|
||||
|
||||
lspc.yamlls.setup({
|
||||
settings = {
|
||||
yaml = {
|
||||
keyOrdering = false,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
-- autoformat json files with jq
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "json",
|
||||
callback = function(ev)
|
||||
vim.bo[ev.buf].formatprg = "jq"
|
||||
print("It's a json file")
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
-- lspc.intelephense.setup()
|
||||
73
hosts/nb/modules/development/nvim/config/nvim-cmp.lua
Normal file
73
hosts/nb/modules/development/nvim/config/nvim-cmp.lua
Normal file
@@ -0,0 +1,73 @@
|
||||
local has_words_before = function()
|
||||
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
|
||||
|
||||
local feedkey = function(key, mode)
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
||||
end
|
||||
|
||||
local cmp = require("cmp")
|
||||
local lspkind = require("lspkind")
|
||||
|
||||
cmp.setup({
|
||||
sources = {
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "cmp_tabnine" },
|
||||
{ name = "treesitter" },
|
||||
{ name = "buffer" },
|
||||
{ name = "path" },
|
||||
{ name = "vsnip" },
|
||||
-- { name = "copilot" },
|
||||
},
|
||||
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
vim.fn["vsnip#anonymous"](args.body)
|
||||
end,
|
||||
},
|
||||
|
||||
formatting = {
|
||||
format = lspkind.cmp_format({
|
||||
with_text = true,
|
||||
menu = {
|
||||
buffer = "[Buf]",
|
||||
nvim_lsp = "[LSP]",
|
||||
nvim_lua = "[Lua]",
|
||||
latex_symbols = "[Latex]",
|
||||
treesitter = "[TS]",
|
||||
cmp_tabnine = "[TN]",
|
||||
vsnip = "[Snip]",
|
||||
},
|
||||
}),
|
||||
},
|
||||
|
||||
mapping = {
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif vim.fn["vsnip#available"](1) == 1 then
|
||||
feedkey("<Plug>(vsnip-expand-or-jump)", "")
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {
|
||||
"i",
|
||||
"s",
|
||||
}),
|
||||
|
||||
["<S-Tab>"] = cmp.mapping(function()
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
|
||||
feedkey("<Plug>(vsnip-jump-prev)", "")
|
||||
end
|
||||
end, {
|
||||
"i",
|
||||
"s",
|
||||
}),
|
||||
},
|
||||
})
|
||||
41
hosts/nb/modules/development/nvim/config/project.lua
Normal file
41
hosts/nb/modules/development/nvim/config/project.lua
Normal file
@@ -0,0 +1,41 @@
|
||||
config = {
|
||||
---@usage set to false to disable project.nvim.
|
||||
--- This is on by default since it's currently the expected behavior.
|
||||
active = true,
|
||||
|
||||
on_config_done = nil,
|
||||
|
||||
---@usage set to true to disable setting the current-woriking directory
|
||||
--- Manual mode doesn't automatically change your root directory, so you have
|
||||
--- the option to manually do so using `:ProjectRoot` command.
|
||||
manual_mode = false,
|
||||
|
||||
---@usage Methods of detecting the root directory
|
||||
--- Allowed values: **"lsp"** uses the native neovim lsp
|
||||
--- **"pattern"** uses vim-rooter like glob pattern matching. Here
|
||||
--- order matters: if one is not detected, the other is used as fallback. You
|
||||
--- can also delete or rearangne the detection methods.
|
||||
-- detection_methods = { "lsp", "pattern" }, -- NOTE: lsp detection will get annoying with multiple langs in one project
|
||||
detection_methods = { "pattern" },
|
||||
|
||||
---@usage patterns used to detect root dir, when **"pattern"** is in detection_methods
|
||||
patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json", "pom.xml" },
|
||||
|
||||
---@ Show hidden files in telescope when searching for files in a project
|
||||
show_hidden = false,
|
||||
|
||||
---@usage When set to false, you will get a message when project.nvim changes your directory.
|
||||
-- When set to false, you will get a message when project.nvim changes your directory.
|
||||
silent_chdir = true,
|
||||
|
||||
---@usage list of lsp client names to ignore when using **lsp** detection. eg: { "efm", ... }
|
||||
ignore_lsp = {},
|
||||
}
|
||||
|
||||
local status_ok, project = pcall(require, "project_nvim")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
project.setup(config)
|
||||
|
||||
149
hosts/nb/modules/development/nvim/config/telescope.lua
Normal file
149
hosts/nb/modules/development/nvim/config/telescope.lua
Normal file
@@ -0,0 +1,149 @@
|
||||
local function get_pickers(actions)
|
||||
return {
|
||||
find_files = {
|
||||
theme = "dropdown",
|
||||
hidden = true,
|
||||
previewer = false,
|
||||
},
|
||||
live_grep = {
|
||||
--@usage don't include the filename in the search results
|
||||
only_sort_text = true,
|
||||
theme = "dropdown",
|
||||
},
|
||||
grep_string = {
|
||||
only_sort_text = true,
|
||||
theme = "dropdown",
|
||||
},
|
||||
buffers = {
|
||||
theme = "dropdown",
|
||||
previewer = false,
|
||||
initial_mode = "normal",
|
||||
mappings = {
|
||||
i = {
|
||||
["<C-d>"] = actions.delete_buffer,
|
||||
},
|
||||
n = {
|
||||
["dd"] = actions.delete_buffer,
|
||||
},
|
||||
},
|
||||
},
|
||||
planets = {
|
||||
show_pluto = true,
|
||||
show_moon = true,
|
||||
},
|
||||
git_files = {
|
||||
theme = "dropdown",
|
||||
hidden = true,
|
||||
previewer = false,
|
||||
show_untracked = true,
|
||||
layout_config = { width = 0.8 },
|
||||
},
|
||||
lsp_references = {
|
||||
theme = "dropdown",
|
||||
initial_mode = "normal",
|
||||
},
|
||||
lsp_definitions = {
|
||||
theme = "dropdown",
|
||||
initial_mode = "normal",
|
||||
},
|
||||
lsp_declarations = {
|
||||
theme = "dropdown",
|
||||
initial_mode = "normal",
|
||||
},
|
||||
lsp_implementations = {
|
||||
theme = "dropdown",
|
||||
initial_mode = "normal",
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
local ok, actions = pcall(require, "telescope.actions")
|
||||
if not ok then
|
||||
return
|
||||
end
|
||||
|
||||
local config = {
|
||||
prompt_prefix = " ",
|
||||
selection_caret = " ",
|
||||
entry_prefix = " ",
|
||||
initial_mode = "insert",
|
||||
selection_strategy = "reset",
|
||||
sorting_strategy = "descending",
|
||||
layout_strategy = "horizontal",
|
||||
layout_config = {
|
||||
width = 0.8,
|
||||
preview_cutoff = 120,
|
||||
horizontal = {
|
||||
preview_width = function(_, cols, _)
|
||||
if cols < 120 then
|
||||
return math.floor(cols * 0.8)
|
||||
end
|
||||
return math.floor(cols * 0.8)
|
||||
end,
|
||||
mirror = false,
|
||||
},
|
||||
vertical = { mirror = false },
|
||||
},
|
||||
vimgrep_arguments = {
|
||||
"rg",
|
||||
"--color=never",
|
||||
"--no-heading",
|
||||
"--with-filename",
|
||||
"--line-number",
|
||||
"--column",
|
||||
"--smart-case",
|
||||
"--hidden",
|
||||
"--glob=!.git/",
|
||||
},
|
||||
---@usage Mappings are fully customizable. Many familiar mapping patterns are setup as defaults.
|
||||
mappings = {
|
||||
i = {
|
||||
["<C-n>"] = actions.move_selection_next,
|
||||
["<C-p>"] = actions.move_selection_previous,
|
||||
["<C-c>"] = actions.close,
|
||||
["<C-j>"] = actions.cycle_history_next,
|
||||
["<C-k>"] = actions.cycle_history_prev,
|
||||
["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
|
||||
["<CR>"] = actions.select_default,
|
||||
},
|
||||
n = {
|
||||
["<C-n>"] = actions.move_selection_next,
|
||||
["<C-p>"] = actions.move_selection_previous,
|
||||
["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
|
||||
},
|
||||
},
|
||||
pickers = get_pickers(actions),
|
||||
file_ignore_patterns = {},
|
||||
path_display = { "smart" },
|
||||
winblend = 0,
|
||||
border = {},
|
||||
borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" },
|
||||
color_devicons = true,
|
||||
set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil,
|
||||
extensions = {
|
||||
fzf = {
|
||||
fuzzy = true, -- false will only do exact matching
|
||||
override_generic_sorter = true, -- override the generic sorter
|
||||
override_file_sorter = true, -- override the file sorter
|
||||
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
local previewers = require "telescope.previewers"
|
||||
local sorters = require "telescope.sorters"
|
||||
|
||||
config = vim.tbl_extend("keep", {
|
||||
file_previewer = previewers.vim_buffer_cat.new,
|
||||
grep_previewer = previewers.vim_buffer_vimgrep.new,
|
||||
qflist_previewer = previewers.vim_buffer_qflist.new,
|
||||
file_sorter = sorters.get_fuzzy_file,
|
||||
generic_sorter = sorters.get_generic_fuzzy_sorter,
|
||||
}, config)
|
||||
|
||||
local telescope = require "telescope"
|
||||
telescope.setup(config)
|
||||
|
||||
require("telescope").load_extension "projects"
|
||||
require("telescope").load_extension "fzf"
|
||||
133
hosts/nb/modules/development/nvim/config/terminal.lua
Normal file
133
hosts/nb/modules/development/nvim/config/terminal.lua
Normal file
@@ -0,0 +1,133 @@
|
||||
local config = {
|
||||
active = true,
|
||||
on_config_done = nil,
|
||||
-- size can be a number or function which is passed the current terminal
|
||||
size = 60,
|
||||
open_mapping = [[<c-t>]],
|
||||
hide_numbers = true, -- hide the number column in toggleterm buffers
|
||||
shade_filetypes = {},
|
||||
shade_terminals = true,
|
||||
shading_factor = 2, -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light
|
||||
start_in_insert = true,
|
||||
insert_mappings = true, -- whether or not the open mapping applies in insert mode
|
||||
persist_size = false,
|
||||
-- direction = 'vertical' | 'horizontal' | 'window' | 'float',
|
||||
direction = "float",
|
||||
close_on_exit = true, -- close the terminal window when the process exits
|
||||
shell = vim.o.shell, -- change the default shell
|
||||
-- This field is only relevant if direction is set to 'float'
|
||||
float_opts = {
|
||||
-- The border key is *almost* the same as 'nvim_win_open'
|
||||
-- see :h nvim_win_open for details on borders however
|
||||
-- the 'curved' border is a custom border type
|
||||
-- not natively supported but implemented in this plugin.
|
||||
-- border = 'single' | 'double' | 'shadow' | 'curved' | ... other options supported by win open
|
||||
border = "curved",
|
||||
-- width = <value>,
|
||||
-- height = <value>,
|
||||
winblend = 0,
|
||||
highlights = {
|
||||
border = "Normal",
|
||||
background = "Normal",
|
||||
},
|
||||
},
|
||||
-- Add executables on the config.lua
|
||||
-- { exec, keymap, name}
|
||||
-- lvim.builtin.terminal.execs = {{}} to overwrite
|
||||
-- lvim.builtin.terminal.execs[#lvim.builtin.terminal.execs+1] = {"gdb", "tg", "GNU Debugger"}
|
||||
-- TODO: pls add mappings in which key and refactor this
|
||||
execs = {
|
||||
{ vim.o.shell, "<M-1>", "Horizontal Terminal", "horizontal", 0.3 },
|
||||
{ vim.o.shell, "<M-2>", "Vertical Terminal", "vertical", 0.4 },
|
||||
{ vim.o.shell, "<M-3>", "Float Terminal", "float", nil },
|
||||
},
|
||||
}
|
||||
|
||||
--- Get current buffer size
|
||||
---@return {width: number, height: number}
|
||||
local function get_buf_size()
|
||||
local cbuf = vim.api.nvim_get_current_buf()
|
||||
local bufinfo = vim.tbl_filter(function(buf)
|
||||
return buf.bufnr == cbuf
|
||||
end, vim.fn.getwininfo(vim.api.nvim_get_current_win()))[1]
|
||||
if bufinfo == nil then
|
||||
return { width = -1, height = -1 }
|
||||
end
|
||||
return { width = bufinfo.width, height = bufinfo.height }
|
||||
end
|
||||
|
||||
--- Get the dynamic terminal size in cells
|
||||
---@param direction number
|
||||
---@param size integer
|
||||
---@return integer
|
||||
local function get_dynamic_terminal_size(direction, size)
|
||||
size = size or config.size
|
||||
if direction ~= "vertical" and tostring(size):find(".", 1, true) then
|
||||
size = math.min(size, 1.0)
|
||||
local buf_sizes = get_buf_size()
|
||||
local buf_size = direction == "horizontal" and buf_sizes.height or buf_sizes.width
|
||||
return buf_size * size
|
||||
else
|
||||
return size
|
||||
end
|
||||
end
|
||||
|
||||
Add_exec = function(opts)
|
||||
local binary = opts.cmd:match "(%S+)"
|
||||
if vim.fn.executable(binary) ~= 1 then
|
||||
Log:debug("Skipping configuring executable " .. binary .. ". Please make sure it is installed properly.")
|
||||
return
|
||||
end
|
||||
|
||||
vim.keymap.set({ "n", "t" }, opts.keymap, function()
|
||||
M._exec_toggle { cmd = opts.cmd, count = opts.count, direction = opts.direction, size = opts.size() }
|
||||
end, { desc = opts.label, noremap = true, silent = true })
|
||||
end
|
||||
|
||||
local terminal = require "toggleterm"
|
||||
terminal.setup(config)
|
||||
|
||||
for i, exec in pairs(config.execs) do
|
||||
local direction = exec[4] or config.direction
|
||||
|
||||
local opts = {
|
||||
cmd = exec[1],
|
||||
keymap = exec[2],
|
||||
label = exec[3],
|
||||
-- NOTE: unable to consistently bind id/count <= 9, see #2146
|
||||
count = i + 100,
|
||||
direction = direction,
|
||||
size = function()
|
||||
return get_dynamic_terminal_size(direction, exec[5])
|
||||
end,
|
||||
}
|
||||
|
||||
Add_exec(opts)
|
||||
end
|
||||
|
||||
_exec_toggle = function(opts)
|
||||
local Terminal = require("toggleterm.terminal").Terminal
|
||||
local term = Terminal:new { cmd = opts.cmd, count = opts.count, direction = opts.direction }
|
||||
term:toggle(opts.size, opts.direction)
|
||||
end
|
||||
|
||||
Lazygit_toggle = function()
|
||||
local Terminal = require("toggleterm.terminal").Terminal
|
||||
local lazygit = Terminal:new {
|
||||
cmd = "lazygit",
|
||||
hidden = true,
|
||||
direction = "float",
|
||||
float_opts = {
|
||||
border = "none",
|
||||
width = 100000,
|
||||
height = 100000,
|
||||
},
|
||||
on_open = function(_)
|
||||
vim.cmd "startinsert!"
|
||||
end,
|
||||
on_close = function(_) end,
|
||||
count = 99,
|
||||
}
|
||||
lazygit:toggle()
|
||||
end
|
||||
|
||||
18
hosts/nb/modules/development/nvim/config/theming.lua
Normal file
18
hosts/nb/modules/development/nvim/config/theming.lua
Normal file
@@ -0,0 +1,18 @@
|
||||
-- set colorscheme
|
||||
vim.cmd 'set termguicolors'
|
||||
|
||||
require("catppuccin").setup()
|
||||
|
||||
vim.cmd [[colorscheme dracula]]
|
||||
|
||||
-- enable colorizer
|
||||
require'colorizer'.setup()
|
||||
|
||||
-- set sign
|
||||
vim.cmd 'sign define DiagnosticSignError text= linehl= texthl=DiagnosticSignError numhl='
|
||||
vim.cmd 'sign define DiagnosticSignHint text= linehl= texthl=DiagnosticSignHint numhl='
|
||||
vim.cmd 'sign define DiagnosticSignInfo text= linehl= texthl=DiagnosticSignInfo numhl='
|
||||
vim.cmd 'sign define DiagnosticSignWarn text= linehl= texthl=DiagnosticSignWarn numhl='
|
||||
|
||||
-- set lightline theme to horizon
|
||||
vim.g.lightline = { colorscheme = "dracula" }
|
||||
@@ -0,0 +1,14 @@
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
textobjects = {
|
||||
select = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
-- You can use the capture groups defined in textobjects.scm
|
||||
["af"] = "@function.outer",
|
||||
["if"] = "@function.inner",
|
||||
["ac"] = "@class.outer",
|
||||
["ic"] = "@class.inner",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
30
hosts/nb/modules/development/nvim/config/treesitter.lua
Normal file
30
hosts/nb/modules/development/nvim/config/treesitter.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
require("nvim-treesitter.configs").setup({
|
||||
highlight = {
|
||||
enable = true,
|
||||
disable = {},
|
||||
},
|
||||
rainbow = {
|
||||
enable = true,
|
||||
extended_mode = true,
|
||||
},
|
||||
autotag = {
|
||||
enable = true,
|
||||
},
|
||||
context_commentstring = {
|
||||
enable = true,
|
||||
},
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = "gnn",
|
||||
node_incremental = "grn",
|
||||
scope_incremental = "grc",
|
||||
node_decremental = "grm",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- breaks highlight
|
||||
-- vim.cmd([[set foldmethod=expr]])
|
||||
-- vim.cmd([[set foldlevel=10]])
|
||||
-- vim.cmd([[set foldexpr=nvim_treesitter#foldexpr()]])
|
||||
34
hosts/nb/modules/development/nvim/config/utils.lua
Normal file
34
hosts/nb/modules/development/nvim/config/utils.lua
Normal file
@@ -0,0 +1,34 @@
|
||||
-- none-ls
|
||||
local status_ok_nls, none_ls_module = pcall(require, "none-ls")
|
||||
if not status_ok_nls then
|
||||
vim.notify("none-ls plugin not found or failed to load. Check Nix config and plugin paths.", vim.log.levels.WARN)
|
||||
else
|
||||
local nb = none_ls_module.builtins
|
||||
none_ls_module.setup({
|
||||
sources = {
|
||||
nb.formatting.alejandra,
|
||||
nb.code_actions.statix,
|
||||
nb.diagnostics.cppcheck,
|
||||
nb.diagnostics.deadnix,
|
||||
nb.diagnostics.statix,
|
||||
nb.diagnostics.eslint,
|
||||
nb.completion.spell,
|
||||
},
|
||||
debug = false, -- You can set this to true for more verbose output from none-ls
|
||||
})
|
||||
vim.notify("none-ls setup processed from utils.lua", vim.log.levels.INFO)
|
||||
end
|
||||
|
||||
require("gitsigns").setup()
|
||||
|
||||
-- autopairs
|
||||
require('nvim-autopairs').setup{}
|
||||
|
||||
require('todo-comments').setup{}
|
||||
|
||||
-- copy to system clipboard
|
||||
vim.api.nvim_set_keymap( 'v', '<Leader>y', '"+y', {noremap = true})
|
||||
vim.api.nvim_set_keymap( 'n', '<Leader>y', ':%+y<CR>', {noremap = true})
|
||||
|
||||
-- paste from system clipboard
|
||||
vim.api.nvim_set_keymap( 'n', '<Leader>p', '"+p', {noremap = true})
|
||||
148
hosts/nb/modules/development/nvim/config/which-key.lua
Normal file
148
hosts/nb/modules/development/nvim/config/which-key.lua
Normal file
@@ -0,0 +1,148 @@
|
||||
vim.g.mapleader = " "
|
||||
|
||||
local function smart_quit()
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local modified = vim.api.nvim_buf_get_option(bufnr, "modified")
|
||||
if modified then
|
||||
vim.ui.input({
|
||||
prompt = "You have unsaved changes. Quit anyway? (y/n) ",
|
||||
}, function(input)
|
||||
if input == "y" then
|
||||
vim.cmd "q!"
|
||||
end
|
||||
end)
|
||||
else
|
||||
vim.cmd "q!"
|
||||
end
|
||||
end
|
||||
|
||||
local function find_project_files()
|
||||
local _, builtin = pcall(require, "telescope.builtin")
|
||||
local ok = pcall(builtin.git_files)
|
||||
|
||||
if not ok then
|
||||
builtin.find_files()
|
||||
end
|
||||
end
|
||||
|
||||
local wk = require("which-key")
|
||||
|
||||
wk.setup({})
|
||||
|
||||
wk.register({
|
||||
["<leader>"] = {
|
||||
|
||||
[";"] = { "<cmd>Alpha<CR>", "Dashboard" },
|
||||
["w"] = { "<cmd>w!<CR>", "Save" },
|
||||
["q"] = { "<cmd>smart_quit()<CR>", "Quit" },
|
||||
["/"] = { "<Plug>(comment_toggle_linewise_current)", "Comment toggle current line" },
|
||||
["c"] = { "<cmd>BufferKill<CR>", "Close Buffer" },
|
||||
["f"] = { find_project_files, "Find File" },
|
||||
["h"] = { "<cmd>nohlsearch<CR>", "No Highlight" },
|
||||
["t"] = { "<cmd>TodoTelescope keywords=TODO,FIX<CR>", "Find TODO,FIX" },
|
||||
b = {
|
||||
name = "Buffers",
|
||||
j = { "<cmd>BufferLinePick<cr>", "Jump" },
|
||||
f = { "<cmd>Telescope buffers<cr>", "Find" },
|
||||
b = { "<cmd>BufferLineCyclePrev<cr>", "Previous" },
|
||||
n = { "<cmd>BufferLineCycleNext<cr>", "Next" },
|
||||
-- w = { "<cmd>BufferWipeout<cr>", "Wipeout" }, -- TODO: implement this for bufferline
|
||||
e = {
|
||||
"<cmd>BufferLinePickClose<cr>",
|
||||
"Pick which buffer to close",
|
||||
},
|
||||
h = { "<cmd>BufferLineCloseLeft<cr>", "Close all to the left" },
|
||||
l = {
|
||||
"<cmd>BufferLineCloseRight<cr>",
|
||||
"Close all to the right",
|
||||
},
|
||||
D = {
|
||||
"<cmd>BufferLineSortByDirectory<cr>",
|
||||
"Sort by directory",
|
||||
},
|
||||
L = {
|
||||
"<cmd>BufferLineSortByExtension<cr>",
|
||||
"Sort by language",
|
||||
},
|
||||
},
|
||||
-- " Available Debug Adapters:
|
||||
-- " https://microsoft.github.io/debug-adapter-protocol/implementors/adapters/
|
||||
-- " Adapter configuration and installation instructions:
|
||||
-- " https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation
|
||||
-- " Debug Adapter protocol:
|
||||
-- " https://microsoft.github.io/debug-adapter-protocol/
|
||||
-- " Debugging
|
||||
g = {
|
||||
name = "Git",
|
||||
g = { Lazygit_toggle, "Lazygit" },
|
||||
j = { "<cmd>lua require 'gitsigns'.next_hunk({navigation_message = false})<cr>", "Next Hunk" },
|
||||
k = { "<cmd>lua require 'gitsigns'.prev_hunk({navigation_message = false})<cr>", "Prev Hunk" },
|
||||
l = { "<cmd>lua require 'gitsigns'.blame_line()<cr>", "Blame" },
|
||||
p = { "<cmd>lua require 'gitsigns'.preview_hunk()<cr>", "Preview Hunk" },
|
||||
r = { "<cmd>lua require 'gitsigns'.reset_hunk()<cr>", "Reset Hunk" },
|
||||
R = { "<cmd>lua require 'gitsigns'.reset_buffer()<cr>", "Reset Buffer" },
|
||||
s = { "<cmd>lua require 'gitsigns'.stage_hunk()<cr>", "Stage Hunk" },
|
||||
u = {
|
||||
"<cmd>lua require 'gitsigns'.undo_stage_hunk()<cr>",
|
||||
"Undo Stage Hunk",
|
||||
},
|
||||
o = { "<cmd>Telescope git_status<cr>", "Open changed file" },
|
||||
b = { "<cmd>Telescope git_branches<cr>", "Checkout branch" },
|
||||
c = { "<cmd>Telescope git_commits<cr>", "Checkout commit" },
|
||||
C = {
|
||||
"<cmd>Telescope git_bcommits<cr>",
|
||||
"Checkout commit(for current file)",
|
||||
},
|
||||
d = {
|
||||
"<cmd>Gitsigns diffthis HEAD<cr>",
|
||||
"Git Diff",
|
||||
},
|
||||
},
|
||||
l = {
|
||||
name = "LSP",
|
||||
a = { "<cmd>lua vim.lsp.buf.code_action()<cr>", "Code Action" },
|
||||
d = { "<cmd>Telescope diagnostics bufnr=0 theme=get_ivy<cr>", "Buffer Diagnostics" },
|
||||
w = { "<cmd>Telescope diagnostics<cr>", "Diagnostics" },
|
||||
-- f = { require("lvim.lsp.utils").format, "Format" },
|
||||
i = { "<cmd>LspInfo<cr>", "Info" },
|
||||
I = { "<cmd>Mason<cr>", "Mason Info" },
|
||||
j = {
|
||||
vim.diagnostic.goto_next,
|
||||
"Next Diagnostic",
|
||||
},
|
||||
k = {
|
||||
vim.diagnostic.goto_prev,
|
||||
"Prev Diagnostic",
|
||||
},
|
||||
l = { vim.lsp.codelens.run, "CodeLens Action" },
|
||||
q = { vim.diagnostic.setloclist, "Quickfix" },
|
||||
r = { vim.lsp.buf.rename, "Rename" },
|
||||
s = { "<cmd>Telescope lsp_document_symbols<cr>", "Document Symbols" },
|
||||
S = {
|
||||
"<cmd>Telescope lsp_dynamic_workspace_symbols<cr>",
|
||||
"Workspace Symbols",
|
||||
},
|
||||
e = { "<cmd>Telescope quickfix<cr>", "Telescope Quickfix" },
|
||||
},
|
||||
|
||||
|
||||
a = { "<cmd>lua require('telescope.builtin').lsp_code_actions()<cr>", "Code Actions" },
|
||||
d = { "<cmd>lua require('telescope.builtin').lsp_document_diagnostics()<cr>", "LSP Diagnostics" },
|
||||
k = { "<cmd>lua vim.lsp.buf.signature_help()<cr>", "Signature Help" },
|
||||
P = { "<cmd>lua require'telescope'.extensions.projects.projects{}<cr>", "Signature Help" },
|
||||
}
|
||||
})
|
||||
|
||||
wk.register(
|
||||
{
|
||||
["/"] = { "<Plug>(comment_toggle_linewise_visual)", "Comment toggle linewise (visual)" },
|
||||
},
|
||||
{
|
||||
mode = "v", -- VISUAL mode
|
||||
prefix = "<leader>",
|
||||
buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings
|
||||
silent = true, -- use `silent` when creating keymaps
|
||||
noremap = true, -- use `noremap` when creating keymaps
|
||||
nowait = true, -- use `nowait` when creating keymaps
|
||||
}
|
||||
)
|
||||
115
hosts/nb/modules/development/nvim/default.nix
Normal file
115
hosts/nb/modules/development/nvim/default.nix
Normal file
@@ -0,0 +1,115 @@
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
# unstable = import (fetchTarball https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz) {
|
||||
# config = { allowUnfree = true; };
|
||||
# };
|
||||
in
|
||||
{
|
||||
environment.variables = { EDITOR = "vim"; };
|
||||
nixpkgs.overlays = [
|
||||
(import ./chatgpt.nix)
|
||||
# (import ./gitea.nix)
|
||||
];
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
nodePackages.typescript-language-server
|
||||
sumneko-lua-language-server
|
||||
nest
|
||||
nodePackages.intelephense
|
||||
nodePackages.vscode-langservers-extracted
|
||||
nodePackages.yaml-language-server
|
||||
gopls
|
||||
lazygit
|
||||
ripgrep
|
||||
lua
|
||||
luaPackages.lyaml
|
||||
aider-chat
|
||||
(neovim.override {
|
||||
vimAlias = true;
|
||||
configure = {
|
||||
packages.myPlugins = with pkgs.vimPlugins; {
|
||||
start = [
|
||||
bigfile-nvim
|
||||
bufferline-nvim
|
||||
catppuccin-nvim
|
||||
chatgpt-nvim
|
||||
# gitea-nvim
|
||||
cmp-buffer
|
||||
cmp-nvim-lsp
|
||||
cmp-path
|
||||
cmp-spell
|
||||
cmp-treesitter
|
||||
cmp-vsnip
|
||||
comment-nvim
|
||||
copilot-vim
|
||||
copilot-lua
|
||||
copilot-cmp
|
||||
# CopilotChat-nvim
|
||||
dracula-vim
|
||||
friendly-snippets
|
||||
gitsigns-nvim
|
||||
jq
|
||||
lightline-vim
|
||||
lspkind-nvim
|
||||
mini-icons
|
||||
neogit
|
||||
none-ls-nvim
|
||||
nvim-autopairs
|
||||
nvim-cmp
|
||||
nvim-colorizer-lua
|
||||
nvim-lspconfig
|
||||
nvim-tree-lua
|
||||
nvim-web-devicons
|
||||
nvim-treesitter.withAllGrammars
|
||||
nvim-treesitter-parsers.http
|
||||
# (nvim-treesitter.withPlugins (_: pkgs.tree-sitter.allGrammars))
|
||||
octo-nvim
|
||||
plenary-nvim
|
||||
project-nvim
|
||||
rainbow-delimiters-nvim
|
||||
telescope-fzf-native-nvim
|
||||
telescope-nvim
|
||||
todo-comments-nvim
|
||||
toggleterm-nvim
|
||||
vim-floaterm
|
||||
vim-sneak
|
||||
vim-vsnip
|
||||
which-key-nvim
|
||||
pkgs.vimPlugins.rest-nvim
|
||||
aider-nvim
|
||||
];
|
||||
opt = [];
|
||||
};
|
||||
customRC = let
|
||||
luaRequire = module:
|
||||
builtins.readFile (builtins.toString
|
||||
./config
|
||||
+ "/${module}.lua");
|
||||
luaConfig = builtins.concatStringsSep "\n" (map luaRequire [
|
||||
"init"
|
||||
"keymappings"
|
||||
"chatgpt"
|
||||
"copilot"
|
||||
"icons"
|
||||
"lspconfig"
|
||||
"nvim-cmp"
|
||||
"theming"
|
||||
"project"
|
||||
"telescope"
|
||||
"terminal"
|
||||
"treesitter"
|
||||
"treesitter-textobjects"
|
||||
"utils"
|
||||
"bufferline"
|
||||
"which-key"
|
||||
]);
|
||||
in ''
|
||||
lua << EOF
|
||||
${luaConfig}
|
||||
EOF
|
||||
'';
|
||||
};
|
||||
extraLuaPackages = luaPackages: [ luaPackages.lyaml ];
|
||||
}
|
||||
)];
|
||||
}
|
||||
13
hosts/nb/modules/development/nvim/gitea.nix
Normal file
13
hosts/nb/modules/development/nvim/gitea.nix
Normal file
@@ -0,0 +1,13 @@
|
||||
self: super: {
|
||||
vimPlugins = super.vimPlugins // {
|
||||
gitea-nvim = super.vimUtils.buildVimPlugin {
|
||||
pname = "gitea-nvim";
|
||||
version = "1.0.0";
|
||||
src = super.fetchgit {
|
||||
url = "https://git.cloonar.com/Cloonar/gitea.nvim.git";
|
||||
rev = "4927f0b2ec9b5c489bbffae4e58d72c0ad047590";
|
||||
sha256 = "sha256-8C8tUzOP6oy+KxyDthdYrmfoppfz+BSXrrVpVwi5X58=";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
7
hosts/nb/modules/development/nvim/nvim.nix
Normal file
7
hosts/nb/modules/development/nvim/nvim.nix
Normal file
@@ -0,0 +1,7 @@
|
||||
self: super: {
|
||||
neovim = super.neovim.override {
|
||||
luaPackages = super.luaPackages // {
|
||||
lyaml = super.luaPackages.lyaml;
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user