nvim: all in on mini.nvim

This commit is contained in:
Daniel Lundin 2024-10-06 23:00:01 +02:00
parent 890ac1e91c
commit aa228521fe
Signed by: dln
SSH key fingerprint: SHA256:dQy1Xj3UiqJYpKR5ggQ2bxgz4jCH8IF+k3AB8o0kmdI
22 changed files with 450 additions and 741 deletions

View file

@ -1,2 +0,0 @@
-- bootstrap lazy.nvim, LazyVim and your plugins
require("config.lazy")

View file

@ -1,16 +0,0 @@
-- Autocmds are automatically loaded on the VeryLazy event
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
-- Add any additional autocmds here
local function augroup(name)
return vim.api.nvim_create_augroup("lazyvim_" .. name, { clear = true })
end
-- Set comment string for CUE files
vim.api.nvim_create_autocmd("FileType", {
group = augroup("cue"),
pattern = { "cue" },
callback = function(ev)
vim.bo[ev.buf].commentstring = "// %s"
end,
})

View file

@ -1,19 +0,0 @@
-- Keymaps are automatically loaded on the VeryLazy event
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
-- Add any additional keymaps here
-- C-/ should be comment instead of lazyterm
vim.keymap.del("n", "<c-/>")
vim.keymap.set({ "n" }, "<c-/>", "gcc", { remap = true })
vim.keymap.set({ "v" }, "<c-/>", "gc", { remap = true })
vim.keymap.set({ "n" }, "<Leader><c-/>", "gcgc", { remap = true })
vim.keymap.del({ "n" }, "<c-_>")
vim.keymap.set({ "n" }, "<c-_>", "gcc", { remap = true })
vim.keymap.set({ "v" }, "<c-_>", "gc", { remap = true })
vim.keymap.set({ "n" }, "<Leader><c-_>", "gcgc", { remap = true })
vim.keymap.set("n", "<Tab>", "<Space>,", { remap = true })
vim.keymap.set("n", "zz", "zt", { remap = true })
vim.keymap.set("n", "[d", ":lua vim.diagnostic.goto_prev { float = false }<Enter>", { remap = true })
vim.keymap.set("n", "]d", ":lua vim.diagnostic.goto_next { float = false }<Enter>", { remap = true })

View file

@ -1,60 +0,0 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
-- bootstrap lazy.nvim
-- stylua: ignore
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
end
vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
require("lazy").setup({
spec = {
-- add LazyVim and import its plugins
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
-- extras
{ import = "lazyvim.plugins.extras.dap.core" },
{ import = "lazyvim.plugins.extras.editor.overseer" },
{ import = "lazyvim.plugins.extras.editor.telescope" },
{ import = "lazyvim.plugins.extras.formatting.prettier" },
{ import = "lazyvim.plugins.extras.lang.go" },
{ import = "lazyvim.plugins.extras.lang.json" },
{ import = "lazyvim.plugins.extras.lang.markdown" },
{ import = "lazyvim.plugins.extras.lang.nix" },
{ import = "lazyvim.plugins.extras.lang.rust" },
{ import = "lazyvim.plugins.extras.lang.toml" },
{ import = "lazyvim.plugins.extras.lang.typescript" },
{ import = "lazyvim.plugins.extras.lang.yaml" },
{ import = "lazyvim.plugins.extras.lsp.none-ls" },
{ import = "lazyvim.plugins.extras.test.core" },
{ import = "lazyvim.plugins.extras.ui.edgy" },
{ import = "lazyvim.plugins.extras.ui.treesitter-context" },
{ import = "lazyvim.plugins.extras.util.gitui" },
{ import = "lazyvim.plugins.extras.util.project" },
-- plugins
{ import = "plugins" },
},
defaults = {
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
lazy = false,
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
-- have outdated releases, which may break your Neovim install.
version = false, -- always use the latest git commit
-- version = "*", -- try installing the latest stable version for plugins that support semver
},
checker = { enabled = false }, -- automatically check for plugin updates
performance = {
rtp = {
-- disable some rtp plugins
disabled_plugins = {
"gzip",
-- "matchit",
-- "matchparen",
"netrwPlugin",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
},
},
})

View file

@ -1,36 +0,0 @@
vim.opt.number = true
vim.opt.relativenumber = false
vim.g.do_filetype_lua = 1
vim.g.root_spec = { { ".git", "lua" }, "lsp", "cwd" }
vim.o.autochdir = true
vim.o.fillchars = "stl: ,stlnc: ,eob:░"
vim.o.list = false
vim.o.scrolloff = 7
vim.o.splitkeep = "screen"
vim.o.updatetime = 500
vim.o.timeout = true
vim.o.timeoutlen = 0
-- additional filetypes
vim.filetype.add({
extension = {
templ = "templ",
},
})
-- AutoCommand OSC7 workaround for tmux
-- see https://github.com/neovim/neovim/issues/21771
vim.api.nvim_create_autocmd("dirchanged", {
pattern = "*",
command = 'call chansend(v:stderr, printf("\\033]7;%s\\033", v:event.cwd))',
})
-- (No) Statusline
vim.opt.laststatus = 0
vim.api.nvim_set_hl(0, "Statusline", { link = "Normal" })
vim.api.nvim_set_hl(0, "StatuslineNC", { link = "Normal" })
local line = string.rep("", vim.api.nvim_win_get_width(0))
vim.opt.statusline = "%#WinSeparator#" .. line .. "%*"

View file

@ -1,69 +0,0 @@
return {
{
"echasnovski/mini.pairs",
enabled = false,
},
{
"nvim-cmp",
dependencies = { "hrsh7th/cmp-emoji" },
opts = function(_, opts)
local cmp = require("cmp")
table.insert(opts.sources, { name = "emoji" })
opts.view = { docs = { auto_open = false }, entries = { follow_cursor = true } }
opts.completion = {
autocomplete = false,
}
local winhighlight =
"Normal:NoiceCmdlinePopupTitle,FloatBorder:NoiceCmdlinePopupBorder,CursorLine:PMenuSel,Search:Search"
opts.window = {
completion = cmp.config.window.bordered({ winhighlight = winhighlight, border = "rounded" }),
documentation = cmp.config.window.bordered({ winhighlight = winhighlight, border = "rounded" }),
preview = cmp.config.window.bordered({ winhighlight = winhighlight, border = "rounded" }),
}
-- lua sorting = { comparators = { cmp.config.compare.sort_text, -- this needs to be 1st cmp.config.compare.offset, cmp.config.compare.exact, cmp.config.compare.score, cmp.config.compare.kind, cmp.config.compare.length, cmp.config.compare.order, } }
opts.sorting = {
priority_weight = 2,
comparators = {
cmp.config.compare.exact,
cmp.config.compare.recently_used,
cmp.config.compare.locality,
cmp.config.compare.offset,
-- cmp.config.compare.scopes,
cmp.config.compare.score,
cmp.config.compare.kind,
-- cmp.config.compare.sort_text,
cmp.config.compare.length,
cmp.config.compare.order,
},
}
return opts
end,
},
{
"Exafunction/codeium.nvim",
opts = {
enable_chat = false,
},
},
{
"monkoose/neocodeium",
event = "VeryLazy",
config = function()
local neocodeium = require("neocodeium")
neocodeium.setup()
vim.keymap.set("i", "<C-j>", neocodeium.accept)
vim.keymap.set("i", "<A-f>", neocodeium.accept)
vim.keymap.set("i", "<C-h>", neocodeium.cycle_or_complete)
end,
},
}

View file

@ -1,14 +0,0 @@
return {
{
"https://patagia.dev/patagia/dieter.nvim.git",
lazy = false,
priority = 1000,
},
{
"LazyVim/LazyVim",
opts = {
colorscheme = "dieter",
},
},
}

View file

@ -1,100 +0,0 @@
return {
{
"folke/flash.nvim",
enabled = false,
},
{
"telescope.nvim",
keys = {
{
"<Leader><Leader>",
function()
local telescope = require("telescope")
local jj_pick_status, jj_res = pcall(telescope.extensions.jj.files, opts)
if jj_pick_status then
return
end
local git_files_status, git_res = pcall(telescope.builtin.git_files, opts)
if not git_files_status then
error("Could not launch jj/git files: \n" .. jj_res .. "\n" .. git_res)
end
end,
desc = "VCS Files",
},
{
"<C-p>",
"<cmd>Telescope projects<cr>",
desc = "Projects",
},
},
opts = function(_, opts)
local actions = require("telescope.actions")
opts.defaults = {
layout_strategy = "horizontal",
layout_config = {
anchor = "top",
horizontal = {
prompt_position = "top",
mirror = false,
preview_width = 0.49,
-- preview_height = 0.5,
},
width = 0.99,
height = 0.9,
preview_cutoff = 10,
},
mappings = {
i = {
["<esc>"] = actions.close, -- <Esc> close popup
["<C-u>"] = false, -- <C-u> clear prompt
["<C-w>"] = false, -- <C-u> clear prompt
},
},
path_display = { "filename_first" },
-- previewer = false,
preview = {
-- hide_on_startup = true,
},
sorting_strategy = "ascending",
winblend = 0,
wrap_results = true,
}
end,
},
{ "avm99963/vim-jjdescription", lazy = false },
{
"zschreur/telescope-jj.nvim",
keys = {
{
"<Leader>jc",
function()
require("telescope").extensions.jj.conflicts()
end,
desc = "jj conflicts",
},
{
"<Leader>jd",
function()
require("telescope").extensions.jj.diff()
end,
desc = "jj diffs",
},
{
"<Leader>jf",
function()
require("telescope").extensions.jj.files()
end,
desc = "jj files",
},
},
config = function()
LazyVim.on_load("telescope.nvim", function()
local telescope = require("telescope")
telescope.load_extension("jj")
end)
end,
},
}

View file

@ -1,99 +0,0 @@
return {
{
"direnv/direnv.vim",
lazy = false,
priority = 900,
config = function()
vim.g.direnv_silent_load = 1
end,
},
{
"nvimtools/none-ls.nvim",
opts = function(_, opts)
local nls = require("null-ls")
opts.root_dir = opts.root_dir
or require("null-ls.utils").root_pattern(".null-ls-root", ".neoconf.json", "Makefile", ".git")
opts.sources = vim.list_extend(opts.sources or {}, {
nls.builtins.formatting.mdformat,
nls.builtins.formatting.stylua,
nls.builtins.formatting.shfmt,
nls.builtins.formatting.buf,
nls.builtins.formatting.buildifier,
nls.builtins.diagnostics.buildifier,
nls.builtins.diagnostics.buf.with({
args = { "lint", "--disable-symlinks", "--path", "$FILENAME" },
cwd = function()
local file_dir = vim.fn.expand("%:p:h") .. ";"
local buf_yaml = vim.fn.findfile("buf.yaml", file_dir)
if buf_yaml then
return vim.fn.fnamemodify(buf_yaml, ":h")
end
end,
}),
})
end,
},
{
"nvim-neo-tree/neo-tree.nvim",
opts = {
window = {
width = 30,
position = "right",
},
},
},
{
"simrat39/rust-tools.nvim",
enabled = false,
},
{
"mrcjkb/rustaceanvim",
version = "^4", -- Recommended
ft = { "rust" },
opts = {
server = {
on_attach = function(_, bufnr)
vim.keymap.set("n", "<leader>cR", function()
vim.cmd.RustLsp("codeAction")
end, { desc = "Code Action", buffer = bufnr })
vim.keymap.set("n", "<leader>dr", function()
vim.cmd.RustLsp("debuggables")
end, { desc = "Rust debuggables", buffer = bufnr })
vim.keymap.set("n", "<leader>cD", function()
vim.cmd.RustLsp("externalDocs")
end, { desc = "Rust external documentation", buffer = bufnr })
end,
},
settings = {
-- rust-analyzer language server configuration
["rust-analyzer"] = {
cargo = {
allFeatures = true,
loadOutDirsFromCheck = true,
runBuildScripts = true,
targetDir = true,
},
-- Add clippy lints for Rust.
checkOnSave = {
allFeatures = true,
command = "clippy",
extraArgs = { "--no-deps" },
},
procMacro = {
enable = true,
ignored = {
["async-trait"] = { "async_trait" },
["napi-derive"] = { "napi" },
["async-recursion"] = { "async_recursion" },
},
},
},
},
},
},
}

View file

@ -1,15 +0,0 @@
return {
{
"stevearc/conform.nvim",
opts = {
formatters_by_ft = {
["cue"] = { { "cue_fmt" } },
["html"] = { { "prettierd", "prettier" } },
["nix"] = { "nixfmt" },
["sass"] = { { "prettierd", "prettier" } },
["proto"] = { { "buf" } },
["terraform"] = { { "terraform_fmt" } },
},
},
},
}

View file

@ -1,72 +0,0 @@
return {
"b0o/incline.nvim",
config = function()
local devicons = require("nvim-web-devicons")
require("incline").setup({
window = {
margin = {
horizontal = 0,
vertical = 0,
},
padding = 0,
placement = {
horizontal = "right",
vertical = "bottom",
},
},
render = function(props)
local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ":t")
if filename == "" then
filename = "[No Name]"
end
local ft_icon, ft_color = devicons.get_icon_color(filename)
local function get_git_diff()
local icons = { removed = "", changed = "", added = "" }
local signs = vim.b[props.buf].gitsigns_status_dict
local labels = {}
if signs == nil then
return labels
end
for name, icon in pairs(icons) do
if tonumber(signs[name]) and signs[name] > 0 then
table.insert(labels, { icon .. signs[name] .. " ", group = "Diff" .. name })
end
end
if #labels > 0 then
table.insert(labels, { "" })
end
return labels
end
local function get_diagnostic_label()
local icons = { error = "", warn = "", info = "", hint = "" }
local label = {}
for severity, icon in pairs(icons) do
local n = #vim.diagnostic.get(
props.buf,
{ severity = vim.diagnostic.severity[string.upper(severity)] }
)
if n > 0 then
table.insert(label, { icon .. n .. " ", group = "DiagnosticSign" .. severity })
end
end
if #label > 0 then
table.insert(label, { "" })
end
return label
end
return {
{ " " },
{ get_diagnostic_label() },
{ get_git_diff() },
{ filename, group = "Label" },
{ " " },
}
end,
})
end,
event = "VeryLazy",
}

View file

@ -1,35 +0,0 @@
return {
{
"neovim/nvim-lspconfig",
opts = {
diagnostics = {
virtual_text = false,
},
inlay_hints = { enabled = false },
-- codelens = {
-- enabled = true,
-- },
servers = {
nil_ls = {},
nixd = {},
starpls = {},
yamlls = {
settings = {
yaml = {
schemas = {
-- kubernetes = "*.yaml",
["http://json.schemastore.org/github-workflow"] = ".github/workflows/*",
["http://json.schemastore.org/github-action"] = ".github/action.{yml,yaml}",
["http://json.schemastore.org/ansible-stable-2.9"] = "roles/tasks/*.{yml,yaml}",
["http://json.schemastore.org/chart"] = "Chart.{yml,yaml}",
["https://json.schemastore.org/dependabot-v2"] = ".github/dependabot.{yml,yaml}",
["https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json"] = "*api*.{yml,yaml}",
["https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.29.1/all.json"] = "/*.yaml",
},
},
},
},
},
},
},
}

View file

@ -1,41 +0,0 @@
return {
{
"nvim-treesitter/nvim-treesitter-context",
opts = {
enable = false,
},
},
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
vim.list_extend(opts.ensure_installed, {
"bash",
"c",
"diff",
"go",
"html",
"javascript",
"jsdoc",
"json",
"jsonc",
"lua",
"luadoc",
"luap",
"markdown",
"markdown_inline",
"python",
"query",
"regex",
"rust",
"toml",
"tsx",
"typescript",
"vim",
"vimdoc",
"xml",
"yaml",
})
end,
},
}

View file

@ -1,130 +0,0 @@
return {
{
"nvimdev/dashboard-nvim",
enabled = false,
},
{
"dgagn/diagflow.nvim",
-- event = 'LspAttach', This is what I use personnally and it works great
opts = {
scope = "line",
gap_size = 0,
max_width = 50,
max_height = 20,
show_borders = true,
toggle_event = { "InsertEnter", "InsertLeave" },
},
},
{
"akinsho/bufferline.nvim",
enabled = false,
},
{
"echasnovski/mini.indentscope",
enabled = false,
},
{
"lukas-reineke/indent-blankline.nvim",
enabled = false,
},
{ "nvimdev/indentmini.nvim", opts = { char = "" } },
{
"mvllow/modes.nvim",
opts = {
colors = {
copy = "#f5c359",
delete = "#c75c6a",
insert = "#ffcc00",
visual = "#c343fc",
},
set_cursor = true,
set_cursorline = true,
set_number = true,
},
},
{
"folke/noice.nvim",
event = "VeryLazy",
keys = {
{ "<leader>sna", "<cmd>NoiceTelescope<cr>", desc = "Show all messages in Telescope" },
},
opts = function()
local enable_conceal = true -- Hide command text if true
return {
presets = { bottom_search = true }, -- The kind of popup used for /
cmdline = {
view = "cmdline", -- The kind of popup used for :
format = {
cmdline = { conceal = enable_conceal },
search_down = { conceal = enable_conceal },
search_up = { conceal = enable_conceal },
filter = { conceal = enable_conceal },
lua = { conceal = enable_conceal },
help = { conceal = enable_conceal },
input = { conceal = enable_conceal },
},
},
messages = { enabled = true, view = "mini" },
lsp = {
hover = { enabled = false },
signature = { enabled = false },
progress = { enabled = true, view = "cmdline" },
message = { enabled = false },
smart_move = { enabled = false },
},
}
end,
},
{
"rcarriga/nvim-notify",
opts = {
timeout = 1000,
render = "wrapped-compact",
top_down = false,
max_width = function()
return math.floor(vim.o.columns * 0.5)
end,
on_open = function(win)
vim.api.nvim_win_set_config(win, {
focusable = false,
zindex = 100,
})
end,
},
},
{
"nvim-lualine/lualine.nvim",
enabled = false,
},
{
"DrKJeff16/project.nvim",
config = function(_, opts)
if vim.fn.argv()[1] == nil then
require("project_nvim").setup(opts) -- Workaround for project.nvim not setting up
vim.schedule(function()
vim.cmd("Telescope projects")
end)
end
end,
opts = {
exclude_dirs = {
"~/.cargo/*",
"~/.config/*",
"/tmp/*",
},
manual_mode = false,
patterns = { ".git", ".jj" },
},
},
}

View file

@ -29,11 +29,11 @@
"zig": "zig" "zig": "zig"
}, },
"locked": { "locked": {
"lastModified": 1729600492, "lastModified": 1730776162,
"narHash": "sha256-lQ1oSHfNRvveB9YEMetEFl6a8Tpb6cQkMtSQKAYBLMQ=", "narHash": "sha256-ODmmTWz3jqaPmJ1UiJgHD3oy90BTEd871GZHyT5Xn9M=",
"ref": "refs/heads/main", "ref": "refs/heads/main",
"rev": "5e001fcb64deeee69b92a03a51d05a21b09153bd", "rev": "f9199a46118f173ac7a005130f871fdf050f94d1",
"revCount": 7763, "revCount": 7881,
"type": "git", "type": "git",
"url": "ssh://git@github.com/ghostty-org/ghostty" "url": "ssh://git@github.com/ghostty-org/ghostty"
}, },
@ -64,11 +64,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1729551526, "lastModified": 1730633670,
"narHash": "sha256-7LAGY32Xl14OVQp3y6M43/0AtHYYvV6pdyBcp3eoz0s=", "narHash": "sha256-ZFJqIXpvVKvzOVFKWNRDyIyAo+GYdmEPaYi1bZB6uf0=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "5ec753a1fc4454df9285d8b3ec0809234defb975", "rev": "8f6ca7855d409aeebe2a582c6fd6b6a8d0bf5661",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -79,11 +79,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1729413321, "lastModified": 1730531603,
"narHash": "sha256-I4tuhRpZFa6Fu6dcH9Dlo5LlH17peT79vx1y1SpeKt0=", "narHash": "sha256-Dqg6si5CqIzm87sp57j5nTaeBbWhHFaVyG7V6L8k3lY=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "1997e4aa514312c1af7e2bda7fad1644e778ff26", "rev": "7ffd9ae656aec493492b44d0ddfb28e79a1ea25d",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -95,11 +95,11 @@
}, },
"nixpkgs-stable": { "nixpkgs-stable": {
"locked": { "locked": {
"lastModified": 1729449015, "lastModified": 1730741070,
"narHash": "sha256-Gf04dXB0n4q0A9G5nTGH3zuMGr6jtJppqdeljxua1fo=", "narHash": "sha256-edm8WG19kWozJ/GqyYx2VjW99EdhjKwbY3ZwdlPAAlo=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "89172919243df199fe237ba0f776c3e3e3d72367", "rev": "d063c1dd113c91ab27959ba540c0d9753409edf3",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -9,7 +9,7 @@
./gnome.nix ./gnome.nix
./k8s.nix ./k8s.nix
./nix.nix ./nix.nix
./nvim.nix ./nvim
./scripts.nix ./scripts.nix
./ssh.nix ./ssh.nix
./tmux.nix ./tmux.nix

View file

@ -1,19 +0,0 @@
{ ... }:
{
programs.neovim = {
enable = true;
defaultEditor = true;
viAlias = true;
vimAlias = true;
withNodeJs = false;
withPython3 = false;
withRuby = false;
};
xdg.configFile = {
"nvim" = {
recursive = true;
source = ./../../files/config/nvim;
};
};
}

View file

@ -0,0 +1,119 @@
{ lib, pkgs, ... }:
{
programs.neovim = {
enable = true;
defaultEditor = true;
viAlias = true;
vimAlias = true;
withNodeJs = false;
withPython3 = false;
withRuby = false;
extraLuaConfig = lib.fileContents ./init.lua;
extraPackages = with pkgs; [
black
cue
go
gopls
gotools
lua-language-server
nil
nixd
nodePackages.prettier
nodePackages.typescript
nodePackages.typescript-language-server
nodePackages.bash-language-server
rust-analyzer
shellcheck
shfmt
stylua
tree-sitter
tree-sitter-grammars.tree-sitter-bash
tree-sitter-grammars.tree-sitter-yaml
tree-sitter-grammars.tree-sitter-go
tree-sitter-grammars.tree-sitter-markdown
tree-sitter-grammars.tree-sitter-lua
tree-sitter-grammars.tree-sitter-html
tree-sitter-grammars.tree-sitter-vim
tree-sitter-grammars.tree-sitter-nix
vscode-langservers-extracted
];
plugins = with pkgs.vimPlugins; [
go-nvim
rustaceanvim
targets-vim
{
plugin = pkgs.vimUtils.buildVimPlugin {
name = "dieter-nvim";
src = pkgs.fetchgit {
url = "https://patagia.dev/Patagia/dieter.nvim.git";
rev = "08fae6ffec4ae70ba6b2e1cafa780ff317ef0b61";
hash = "sha256-C+Vo2SUVfNMkBwuLWqLoA59Pmy9aFwur7fBpfVkLm6Q=";
};
};
type = "lua";
config = ''
vim.cmd.colorscheme "dieter"
'';
}
{
plugin = nvim-treesitter.withAllGrammars; # Treesitter
type = "lua";
config = ''
require'nvim-treesitter.configs'.setup {
highlight = { enable = true, },
indent = { enable = true },
}
'';
}
{
plugin = pkgs.vimUtils.buildVimPlugin {
name = "nvim-tree-pairs"; # make % match in TS
src = pkgs.fetchFromGitHub {
owner = "yorickpeterse";
repo = "nvim-tree-pairs";
rev = "e7f7b6cc28dda6f3fa271ce63b0d371d5b7641da";
hash = "sha256-fb4EsrWAbm8+dWAhiirCPuR44MEg+KYb9hZOIuEuT24=";
};
};
type = "lua";
config = "require('tree-pairs').setup()";
}
{
plugin = nvim-treesitter-textobjects; # helix-style selection of TS tree
type = "lua";
config = ''
require'nvim-treesitter.configs'.setup {
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<M-o>",
scope_incremental = "<M-O>",
node_incremental = "<M-o>",
node_decremental = "<M-i>",
},
},
}
'';
}
{
plugin = mini-nvim;
type = "lua";
config = lib.fileContents ./mini.lua;
}
{
plugin = nvim-lspconfig; # Interface for LSPs
type = "lua";
config = lib.fileContents ./lsp.lua;
}
];
};
}

93
home/common/nvim/init.lua Normal file
View file

@ -0,0 +1,93 @@
-- vim.g.mapleader = "<space>"
vim.g.maplocalleader = ','
-- UI
vim.opt.cursorline = true
vim.opt.laststatus = 0
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.ruler = true
vim.opt.rulerformat = "" -- FIXME: fancify!
vim.opt.rulerformat = "%36(%5l,%-6(%c%V%) %t%)%*"
vim.opt.syntax = "on"
vim.opt.termguicolors = true
-- Search
vim.opt.ignorecase = true
vim.opt.smartcase = true
-- Tab completion
-- vim.opt.wildmode="list:longest,full"
vim.opt.wildignore="*.swp,*.o,*.so,*.exe,*.dll"
-- Whitespaces
vim.opt.breakindent = true
vim.opt.copyindent = true
vim.opt.expandtab = true
vim.opt.softtabstop = 2
vim.opt.shiftround = true
vim.opt.shiftwidth = 2
vim.opt.smartindent = true
vim.opt.tabstop = 2
vim.opt.wrap = false
vim.opt.list = true
vim.opt.listchars="tab:»·,trail:·"
-- Folds
vim.opt.foldenable = false
vim.opt.foldtext = "v:lua.vim.treesitter.foldtext()"
vim.opt.foldmethod = "expr"
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
--
vim.o.autochdir = true
vim.o.fillchars = "stl: ,stlnc: ,eob:░,vert:│"
vim.o.list = false
vim.o.scrolloff = 7
vim.o.splitkeep = "screen"
vim.o.updatetime = 50
vim.o.timeout = true
vim.o.timeoutlen = 10
vim.o.icm = "split"
-- vim.o.cia = 'kind,abbr,menu' wait for nightly to drop
vim.o.showmode = false
-- Use rg
vim.o.grepprg = [[rg --glob "!.jj" --glob "!.git" --no-heading --vimgrep --follow $*]]
vim.opt.grepformat = vim.opt.grepformat ^ { "%f:%l:%c:%m" }
vim.fn.sign_define(
"DiagnosticSignError",
{ text = "", hl = "DiagnosticSignError", texthl = "DiagnosticSignError", culhl = "DiagnosticSignErrorLine" }
)
vim.fn.sign_define(
"DiagnosticSignWarn",
{ text = "", hl = "DiagnosticSignWarn", texthl = "DiagnosticSignWarn", culhl = "DiagnosticSignWarnLine" }
)
vim.fn.sign_define(
"DiagnosticSignInfo",
{ text = "", hl = "DiagnosticSignInfo", texthl = "DiagnosticSignInfo", culhl = "DiagnosticSignInfoLine" }
)
vim.fn.sign_define(
"DiagnosticSignHint",
{ text = "", hl = "DiagnosticSignHint", texthl = "DiagnosticSignHint", culhl = "DiagnosticSignHintLine" }
)
-- Make <Tab> work for snippets
vim.keymap.set({ "i", "s" }, "<Tab>", function()
if vim.snippet.active({ direction = 1 }) then
return "<cmd>lua vim.snippet.jump(1)<cr>"
else
return "<Tab>"
end
end, { expr = true })
vim.keymap.set({ "n" }, "<c-/>", "gcc", { remap = true })
vim.keymap.set({ "v" }, "<c-/>", "gc", { remap = true })
vim.keymap.set({ "n" }, "<c-_>", "gcc", { remap = true })
vim.keymap.set({ "v" }, "<c-_>", "gc", { remap = true })
vim.keymap.set("n", "zz", "zt", { remap = true })

92
home/common/nvim/lsp.lua Normal file
View file

@ -0,0 +1,92 @@
vim.keymap.set("n", "<space>d", vim.diagnostic.setloclist, { desc = "Add buffer diagnostics to the location list." })
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(ev)
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc"
-- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = function(str)
return { buffer = ev.buf, desc = str }
end
local client = vim.lsp.get_client_by_id(ev.data.client_id)
if client.server_capabilities.codeLensProvider then
vim.lsp.codelens.refresh({ bufnr = bufnr })
end
vim.keymap.set("n", "K", vim.lsp.buf.hover, {})
vim.keymap.set("n", "gd", vim.lsp.buf.definition, {})
vim.keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, {})
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts("Declaration"))
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts("Definition"))
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts("Implementation"))
vim.keymap.set("n", "<M-k>", vim.lsp.buf.signature_help, opts("Signature Help"))
vim.keymap.set("i", "<M-k>", vim.lsp.buf.signature_help, opts("Signature Help"))
vim.keymap.set("n", "<space>wa", vim.lsp.buf.add_workspace_folder, opts("Add Workspace Folder"))
vim.keymap.set("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, opts("Remove Workspace Folder"))
vim.keymap.set("n", "<space>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts("List Workspace Folders"))
vim.keymap.set("n", "<space>D", vim.lsp.buf.type_definition, opts("Type Definition"))
vim.keymap.set("n", "<space>r", vim.lsp.buf.rename, opts("Rename Symbol"))
vim.keymap.set({ "n", "v" }, "<space>a", vim.lsp.buf.code_action, opts("Code Action"))
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts("Buffer References"))
vim.keymap.set("n", "<localleader>f", function()
vim.lsp.buf.format({ async = true })
end, opts("Format Buffer"))
end,
})
local configs = require('lspconfig.configs')
local lspconfig = require("lspconfig")
local capabilities = vim.lsp.protocol.make_client_capabilities()
local servers = {
'gopls',
'nil_ls',
'ts_ls',
}
for _, ls in ipairs(servers) do
lspconfig[ls].setup {
capabilities = capabilities,
on_attach = function(_, buf)
vim.api.nvim_set_option_value('omnifunc', 'v:lua.MiniCompletion.completefunc_lsp', {buf = buf})
end,
}
end
lspconfig.nixd.setup({
capabilities = capabilities,
cmd = { "nixd" },
settings = {
nixd = {
nixpkgs = { expr = "import <nixpkgs> { }" },
formatting = { command = { "nixfmt" } },
options = {},
},
},
})
lspconfig.lua_ls.setup({
capabilities = capabilities,
settings = {
Lua = {
runtime = {
version = "LuaJIT",
path = vim.split(package.path, ";"),
},
diagnostics = { globals = { "vim", "hs" } },
workspace = {
library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
[vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true,
},
},
},
},
})

130
home/common/nvim/mini.lua Normal file
View file

@ -0,0 +1,130 @@
local opts = function(label)
return {noremap = true, silent = true, desc = label}
end
require('mini.ai').setup()
require('mini.align').setup()
require('mini.bracketed').setup()
require('mini.completion').setup()
require('mini.diff').setup()
require('mini.extra').setup()
require('mini.icons').setup()
require('mini.jump').setup()
-- require('mini.pairs').setup()
-- require('mini.statusline').setup()
require('mini.surround').setup()
require('mini.splitjoin').setup()
require('mini.files').setup()
local oil_style = function()
if not MiniFiles.close() then
MiniFiles.open(vim.api.nvim_buf_get_name(0))
MiniFiles.reveal_cwd()
end
end
vim.keymap.set('n', '-', oil_style, opts("File Explorer"));
local hipatterns = require('mini.hipatterns')
hipatterns.setup({ -- highlight strings and colors
highlighters = {
-- Highlight standalone 'FIXME', 'HACK', 'TODO', 'NOTE'
fixme = { pattern = '%f[%w]()FIXME()%f[%W]', group = 'MiniHipatternsFixme' },
hack = { pattern = '%f[%w]()HACK()%f[%W]', group = 'MiniHipatternsHack' },
todo = { pattern = '%f[%w]()TODO()%f[%W]', group = 'MiniHipatternsTodo' },
note = { pattern = '%f[%w]()NOTE()%f[%W]', group = 'MiniHipatternsNote' },
-- Highlight hex color strings (`#rrggbb`) using that color
hex_color = hipatterns.gen_highlighter.hex_color(),
}
})
require('mini.jump2d').setup({
mappings = {
start_jumping = 'gw'
}
})
require('mini.pick').setup({
mappings = {
move_down = '<tab>'
},
options = {
use_cache = true
}
})
MiniPick.registry.files_root = function(local_opts)
local root_patterns = { ".jj", ".git" }
local root_dir = vim.fs.dirname(vim.fs.find(root_patterns, { upward = true })[1])
local opts = { source = { cwd = root_dir, tool = "ripgrep"} }
local_opts.cwd = root_dir
local_opts.tool = "rg"
return MiniPick.builtin.files(local_opts, opts)
end
MiniPick.registry.grep_live_root = function(local_opts)
local root_patterns = { ".jj", ".git" }
local root_dir = vim.fs.dirname(vim.fs.find(root_patterns, { upward = true })[1])
local opts = { source = { cwd = root_dir } }
local_opts.cwd = root_dir
return MiniPick.builtin.grep_live(local_opts, opts)
end
vim.keymap.set('n', '<space>/', "<cmd>Pick grep_live_root<cr>", opts("Live Grep"))
vim.keymap.set('n', '<space>F', "<cmd>Pick files<cr>", opts("Find Files in CWD"))
vim.keymap.set('n', '<space>ff', "<cmd>Pick files_root<cr>", opts("Find Files"))
vim.keymap.set('n', '<space>fr', "<cmd>Pick oldfiles<cr>", opts("Recent Files"))
vim.keymap.set('n', '<space>b', "<cmd>Pick buffers<cr>", opts("Buffers"))
vim.keymap.set('n', '<space>d', "<cmd>Pick diagnostics<cr>", opts("Diagnostics"))
vim.keymap.set('n', '<tab>', "<cmd>Pick buffers include_current=false<cr>", opts("Buffers"))
vim.keymap.set('n', "<space>'", "<cmd>Pick resume<cr>", opts("Last Picker"))
vim.keymap.set('n', "<space>g", "<cmd>Pick git_commits<cr>", opts("Git Commits"))
local miniclue = require('mini.clue')
miniclue.setup({ -- cute prompts about bindings
triggers = {
{ mode = 'n', keys = '<Leader>' },
{ mode = 'x', keys = '<Leader>' },
{ mode = 'n', keys = '<space>' },
{ mode = 'x', keys = '<space>' },
-- Built-in completion
{ mode = 'i', keys = '<C-x>' },
-- `g` key
{ mode = 'n', keys = 'g' },
{ mode = 'x', keys = 'g' },
-- Marks
{ mode = 'n', keys = "'" },
{ mode = 'n', keys = '`' },
{ mode = 'x', keys = "'" },
{ mode = 'x', keys = '`' },
-- Registers
{ mode = 'n', keys = '"' },
{ mode = 'x', keys = '"' },
{ mode = 'i', keys = '<C-r>' },
{ mode = 'c', keys = '<C-r>' },
-- Window commands
{ mode = 'n', keys = '<C-w>' },
-- `z` key
{ mode = 'n', keys = 'z' },
{ mode = 'x', keys = 'z' },
-- Bracketed
{ mode = 'n', keys = '[' },
{ mode = 'n', keys = ']' },
},
clues = {
miniclue.gen_clues.builtin_completion(),
miniclue.gen_clues.g(),
miniclue.gen_clues.marks(),
miniclue.gen_clues.registers(),
miniclue.gen_clues.windows(),
miniclue.gen_clues.z(),
},
window = {
delay = 15,
}
})

View file

@ -55,6 +55,8 @@
arguments = [ arguments = [
"--glob=!.git/*" "--glob=!.git/*"
"--glob=!.jj/*" "--glob=!.jj/*"
"--glob=!result/*"
"--glob=!target/*"
]; ];
}; };