refactor: complete overhaul
Complete overhaul of repo structure based on nvix. See https://github.com/niksingh710/nvix Signed-off-by: Lander Van den Bulcke <landervandenbulcke@gmail.com>
This commit is contained in:
parent
ff2c59724a
commit
61feed4086
75 changed files with 2916 additions and 2314 deletions
56
plugins/lsp/conform.nix
Normal file
56
plugins/lsp/conform.nix
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
# formatter with lsp fallback
|
||||
{ lib, pkgs, ... }:
|
||||
{
|
||||
plugins.conform-nvim = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
default_format_opts.lsp_format = "prefer";
|
||||
notify_on_error = true;
|
||||
|
||||
format_on_save = ''
|
||||
function(bufnr)
|
||||
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
|
||||
return
|
||||
end
|
||||
|
||||
if slow_format_filetypes[vim.bo[bufnr].filetype] then
|
||||
return
|
||||
end
|
||||
|
||||
local function on_format(err)
|
||||
if err and err:match("timeout$") then
|
||||
slow_format_filetypes[vim.bo[bufnr].filetype] = true
|
||||
end
|
||||
end
|
||||
|
||||
return { timeout_ms = 200, lsp_fallback = true }, on_format
|
||||
end
|
||||
'';
|
||||
|
||||
format_after_save = ''
|
||||
function(bufnr)
|
||||
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
|
||||
return
|
||||
end
|
||||
|
||||
if not slow_format_filetypes[vim.bo[bufnr].filetype] then
|
||||
return
|
||||
end
|
||||
|
||||
return { lsp_fallback = true }
|
||||
end
|
||||
'';
|
||||
|
||||
formatters_by_ft = {
|
||||
"_" = [
|
||||
"squeeze_blanks"
|
||||
"trim_whitespace"
|
||||
"trim_newlines"
|
||||
];
|
||||
};
|
||||
|
||||
formatters.squeeze_blanks.command = lib.getExe' pkgs.coreutils "cat";
|
||||
};
|
||||
};
|
||||
}
|
||||
108
plugins/lsp/default.nix
Normal file
108
plugins/lsp/default.nix
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
inherit (config.myvim.mkKey) mkKeymap;
|
||||
in
|
||||
{
|
||||
opts = {
|
||||
foldcolumn = "1";
|
||||
foldlevel = 99;
|
||||
foldlevelstart = -1;
|
||||
foldenable = true;
|
||||
};
|
||||
|
||||
diagnostic.settings = {
|
||||
virtual_text = false;
|
||||
underline = true;
|
||||
signs = true;
|
||||
severity_sort = true;
|
||||
|
||||
float = {
|
||||
border = config.myvim.border;
|
||||
source = "always";
|
||||
focusable = false;
|
||||
};
|
||||
};
|
||||
|
||||
plugins = {
|
||||
lsp = {
|
||||
enable = true;
|
||||
|
||||
keymaps.extra = [
|
||||
(mkKeymap "n" "<leader>lO" "<cmd>lua require('otter').activate()<cr>" "Force Otter")
|
||||
];
|
||||
|
||||
inlayHints = true;
|
||||
|
||||
servers = {
|
||||
typos_lsp = {
|
||||
enable = true;
|
||||
extraOptions.init_options.diagnosticSeverity = "Hint";
|
||||
};
|
||||
};
|
||||
|
||||
keymaps = {
|
||||
silent = true;
|
||||
|
||||
diagnostic = {
|
||||
"<leader>lj" = "goto_next";
|
||||
"<leader>lk" = "goto_prev";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lspsaga = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
lightbulb = {
|
||||
enable = false;
|
||||
virtualText = false;
|
||||
};
|
||||
|
||||
outline.keys.jump = "<cr>";
|
||||
ui.bortder = config.myvim.border;
|
||||
|
||||
scrollPreview = {
|
||||
scrollDown = "<c-d>";
|
||||
scrollUp = "<c-u>";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nvim-ufo = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
provider_selector = # lua
|
||||
''
|
||||
function()
|
||||
return { "lsp", "indent" }
|
||||
end
|
||||
'';
|
||||
|
||||
preview.mappings = {
|
||||
close = "q";
|
||||
switch = "K";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
otter = {
|
||||
enable = true;
|
||||
|
||||
settings.buffers = {
|
||||
set_filetype = true;
|
||||
};
|
||||
};
|
||||
|
||||
tiny-inline-diagnostic.enable = true;
|
||||
trouble.enable = true;
|
||||
};
|
||||
|
||||
imports =
|
||||
with builtins;
|
||||
with lib;
|
||||
map (fn: ./${fn}) (
|
||||
filter (fn: (fn != "default.nix" && !hasSuffix ".md" "${fn}")) (attrNames (readDir ./.))
|
||||
);
|
||||
}
|
||||
120
plugins/lsp/mappings.nix
Normal file
120
plugins/lsp/mappings.nix
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
inherit (lib.nixvim) mkRaw;
|
||||
inherit (config.myvim.mkKey) mkKeymap wKeyObj;
|
||||
in
|
||||
{
|
||||
|
||||
wKeyList = [
|
||||
(wKeyObj [
|
||||
"<leader>lg"
|
||||
""
|
||||
"goto"
|
||||
])
|
||||
(wKeyObj [
|
||||
"<leader>l"
|
||||
""
|
||||
"lsp"
|
||||
])
|
||||
];
|
||||
|
||||
plugins.lsp.keymaps.extra = [
|
||||
(mkKeymap "n" "<leader>lO" "<cmd>lua require('otter').activate()<cr>" "Force Otter")
|
||||
|
||||
# Lspsaga
|
||||
|
||||
(mkKeymap "n" "<leader>la" "<cmd>:Lspsaga code_action<cr>" "Code Action")
|
||||
(mkKeymap "n" "<leader>lo" "<cmd>Lspsaga outline<cr>" "Outline")
|
||||
(mkKeymap "n" "<leader>lw" "<cmd>Lspsaga show_workspace_diagnostics<cr>" "Workspace Diagnostics")
|
||||
(mkKeymap "n" "gd" "<cmd>Lspsaga goto_definition<cr>" "Definitions")
|
||||
(mkKeymap "n" "<leader>lr" "<cmd>Lspsaga rename ++project<cr>" "Rename")
|
||||
(mkKeymap "n" "gt" "<cmd>Lspsaga goto_type_definition<cr>" "Type Definitions")
|
||||
(mkKeymap "n" "<leader>l." "<cmd>Lspsaga show_line_diagnostics<cr>" "Line Diagnostics")
|
||||
(mkKeymap "n" "gpd" "<cmd>Lspsaga peek_definition<cr>" "Peek Definition")
|
||||
(mkKeymap "n" "gpt" "<cmd>Lspsaga peek_type_definition<cr>" "Peek Type Definition")
|
||||
(mkKeymap "n" "[e" "<cmd>Lspsaga diagnostic_jump_prev<cr>" "Jump Prev Diagnostic")
|
||||
(mkKeymap "n" "]e" "<cmd>Lspsaga diagnostic_jump_next<cr>" "Jump Next Diagnostic")
|
||||
(mkKeymap "n" "K" (mkRaw ''
|
||||
function()
|
||||
local ok, ufo = pcall(require, "ufo")
|
||||
if ok then
|
||||
winid = ufo.peekFoldedLinesUnderCursor()
|
||||
end
|
||||
if not winid then
|
||||
vim.cmd("Lspsaga hover_doc")
|
||||
end
|
||||
end
|
||||
'') "Hover Doc")
|
||||
|
||||
# UFO
|
||||
(mkKeymap "n" "zR" (
|
||||
# lua
|
||||
mkRaw ''
|
||||
function()
|
||||
require("ufo").openAllFolds()
|
||||
end
|
||||
''
|
||||
) "Open all folds")
|
||||
(mkKeymap "n" "zM" (
|
||||
# lua
|
||||
mkRaw ''
|
||||
function()
|
||||
require("ufo").closeAllFolds()
|
||||
end
|
||||
''
|
||||
) "Close All Folds")
|
||||
(mkKeymap "n" "zK" (
|
||||
# lua
|
||||
mkRaw ''
|
||||
function()
|
||||
local winid = require("ufo").peekFoldedLinesUnderCursor()
|
||||
if not winid then
|
||||
vim.lsp.buf.hover()
|
||||
end
|
||||
end
|
||||
''
|
||||
) "Peek Folded Lines")
|
||||
|
||||
(mkKeymap "n" "<leader>lq" "<CMD>LspStop<Enter>" "Stop LSP")
|
||||
(mkKeymap "n" "<leader>li" "<cmd>LspInfo<cr>" "LSP Info")
|
||||
(mkKeymap "n" "<leader>ls" "<CMD>LspStart<Enter>" "Start LSP")
|
||||
(mkKeymap "n" "<leader>lR" "<CMD>LspRestart<Enter>" "Restart LSP")
|
||||
|
||||
(mkKeymap "n" "<C-s-k>" "<cmd>:lua vim.lsp.buf.signature_help()<cr>" "Signature Help")
|
||||
(mkKeymap "n" "<leader>lD" "<cmd>:lua Snacks.picker.lsp_definitions()<cr>" "Definitions list")
|
||||
(mkKeymap "n" "<leader>ls" "<cmd>:lua Snacks.picker.lsp_symbols()<cr>" "Definitions list")
|
||||
|
||||
(mkKeymap "n" "<leader>lf" "<cmd>:lua require('conform').format()<cr>" "Format file")
|
||||
(mkKeymap "x" "<leader>lf" "<cmd>:lua require('conform').format()<cr>" "Format File")
|
||||
(mkKeymap "v" "<leader>lf" "<cmd>:lua require('conform').format()<cr>" "Format File")
|
||||
|
||||
(mkKeymap "n" "[d" "<cmd>:lua vim.diagnostic.goto_prev()<cr>" "Previous Diagnostic")
|
||||
(mkKeymap "n" "]d" "<cmd>:lua vim.diagnostic.goto_next()<cr>" "Next Diagnostic")
|
||||
(mkKeymap "n" "<leader>lL" (
|
||||
# lua
|
||||
mkRaw ''
|
||||
function()
|
||||
if vim.g.diagnostics_visible == nil or vim.g.diagnostics_visible then
|
||||
vim.g.diagnostics_visible = false
|
||||
vim.diagnostic.disable()
|
||||
else
|
||||
vim.g.diagnostics_visible = true
|
||||
vim.diagnostic.enable()
|
||||
end
|
||||
end
|
||||
''
|
||||
) "Toggle Diagnostics")
|
||||
(mkKeymap "n" "<leader>ll" (
|
||||
# lua
|
||||
mkRaw ''
|
||||
function()
|
||||
if vim.diagnostic.config().virtual_text == false then
|
||||
vim.diagnostic.config({ virtual_text = { source = "always" } })
|
||||
else
|
||||
vim.diagnostic.config({ virtual_text = false })
|
||||
end
|
||||
end
|
||||
''
|
||||
) "Toggle Virtual Text")
|
||||
];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue