add new-file-template to nvim (not merged yet)

This commit is contained in:
jacekpoz 2024-08-05 18:53:10 +02:00
parent 5b9bffdb4c
commit dadc734e49
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8
7 changed files with 67 additions and 7 deletions

View file

@ -57,7 +57,10 @@ in {
starship.enable = true;
zsh.enable = true;
btop.enable = true;
neovim.enable = true;
neovim = {
enable = true;
enableLsp = false;
};
};
services = {
ssh = {

View file

@ -167,7 +167,10 @@ in {
btop.enable = true;
foot.enable = true;
mpv.enable = true;
neovim.enable = true;
neovim = {
enable = true;
enableLsp = true;
};
zathura.enable = true;
hypr = {
land = {

View file

@ -104,7 +104,10 @@ in {
enable = true;
gpu = "AMD Radeon RX 6800M (RADV NAVI22)";
};
neovim.enable = true;
neovim = {
enable = true;
enableLsp = true;
};
zathura.enable = true;
hypr = {
land = {

View file

@ -1,8 +1,8 @@
{
imports = [
./neovim
./btop.nix
./helix.nix
./neovim.nix
./newsboat.nix
];
}

View file

@ -14,7 +14,10 @@
glsl_analyzer = getExe pkgs.glsl_analyzer;
in {
options.poz.programs.neovim.enable = mkEnableOption "neovim";
options.poz.programs.neovim = {
enable = mkEnableOption "neovim";
enableLsp = mkEnableOption "neovim lsps";
};
config = mkIf cfg.enable {
environment.sessionVariables = {
@ -38,6 +41,8 @@ in {
cmdHeight = 1;
useSystemClipboard = false;
additionalRuntimePaths = [ ./runtime ];
theme = {
enable = true;
name = "catppuccin";
@ -150,7 +155,7 @@ in {
};
};
lsp = {
lsp = mkIf cfg.enableLsp {
enable = true;
lspSignature.enable = true;
lspconfig = {
@ -183,7 +188,7 @@ in {
};
};
languages = {
languages = mkIf cfg.enableLsp {
enableDAP = true;
enableExtraDiagnostics = true;
enableFormat = true;
@ -216,6 +221,7 @@ in {
enable = true;
useVendoredKeybindings = true;
};
# new-file-template.enable = true;
};
visuals.fidget-nvim.enable = true;

View file

@ -0,0 +1,5 @@
{
imports = [
./config.nix
];
}

View file

@ -0,0 +1,40 @@
local utils = require("new-file-template.utils")
local function h_template(relative_path, filename)
local file_name_split = vim.split(filename, "%.")
local guard_content = file_name_split[1].upper(file_name_split[1]) .. [[_H_]]
.. string.format('%s', os.time()) .. [[_]]
return [[
#ifndef ]] .. guard_content .. [[
#define ]] .. guard_content .. [[
|cursor|
#endif // ]] .. guard_content .. [[
]]
end
local function c_template(relative_path, filename)
local file_name_split = vim.split(filename, "%.")
return [[#include "]].. file_name_split[1] ..[[.h"
|cursor|]]
end
--- @param opts table
--- A table containing the following fields:
--- - `full_path` (string): The full path of the new file, e.g., "lua/new-file-template/templates/init.lua".
--- - `relative_path` (string): The relative path of the new file, e.g., "lua/new-file-template/templates/init.lua".
--- - `filename` (string): The filename of the new file, e.g., "init.lua".
return function(opts)
local template = {
{ pattern = ".*h", content = h_template },
{ pattern = ".*c", content = c_template },
}
return utils.find_entry(template, opts)
end