[fix] fmt: change formatter to nixfmt-rfc-style

Alejandra has ads and splits files into too many new lines.
This commit is contained in:
Jalil David Salamé Messina 2024-07-03 23:58:26 +02:00
parent 711c1aa81d
commit 91284a73ca
Signed by: jalil
GPG key ID: F016B9E770737A0B
28 changed files with 800 additions and 742 deletions

View file

@ -1,11 +1,13 @@
{helpers, ...}: let
{ helpers, ... }:
let
inherit (helpers) mkRaw;
in {
in
{
config = {
autoGroups = {
"highlightOnYank" = {};
"lspConfig" = {};
"restoreCursorPosition" = {};
"highlightOnYank" = { };
"lspConfig" = { };
"restoreCursorPosition" = { };
};
autoCmd = [
{
@ -14,19 +16,17 @@ in {
pattern = "*";
callback =
mkRaw
/*
lua
*/
''
function()
vim.highlight.on_yank {
higroup = (
vim.fn['hlexists'] 'HighlightedyankRegion' > 0 and 'HighlightedyankRegion' or 'IncSearch'
),
timeout = 200,
}
end
'';
# lua
''
function()
vim.highlight.on_yank {
higroup = (
vim.fn['hlexists'] 'HighlightedyankRegion' > 0 and 'HighlightedyankRegion' or 'IncSearch'
),
timeout = 200,
}
end
'';
}
{
group = "restoreCursorPosition";
@ -34,69 +34,66 @@ in {
pattern = "*";
callback =
mkRaw
/*
lua
*/
''
function()
if vim.fn.line '\'"' > 0 and vim.fn.line '\'"' <= vim.fn.line '$' then
vim.cmd [[execute "normal! g'\""]]
# lua
''
function()
if vim.fn.line '\'"' > 0 and vim.fn.line '\'"' <= vim.fn.line '$' then
vim.cmd [[execute "normal! g'\""]]
end
end
end
'';
'';
}
{
group = "lspConfig";
event = "LspAttach";
pattern = "*";
callback = let
opts = "noremap = true, buffer = bufnr";
in
callback =
let
opts = "noremap = true, buffer = bufnr";
in
mkRaw
/*
lua
*/
''
function(opts)
local bufnr = opts.buf
local client = vim.lsp.get_client_by_id(opts.data.client_id)
local capabilities = client.server_capabilities
-- Set Omnifunc if supported
if capabilities.completionProvider then
vim.bo[bufnr].omnifunc = "v:lua.vim.lsp.omnifunc"
# lua
''
function(opts)
local bufnr = opts.buf
local client = vim.lsp.get_client_by_id(opts.data.client_id)
local capabilities = client.server_capabilities
-- Set Omnifunc if supported
if capabilities.completionProvider then
vim.bo[bufnr].omnifunc = "v:lua.vim.lsp.omnifunc"
end
-- Enable inlay hints if supported
if capabilities.inlayHintProvider then
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
end
-- Some Lsp servers do not advertise inlay hints properly so enable this keybinding regardless
vim.keymap.set('n', '<space>ht', function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({bufnr = 0}), { bufnr = 0 })
end,
{ desc = '[H]ints [T]oggle', ${opts} }
)
-- Enable hover if supported
if capabilities.hoverProvider then
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { desc = 'Hover Documentation', ${opts} })
end
-- Enable rename if supported
if capabilities.renameProvider then
vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename, { desc = '[R]ename', ${opts} })
end
-- Enable code actions if supported
if capabilities.codeActionProvider then
vim.keymap.set({ 'n', 'v' }, '<leader>fa', vim.lsp.buf.code_action, { desc = '[F]ind Code [A]ctions', ${opts} })
end
-- Enable formatting if supported
if capabilities.documentFormattingProvider then
vim.keymap.set('n', '<leader>w', function() require("conform").format({ lsp_fallback = true }) end, { desc = 'Format Buffer', ${opts} })
end
-- Other keybinds
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { desc = '[G]o to [D]efinition', ${opts} })
vim.keymap.set('n', 'gt', vim.lsp.buf.type_definition, { desc = '[G]o to [T]ype Definition', ${opts} })
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, { desc = '[G]o to [I]mplementation', ${opts} })
end
-- Enable inlay hints if supported
if capabilities.inlayHintProvider then
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
end
-- Some Lsp servers do not advertise inlay hints properly so enable this keybinding regardless
vim.keymap.set('n', '<space>ht', function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({bufnr = 0}), { bufnr = 0 })
end,
{ desc = '[H]ints [T]oggle', ${opts} }
)
-- Enable hover if supported
if capabilities.hoverProvider then
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { desc = 'Hover Documentation', ${opts} })
end
-- Enable rename if supported
if capabilities.renameProvider then
vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename, { desc = '[R]ename', ${opts} })
end
-- Enable code actions if supported
if capabilities.codeActionProvider then
vim.keymap.set({ 'n', 'v' }, '<leader>fa', vim.lsp.buf.code_action, { desc = '[F]ind Code [A]ctions', ${opts} })
end
-- Enable formatting if supported
if capabilities.documentFormattingProvider then
vim.keymap.set('n', '<leader>w', function() require("conform").format({ lsp_fallback = true }) end, { desc = 'Format Buffer', ${opts} })
end
-- Other keybinds
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { desc = '[G]o to [D]efinition', ${opts} })
vim.keymap.set('n', 'gt', vim.lsp.buf.type_definition, { desc = '[G]o to [T]ype Definition', ${opts} })
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, { desc = '[G]o to [I]mplementation', ${opts} })
end
'';
'';
}
];
};

View file

@ -1,11 +1,9 @@
{
lib,
config,
...
}: let
{ lib, config, ... }:
let
cfg = config.jhome.nvim;
in {
imports = [./options.nix];
in
{
imports = [ ./options.nix ];
config.programs.nixvim = lib.mkMerge [
./standalone.nix

View file

@ -1,4 +1,5 @@
{pkgs}: {
vim-jjdescription = pkgs.callPackage ./vim-jjdescription.nix {};
nvim-silicon = pkgs.callPackage ./nvim-silicon.nix {};
{ pkgs }:
{
vim-jjdescription = pkgs.callPackage ./vim-jjdescription.nix { };
nvim-silicon = pkgs.callPackage ./nvim-silicon.nix { };
}

View file

@ -1,7 +1,4 @@
{
vimUtils,
fetchFromGitHub,
}:
{ vimUtils, fetchFromGitHub }:
vimUtils.buildVimPlugin {
name = "nvim-silicon";
src = fetchFromGitHub {

View file

@ -1,7 +1,4 @@
{
vimUtils,
fetchFromGitHub,
}:
{ vimUtils, fetchFromGitHub }:
vimUtils.buildVimPlugin {
name = "jjdescription";
src = fetchFromGitHub {

View file

@ -1,6 +1,8 @@
{helpers, ...}: let
{ helpers, ... }:
let
inherit (helpers) mkRaw;
in {
in
{
config.keymaps = [
# Quickfix
{
@ -53,10 +55,10 @@ in {
key = "<leader>dj";
action =
mkRaw
# lua
''
vim.diagnostic.goto_next
'';
# lua
''
vim.diagnostic.goto_next
'';
options.desc = "Diagnostics next [J]";
}
{
@ -64,10 +66,10 @@ in {
key = "<leader>dk";
action =
mkRaw
# lua
''
vim.diagnostic.goto_prev
'';
# lua
''
vim.diagnostic.goto_prev
'';
options.desc = "Diagnostics previous [K]";
}
{
@ -75,10 +77,10 @@ in {
key = "<leader>xx";
action =
mkRaw
# lua
''
require('trouble').toggle
'';
# lua
''
require('trouble').toggle
'';
options.desc = "Toggle trouble";
}
{
@ -86,10 +88,10 @@ in {
key = "<leader>xw";
action =
mkRaw
# lua
''
function() require('trouble').toggle('workspace_diagnostics') end
'';
# lua
''
function() require('trouble').toggle('workspace_diagnostics') end
'';
options.desc = "Toggle Workspace trouble";
}
{
@ -97,10 +99,10 @@ in {
key = "<leader>xd";
action =
mkRaw
# lua
''
function() require('trouble').toggle('document_diagnostics') end
'';
# lua
''
function() require('trouble').toggle('document_diagnostics') end
'';
options.desc = "Toggle Document trouble";
}
{
@ -108,10 +110,10 @@ in {
key = "<leader>xq";
action =
mkRaw
# lua
''
function() require('trouble').toggle('quickfix') end
'';
# lua
''
function() require('trouble').toggle('quickfix') end
'';
options.desc = "Toggle Quickfix trouble";
}
{
@ -119,10 +121,10 @@ in {
key = "<leader>xl";
action =
mkRaw
# lua
''
function() require('trouble').toggle('loclist') end
'';
# lua
''
function() require('trouble').toggle('loclist') end
'';
options.desc = "Toggle Loclist trouble";
}
{
@ -130,10 +132,10 @@ in {
key = "gR";
action =
mkRaw
# lua
''
function() require('trouble').toggle('lsp_references') end
'';
# lua
''
function() require('trouble').toggle('lsp_references') end
'';
options.desc = "Toggle lsp References trouble";
}
# Telescope
@ -142,10 +144,10 @@ in {
key = "<leader>ff";
action =
mkRaw
# lua
''
require('telescope.builtin').find_files
'';
# lua
''
require('telescope.builtin').find_files
'';
options.desc = "Find Files";
}
{
@ -153,10 +155,10 @@ in {
key = "<leader>fg";
action =
mkRaw
# lua
''
require('telescope.builtin').live_grep
'';
# lua
''
require('telescope.builtin').live_grep
'';
options.desc = "Find Grep";
}
{
@ -164,10 +166,10 @@ in {
key = "<leader>fh";
action =
mkRaw
# lua
''
require('telescope.builtin').help_tags
'';
# lua
''
require('telescope.builtin').help_tags
'';
options.desc = "Find Help";
}
{
@ -175,10 +177,10 @@ in {
key = "<leader>fb";
action =
mkRaw
# lua
''
require('telescope.builtin').buffers
'';
# lua
''
require('telescope.builtin').buffers
'';
options.desc = "Find Buffer";
}
{
@ -186,10 +188,10 @@ in {
key = "<leader>fd";
action =
mkRaw
# lua
''
require('telescope.builtin').diagnostics
'';
# lua
''
require('telescope.builtin').diagnostics
'';
options.desc = "Find Diagnostics";
}
{
@ -197,10 +199,10 @@ in {
key = "<leader>fq";
action =
mkRaw
# lua
''
require('telescope.builtin').quickfix
'';
# lua
''
require('telescope.builtin').quickfix
'';
options.desc = "Find Quickfix";
}
{
@ -208,10 +210,10 @@ in {
key = "<leader>w";
action =
mkRaw
# lua
''
require('conform').format
'';
# lua
''
require('conform').format
'';
options.desc = "Format buffer";
}
# Nvim Silicon
@ -220,11 +222,11 @@ in {
key = "<leader>sc";
action =
mkRaw
# lua
''
require('nvim-silicon').clip
# lua
''
require('nvim-silicon').clip
'';
'';
options.desc = "Snap Code (to clipboard)";
}
];

View file

@ -1,8 +1,7 @@
{lib, ...}: {
options.jhome.nvim.enable =
lib.mkEnableOption "jalil's neovim configuration"
// {
default = true;
example = false;
};
{ lib, ... }:
{
options.jhome.nvim.enable = lib.mkEnableOption "jalil's neovim configuration" // {
default = true;
example = false;
};
}

View file

@ -3,9 +3,11 @@
pkgs,
helpers,
...
}: let
}:
let
inherit (helpers) mkRaw;
in {
in
{
config.plugins = {
bacon = {
enable = true;
@ -17,38 +19,32 @@ in {
"/" = {
mapping =
mkRaw
/*
lua
*/
''
cmp.mapping.preset.cmdline()
'';
# lua
''
cmp.mapping.preset.cmdline()
'';
sources = [
{name = "rg";}
{name = "buffer";}
{ name = "rg"; }
{ name = "buffer"; }
];
};
":" = {
mapping =
mkRaw
/*
lua
*/
''
cmp.mapping.preset.cmdline()
'';
# lua
''
cmp.mapping.preset.cmdline()
'';
sources = [
{name = "path";}
{name = "cmdline";}
{ name = "path"; }
{ name = "cmdline"; }
];
};
};
settings = {
# Snippets
snippet.expand =
/*
lua
*/
# lua
''
function(args) require('luasnip').lsp_expand(args.body) end
'';
@ -105,73 +101,74 @@ in {
];
mapping =
mkRaw
/*
lua
*/
''
cmp.mapping.preset.insert({
["<C-n>"] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif require("luasnip").expand_or_jumpable() then
require("luasnip").expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end,
["<C-p>"] = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then
require("luasnip").jump(-1)
else
fallback()
end
end,
["<C-u>"] = cmp.mapping(function(fallback)
if require("luasnip").choice_active() then
require("luasnip").next_choice()
else
fallback()
end
end),
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete { },
["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm { select = true },
})
'';
# lua
''
cmp.mapping.preset.insert({
["<C-n>"] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif require("luasnip").expand_or_jumpable() then
require("luasnip").expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end,
["<C-p>"] = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then
require("luasnip").jump(-1)
else
fallback()
end
end,
["<C-u>"] = cmp.mapping(function(fallback)
if require("luasnip").choice_active() then
require("luasnip").next_choice()
else
fallback()
end
end),
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete { },
["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm { select = true },
})
'';
};
};
# FIXME: doesn't include formatters
conform-nvim = {
enable = true;
formattersByFt = {
"_" = ["trim_whitespace"];
c = ["clang_format"];
cpp = ["clang_format"];
lua = ["stylua"];
nix = ["alejandra"];
rust = ["rustfmt"];
sh = ["shfmt"];
toml = ["taplo"];
yaml = ["yamlfmt"];
zig = ["zigfmt"];
"_" = [ "trim_whitespace" ];
c = [ "clang_format" ];
cpp = [ "clang_format" ];
lua = [ "stylua" ];
nix = [ "alejandra" ];
rust = [ "rustfmt" ];
sh = [ "shfmt" ];
toml = [ "taplo" ];
yaml = [ "yamlfmt" ];
zig = [ "zigfmt" ];
};
};
gitsigns.enable = true;
lint = {
enable = true;
lintersByFt = {
rust = ["typos"];
latex = ["chktex" "typos"];
markdown = ["typos"];
nix = ["statix"];
sh = ["dash"];
zsh = ["zsh"];
rust = [ "typos" ];
latex = [
"chktex"
"typos"
];
markdown = [ "typos" ];
nix = [ "statix" ];
sh = [ "dash" ];
zsh = [ "zsh" ];
};
};
lsp = {

View file

@ -1,5 +1,11 @@
{pkgs, ...}: {
imports = [./options.nix ./plugins.nix ./mappings.nix ./augroups.nix];
{ pkgs, ... }:
{
imports = [
./options.nix
./plugins.nix
./mappings.nix
./augroups.nix
];
config = {
globals.mapleader = " ";
@ -34,15 +40,17 @@
# Enable local configuration :h 'exrc'
exrc = true; # safe since nvim 0.9
};
extraPlugins = let
plugins = pkgs.unstable.vimPlugins;
extraPlugins = import ./extraPlugins {pkgs = pkgs.unstable;};
in [
plugins.nui-nvim
plugins.nvim-web-devicons
extraPlugins.vim-jjdescription
extraPlugins.nvim-silicon
];
extraPlugins =
let
plugins = pkgs.unstable.vimPlugins;
extraPlugins = import ./extraPlugins { pkgs = pkgs.unstable; };
in
[
plugins.nui-nvim
plugins.nvim-web-devicons
extraPlugins.vim-jjdescription
extraPlugins.nvim-silicon
];
# Formatting & linters
extraPackages = [
pkgs.unstable.silicon