Split interface/language plugins to file
This commit is contained in:
227
home/modules/neovim/interface.nix
Normal file
227
home/modules/neovim/interface.nix
Normal file
@ -0,0 +1,227 @@
|
||||
{
|
||||
lib,
|
||||
mylib,
|
||||
pkgs,
|
||||
...
|
||||
}: [
|
||||
{
|
||||
name = "lualine";
|
||||
pkg = pkgs.vimPlugins.lualine-nvim;
|
||||
lazy = false;
|
||||
config = ''
|
||||
function(_, opts)
|
||||
require("lualine").setup(opts)
|
||||
end
|
||||
'';
|
||||
opts = {
|
||||
extensions = ["fzf" "chadtree" "neo-tree" "toggleterm" "trouble"];
|
||||
|
||||
options = {
|
||||
always_divide_middle = true;
|
||||
globalstatus = true;
|
||||
ignore_focus = ["neo-tree" "chadtree"];
|
||||
section_separators = {
|
||||
left = "";
|
||||
right = "";
|
||||
# left = "";
|
||||
# right = "";
|
||||
};
|
||||
|
||||
component_separators = {
|
||||
left = "";
|
||||
right = "";
|
||||
# left = "";
|
||||
# right = "";
|
||||
};
|
||||
};
|
||||
|
||||
sections = {
|
||||
lualine_a = [
|
||||
{
|
||||
name = "mode";
|
||||
# extraConfig = {
|
||||
# separator = {
|
||||
# left = "";
|
||||
# };
|
||||
# right_padding = "2";
|
||||
# };
|
||||
}
|
||||
];
|
||||
lualine_b = ["branch" "diff" "diagnostics"];
|
||||
lualine_c = [
|
||||
{
|
||||
name = "filename";
|
||||
extraConfig = {
|
||||
path = 1;
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
lualine_x = ["filetype" "encoding" "fileformat"];
|
||||
lualine_y = ["progress" "searchcount" "selectioncount"];
|
||||
lualine_z = [
|
||||
{
|
||||
name = "location";
|
||||
# extraConfig = {
|
||||
# separator = {
|
||||
# right = "";
|
||||
# };
|
||||
# left_padding = "2";
|
||||
# };
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
tabline = {
|
||||
lualine_a = ["buffers"];
|
||||
lualine_z = ["tabs"];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
{
|
||||
name = "noice";
|
||||
pkg = pkgs.vimPlugins.noice-nvim;
|
||||
dependencies = [
|
||||
{
|
||||
name = "nui"; # For noice
|
||||
pkg = pkgs.vimPlugins.nui-nvim;
|
||||
lazy = false;
|
||||
}
|
||||
];
|
||||
lazy = false;
|
||||
config = ''
|
||||
function(_, opts)
|
||||
require("noice").setup(opts)
|
||||
end
|
||||
'';
|
||||
opts = {
|
||||
presets = {
|
||||
bottom_search = false;
|
||||
command_palette = true;
|
||||
long_message_to_split = true;
|
||||
inc_rename = true;
|
||||
lsp_doc_border = true;
|
||||
};
|
||||
|
||||
lsp = {
|
||||
documentation = {
|
||||
opts = {
|
||||
lang = "markdown";
|
||||
replace = true;
|
||||
render = "plain";
|
||||
border = "rounded"; # single or rounded
|
||||
format = ["{message}"];
|
||||
win_options = {
|
||||
concealcursor = "n";
|
||||
conceallevel = 3;
|
||||
};
|
||||
};
|
||||
view = "hover";
|
||||
};
|
||||
|
||||
override = {
|
||||
"vim.lsp.util.convert_input_to_markdown_lines" = true;
|
||||
"vim.lsp.util.stylize_markdown" = true;
|
||||
"cmp.entry.get_documentation" = true;
|
||||
};
|
||||
};
|
||||
|
||||
notify = {
|
||||
enabled = true;
|
||||
};
|
||||
|
||||
popupmenu = {
|
||||
enabled = true;
|
||||
backend = "nui"; # cmp completion is broken
|
||||
};
|
||||
|
||||
# cmdline.enabled = false;
|
||||
# messages.enabled = false;
|
||||
|
||||
routes = [
|
||||
# Hide inline search count info
|
||||
{
|
||||
filter = {
|
||||
event = "msg_show";
|
||||
kind = "search_count";
|
||||
};
|
||||
opts = {skip = true;};
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
{
|
||||
name = "notify";
|
||||
pkg = pkgs.vimPlugins.nvim-notify;
|
||||
lazy = false;
|
||||
config = ''
|
||||
function(_, opts)
|
||||
vim.notify = require("notify")
|
||||
require("notify").setup(opts)
|
||||
end
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
name = "telescope";
|
||||
pkg = pkgs.vimPlugins.telescope-nvim;
|
||||
dependencies = [
|
||||
{
|
||||
name = "plenary"; # For telescope
|
||||
pkg = pkgs.vimPlugins.plenary-nvim;
|
||||
}
|
||||
{
|
||||
name = "telescope-undo";
|
||||
pkg = pkgs.vimPlugins.telescope-undo-nvim;
|
||||
}
|
||||
{
|
||||
name = "telescope-ui-select";
|
||||
pkg = pkgs.vimPlugins.telescope-ui-select-nvim;
|
||||
}
|
||||
{
|
||||
name = "telescope-fzf-native";
|
||||
pkg = pkgs.vimPlugins.telescope-fzf-native-nvim;
|
||||
}
|
||||
];
|
||||
lazy = false;
|
||||
config = let
|
||||
extensions = mylib.generators.toLuaObject [
|
||||
"undo"
|
||||
"ui-select"
|
||||
"fzf"
|
||||
];
|
||||
in ''
|
||||
function(_, opts)
|
||||
local telescope = require("telescope")
|
||||
telescope.setup(opts)
|
||||
|
||||
for i, extension in ipairs(${extensions}) do
|
||||
telescope.load_extension(extension)
|
||||
end
|
||||
end
|
||||
'';
|
||||
opts = {
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = {
|
||||
"<Esc>" = {__raw = ''function(...) return require("telescope.actions").close(...) end'';};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
{
|
||||
name = "which-key";
|
||||
pkg = pkgs.vimPlugins.which-key-nvim;
|
||||
lazy = false;
|
||||
priority = 100;
|
||||
config = ''
|
||||
function(_, opts)
|
||||
require("which-key").setup(opts)
|
||||
end
|
||||
'';
|
||||
}
|
||||
]
|
148
home/modules/neovim/languages.nix
Normal file
148
home/modules/neovim/languages.nix
Normal file
@ -0,0 +1,148 @@
|
||||
{
|
||||
lib,
|
||||
mylib,
|
||||
pkgs,
|
||||
...
|
||||
}: [
|
||||
{
|
||||
name = "conform";
|
||||
pkg = pkgs.vimPlugins.conform-nvim;
|
||||
config = ''
|
||||
function(_, opts)
|
||||
require("conform").setup(opts)
|
||||
end
|
||||
'';
|
||||
opts = {
|
||||
formatters_by_ft = {
|
||||
c = ["clang-format"];
|
||||
h = ["clang-format"];
|
||||
cpp = ["clang-format"];
|
||||
hpp = ["clang-format"];
|
||||
css = [["prettierd" "prettier"]];
|
||||
html = [["prettierd" "prettier"]];
|
||||
java = ["google-java-format"];
|
||||
javascript = [["prettierd" "prettier"]];
|
||||
lua = ["stylua"];
|
||||
markdown = [["prettierd" "prettier"]];
|
||||
nix = ["alejandra"];
|
||||
python = ["black"];
|
||||
rust = ["rustfmt"];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
{
|
||||
name = "lint";
|
||||
pkg = pkgs.vimPlugins.nvim-lint;
|
||||
lazy = false;
|
||||
config = ''
|
||||
function(_, opts)
|
||||
local lint = require("lint")
|
||||
|
||||
for k, v in pairs(opts) do
|
||||
lint[k] = v
|
||||
end
|
||||
end
|
||||
'';
|
||||
opts = {
|
||||
linters_by_ft = {
|
||||
c = ["clang-tidy"];
|
||||
h = ["clang-tidy"];
|
||||
cpp = ["clang-tidy"];
|
||||
hpp = ["clang-tidy"];
|
||||
clojure = ["clj-kondo"];
|
||||
java = ["checkstyle"];
|
||||
javascript = ["eslint_d"];
|
||||
lua = ["luacheck"];
|
||||
markdown = ["vale"];
|
||||
nix = ["statix"];
|
||||
python = ["flake8"];
|
||||
rust = ["clippy"];
|
||||
text = ["vale"];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
{
|
||||
name = "lspconfig";
|
||||
pkg = pkgs.vimPlugins.nvim-lspconfig;
|
||||
lazy = false;
|
||||
config = let
|
||||
servers = mylib.generators.toLuaObject [
|
||||
{name = "clangd";}
|
||||
{name = "clojure_lsp";}
|
||||
{name = "cmake";}
|
||||
{name = "lua-ls";}
|
||||
{name = "nil_ls";}
|
||||
{name = "pyright";}
|
||||
{name = "rust_analyzer";}
|
||||
{name = "texlab";}
|
||||
|
||||
{
|
||||
name = "hls";
|
||||
cmd = [
|
||||
"haskell-language-server-wrapper"
|
||||
"--lsp"
|
||||
];
|
||||
}
|
||||
];
|
||||
in ''
|
||||
function(_, opts)
|
||||
local __lspOnAttach = function(client, bufnr) end
|
||||
|
||||
local __lspCapabilities = function()
|
||||
capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities())
|
||||
return capabilities
|
||||
end
|
||||
|
||||
local __setup = {
|
||||
on_attach = __lspOnAttach,
|
||||
capabilities = __lspCapabilities(),
|
||||
}
|
||||
|
||||
for i, server in ipairs(${servers}) do
|
||||
if type(server) == "string" then
|
||||
require("lspconfig")[server].setup(__setup)
|
||||
else
|
||||
local options = server.extraOptions
|
||||
|
||||
if options == nil then
|
||||
options = __setup
|
||||
else
|
||||
options = vim.tbl_extend("keep", options, __setup)
|
||||
end
|
||||
|
||||
require("lspconfig")[server.name].setup(options)
|
||||
end
|
||||
end
|
||||
end
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
name = "treesitter";
|
||||
pkg = pkgs.vimPlugins.nvim-treesitter.withAllGrammars;
|
||||
lazy = false;
|
||||
config = ''
|
||||
function(_, opts)
|
||||
require("nvim-treesitter.configs").setup(opts)
|
||||
end
|
||||
'';
|
||||
opts = {
|
||||
highlight.enable = true;
|
||||
indent.enable = true;
|
||||
|
||||
# TODO: Doesn't work
|
||||
incremental_selection = {
|
||||
enable = true;
|
||||
keymaps = {
|
||||
"init_selection" = "gnn";
|
||||
"node_decremental" = "grm";
|
||||
"node_incremental" = "grn";
|
||||
"scope_incremental" = "grc";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
]
|
Reference in New Issue
Block a user