aboutsummaryrefslogtreecommitdiff
path: root/modules/home/editors
diff options
context:
space:
mode:
Diffstat (limited to 'modules/home/editors')
-rw-r--r--modules/home/editors/neovim/default.nix114
-rw-r--r--modules/home/editors/neovim/init.lua239
-rw-r--r--modules/home/editors/vscode/default.nix139
-rw-r--r--modules/home/editors/zed/default.nix91
4 files changed, 583 insertions, 0 deletions
diff --git a/modules/home/editors/neovim/default.nix b/modules/home/editors/neovim/default.nix
new file mode 100644
index 0000000..c9d30db
--- /dev/null
+++ b/modules/home/editors/neovim/default.nix
@@ -0,0 +1,114 @@
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}:
+
+let
+ inherit (lib)
+ mkOption
+ types
+ mkIf
+ optionals
+ ;
+ cfg = config.nx.editors.neovim;
+in
+{
+ options.nx.editors.neovim = {
+ enable = mkOption {
+ description = "Neovim editor";
+ type = types.bool;
+ default = true;
+ };
+
+ langs = {
+ python = mkOption {
+ description = "enable the python integration";
+ type = types.bool;
+ default = false;
+ };
+ go = mkOption {
+ description = "enable go integration";
+ type = types.bool;
+ default = false;
+ };
+ ts = mkOption {
+ description = "enable the js/ts integration";
+ type = types.bool;
+ default = false;
+ };
+ nix = mkOption {
+ description = "enable the nix integration";
+ type = types.bool;
+ default = true;
+ };
+ lua = mkOption {
+ description = "enable the lua integration";
+ type = types.bool;
+ default = true;
+ };
+ latex = mkOption {
+ description = "enable latex integration";
+ type = types.bool;
+ default = false;
+ };
+ typst = mkOption {
+ description = "enable typst integration";
+ type = types.bool;
+ default = false;
+ };
+ };
+ };
+
+ config = mkIf cfg.enable {
+ programs.neovim = {
+ defaultEditor = true;
+ enable = true;
+ package = pkgs.neovim-unwrapped;
+ extraPackages =
+ with pkgs;
+ [
+ tree-sitter
+ git
+ ripgrep
+ fd
+ gcc
+ ]
+ ++ (optionals cfg.langs.ts [ pkgs.nodePackages.typescript-language-server ])
+ ++ (optionals cfg.langs.python [ ])
+ ++ (optionals cfg.langs.go [ pkgs.gopls ])
+ ++ (optionals cfg.langs.nix [
+ pkgs.nil
+ pkgs.nixfmt
+ ])
+ ++ (optionals cfg.langs.lua [ pkgs.lua-language-server ])
+ ++ (optionals cfg.langs.latex [ pkgs.texlab ])
+ ++ (optionals cfg.langs.typst [ pkgs.tinymist ]);
+
+ plugins = with pkgs.vimPlugins; [
+ gruvbox-nvim
+ mini-starter
+ gitsigns-nvim
+ nvim-autopairs
+ telescope-nvim
+ fidget-nvim
+ plenary-nvim
+ nvim-treesitter.withAllGrammars
+ nvim-lspconfig
+ nvim-cmp
+ cmp-nvim-lsp
+ cmp-buffer
+ cmp-path
+ cmp-cmdline
+ luasnip
+ cmp_luasnip
+ lspkind-nvim
+ ];
+
+ extraConfig = ''
+ luafile ${./init.lua}
+ '';
+ };
+ };
+}
diff --git a/modules/home/editors/neovim/init.lua b/modules/home/editors/neovim/init.lua
new file mode 100644
index 0000000..141eb3c
--- /dev/null
+++ b/modules/home/editors/neovim/init.lua
@@ -0,0 +1,239 @@
+-- General settings
+vim.g.mapleader = " "
+vim.o.number = true
+vim.o.relativenumber = true
+vim.o.signcolumn = "yes"
+vim.o.termguicolors = true
+vim.o.wrap = false
+vim.o.tabstop = 2
+vim.o.shiftwidth = 2
+vim.o.updatetime = 250
+vim.o.timeoutlen = 300
+vim.o.swapfile = false
+vim.o.ignorecase = true
+vim.o.smartcase = true
+vim.o.winborder = "rounded"
+vim.o.clipboard = "unnamedplus"
+
+local map = vim.keymap.set
+map('n', '<leader>o', '<CMD>update<BAR>source %<CR>', { desc = 'Save & reload init.lua' })
+map('n', '<leader>w', '<CMD>write<CR>')
+map('n', '<leader>q', '<CMD>quit<CR>')
+
+
+require("mini.starter").setup({
+ header = table.concat({
+ " /l、 ",
+ "(゚、 。 7 ",
+ " l ~ ヽ ",
+ " じしf_,)ノ ",
+ }, "\n"),
+ footer = "",
+ content_hooks = {
+ require("mini.starter").gen_hook.adding_bullet("» "),
+ require("mini.starter").gen_hook.aligning("center", "center"),
+ },
+})
+
+require("gitsigns").setup()
+require("nvim-autopairs").setup()
+require("fidget").setup()
+
+vim.cmd("colorscheme gruvbox")
+
+local hl = vim.api.nvim_set_hl
+hl(0, 'Normal', { bg = 'none' })
+hl(0, 'NormalFloat', { bg = 'none' })
+hl(0, 'NormalNC', { bg = 'none' })
+hl(0, 'StatusLine', { bg = 'none' })
+hl(0, 'SignColumn', { bg = 'none' })
+hl(0, "DiagnosticError", { bg = "none" })
+hl(0, "DiagnosticSignError", { bg = "none" })
+hl(0, "DiagnosticSignHint", { bg = "none" })
+hl(0, "DiagnosticSignInfo", { bg = "none" })
+hl(0, "DiagnosticSignWarn", { bg = "none" })
+
+hl(0, "Pmenu", { bg = "none" })
+hl(0, "PmenuSel", { bg = "none" })
+hl(0, "FloatBorder", { bg = "none" })
+
+local status_ok, configs = pcall(require, "nvim-treesitter.configs")
+if status_ok then
+ configs.setup({
+ highlight = { enable = true },
+ indent = { enable = true },
+ })
+end
+
+local builtin = require('telescope.builtin')
+local map = vim.keymap.set
+map('n', '<leader>ff', builtin.find_files, { desc = 'Telescope find files' })
+map('n', '<leader>fg', builtin.live_grep, { desc = 'Telescope live grep' })
+map('n', '<leader>fb', builtin.buffers, { desc = 'Telescope buffers' })
+map('n', '<leader>fh', builtin.help_tags, { desc = 'Telescope help tags' })
+
+
+local cmp = require("cmp")
+cmp.setup({
+ snippet = {
+ expand = function(args)
+ require('luasnip').lsp_expand(args.body)
+ end,
+ },
+ mapping = cmp.mapping.preset.insert({
+ ['<C-b>'] = cmp.mapping.scroll_docs(-4),
+ ['<C-f>'] = cmp.mapping.scroll_docs(4),
+ ['<C-Space>'] = cmp.mapping.complete(),
+ ['<C-e>'] = cmp.mapping.abort(),
+ ['<CR>'] = cmp.mapping.confirm({ select = true }),
+ ['<Tab>'] = cmp.mapping(function(fallback)
+ if cmp.visible() then
+ cmp.select_next_item()
+ else
+ fallback()
+ end
+ end, { 'i', 's' }),
+ ['<S-Tab>'] = cmp.mapping(function(fallback)
+ if cmp.visible() then
+ cmp.select_prev_item()
+ else
+ fallback()
+ end
+ end, { 'i', 's' }),
+ }),
+ sources = cmp.config.sources({
+ { name = 'nvim_lsp' },
+ { name = 'luasnip' },
+ }, {
+ { name = 'buffer' },
+ })
+})
+
+-- Add parentheses after selecting function or method
+local cmp_autopairs = require('nvim-autopairs.completion.cmp')
+cmp.event:on(
+ 'confirm_done',
+ cmp_autopairs.on_confirm_done()
+)
+
+local capabilities = require('cmp_nvim_lsp').default_capabilities()
+
+vim.api.nvim_create_autocmd('LspAttach', {
+ group = vim.api.nvim_create_augroup('UserLspConfig', {}),
+ callback = function(ev)
+ local opts = { buffer = ev.buf, noremap = true, silent = true }
+ vim.keymap.set('n', '<leader>lf', function() vim.lsp.buf.format { async = true } end, opts)
+ end,
+})
+
+-- Format on save for all languages with LSP support
+vim.api.nvim_create_autocmd('BufWritePre', {
+ group = vim.api.nvim_create_augroup('FormatOnSave', {}),
+ callback = function()
+ local clients = vim.lsp.get_clients({ bufnr = 0 })
+ for _, client in ipairs(clients) do
+ if client.supports_method('textDocument/formatting') then
+ vim.lsp.buf.format({ async = false })
+ return
+ end
+ end
+ end,
+})
+
+-- Native LSP setup (Neovim v0.11+)
+vim.lsp.config('nixd', {
+ cmd = { 'nixd' },
+ capabilities = capabilities,
+ settings = {
+ nixd = {
+ formatting = {
+ command = { "nixfmt" },
+ },
+ },
+ },
+})
+
+vim.lsp.config('nil_ls', {
+ cmd = { 'nil' },
+ capabilities = capabilities,
+ settings = {
+ ['nil'] = {
+ nix = {
+ flake = {
+ autoArchive = true,
+ },
+ },
+ },
+ },
+})
+
+vim.lsp.config('lua_ls', {
+ cmd = { 'lua-language-server' },
+ capabilities = capabilities,
+ settings = {
+ Lua = {
+ runtime = {
+ version = 'LuaJIT',
+ },
+ diagnostics = {
+ globals = { 'vim', 'require' },
+ },
+ workspace = {
+ library = vim.api.nvim_get_runtime_file("", true),
+ },
+ telemetry = {
+ enable = false,
+ },
+ },
+ },
+})
+
+vim.lsp.config('pyright', {
+ cmd = { 'pyright-langserver', '--stdio' },
+ capabilities = capabilities,
+})
+
+vim.lsp.config('tailwindcss', {
+ cmd = { 'tailwindcss-language-server', '--stdio' },
+ capabilities = capabilities,
+})
+
+vim.lsp.config('gopls', {
+ cmd = { 'gopls' },
+ capabilities = capabilities,
+ settings = {
+ gopls = {
+ analyses = {
+ unusedparams = true,
+ unusedwrite = true,
+ },
+ staticcheck = true,
+ },
+ },
+})
+
+vim.lsp.config('rust_analyzer', {
+ cmd = { 'rust-analyzer' },
+ capabilities = capabilities,
+})
+
+vim.lsp.config('ts_ls', {
+ cmd = { 'typescript-language-server', '--stdio' },
+ capabilities = capabilities,
+})
+
+-- Enable all configured servers
+vim.lsp.enable('nixd')
+vim.lsp.enable('nil_ls')
+vim.lsp.enable('lua_ls')
+vim.lsp.enable('pyright')
+vim.lsp.enable('tailwindcss')
+vim.lsp.enable('gopls')
+vim.lsp.enable('rust_analyzer')
+vim.lsp.enable('ts_ls')
+
+vim.diagnostic.config({
+ virtual_text = { source = "if_many" },
+ underline = true,
+ severity_sort = true,
+})
diff --git a/modules/home/editors/vscode/default.nix b/modules/home/editors/vscode/default.nix
new file mode 100644
index 0000000..9762d92
--- /dev/null
+++ b/modules/home/editors/vscode/default.nix
@@ -0,0 +1,139 @@
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}:
+
+let
+ inherit (lib)
+ mkEnableOption
+ mkOption
+ types
+ mkIf
+ optionals
+ ;
+ cfg = config.nx.editors.vscode;
+in
+{
+ options.nx.editors.vscode = {
+ enable = mkEnableOption "vscode editor";
+
+ useVSCodium = mkOption {
+ description = "Use vscodium instead of vscode";
+ type = types.bool;
+ default = false;
+ };
+
+ theme = mkOption {
+ description = "Theme to use for vscode";
+ type = types.enum [
+ "minimal"
+ "dark"
+ "light"
+ ];
+ default = "minimal";
+ };
+
+ langs = {
+ cmake = mkOption {
+ description = "enable cmake integration";
+ type = types.bool;
+ default = false;
+ };
+ docker = mkOption {
+ description = "enable docker integration";
+ type = types.bool;
+ default = false;
+ };
+ python = mkOption {
+ description = "enable python integration";
+ type = types.bool;
+ default = false;
+ };
+ go = mkOption {
+ description = "enable go integration";
+ type = types.bool;
+ default = false;
+ };
+ rust = mkOption {
+ description = "enable rust integration";
+ type = types.bool;
+ default = false;
+ };
+ java = mkOption {
+ description = "enable java integration";
+ type = types.bool;
+ default = false;
+ };
+ lua = mkOption {
+ description = "enable lua integration";
+ type = types.bool;
+ default = false;
+ };
+ tailwindcss = mkOption {
+ description = "enable tailwindcss integration";
+ type = types.bool;
+ default = false;
+ };
+ };
+ };
+
+ config = mkIf cfg.enable {
+ programs.vscode = {
+ enable = true;
+ package = if cfg.useVSCodium then pkgs.vscodium else pkgs.vscode;
+ mutableExtensionsDir = false;
+ profiles.default = {
+ enableUpdateCheck = true;
+ enableExtensionUpdateCheck = true;
+
+ userSettings = {
+ "update.mode" = "none";
+ "workbench.colorTheme" =
+ if cfg.theme == "minimal" then
+ "Minimal"
+ else if cfg.theme == "dark" then
+ "Default Dark Modern"
+ else
+ "Default Light Modern";
+ "editor.fontFamily" = "monospace";
+ "editor.tabSize" = 2;
+ "editor.minimap.enabled" = false;
+ "terminal.integrated.cursorStyle" = "underline";
+ "terminal.integrated.cursorStyleInactive" = "underline";
+ "terminal.integrated.fontFamily" = "monospace";
+ "terminal.integrated.fontSize" = 13;
+ "git.autofetch" = true;
+ "window.controlsStyle" = "custom";
+ };
+
+ extensions =
+ with pkgs.vscode-extensions;
+ [
+ github.copilot
+ adpyke.codesnap
+ esbenp.prettier-vscode
+ ]
+ ++ (optionals cfg.langs.cmake [ ms-vscode.cmake-tools ])
+ ++ (optionals cfg.langs.docker [ ms-azuretools.vscode-docker ])
+ ++ (optionals cfg.langs.python [ ms-python.python ])
+ ++ (optionals cfg.langs.go [ golang.go ])
+ ++ (optionals cfg.langs.rust [ rust-lang.rust-analyzer ])
+ ++ (optionals cfg.langs.java [ vscjava.vscode-maven ])
+ ++ (optionals cfg.langs.lua [ sumneko.lua ])
+ ++ (optionals cfg.langs.tailwindcss [ bradlc.vscode-tailwindcss ])
+ ++ (optionals (cfg.theme == "minimal") (
+ pkgs.vscode-utils.extensionsFromVscodeMarketplace [
+ {
+ name = "minimalist-dark";
+ publisher = "nichabosh";
+ version = "1.0.0";
+ sha256 = "sha256-lw+Scfada6DycLdRT2Cz+Fd12JucglIrw3uRd2ZhabQ=";
+ }
+ ]
+ ));
+ };
+ };
+ };
+}
diff --git a/modules/home/editors/zed/default.nix b/modules/home/editors/zed/default.nix
new file mode 100644
index 0000000..431560c
--- /dev/null
+++ b/modules/home/editors/zed/default.nix
@@ -0,0 +1,91 @@
+{
+ config,
+ lib,
+ ...
+}:
+
+let
+ inherit (lib)
+ mkEnableOption
+ mkOption
+ types
+ mkIf
+ optionals
+ ;
+ cfg = config.nx.editors.zed-editor;
+in
+{
+ options.nx.editors.zed-editor = {
+ enable = mkEnableOption "zed editor";
+
+ langs = {
+ nix = mkOption {
+ description = "enable nix integration";
+ type = types.bool;
+ default = true;
+ };
+ python = mkOption {
+ description = "enable python integration";
+ type = types.bool;
+ default = false;
+ };
+ rust = mkOption {
+ description = "enable rust integration";
+ type = types.bool;
+ default = false;
+ };
+ go = mkOption {
+ description = "enable go integration";
+ type = types.bool;
+ default = false;
+ };
+ lua = mkOption {
+ description = "enable lua integration";
+ type = types.bool;
+ default = false;
+ };
+ docker = mkOption {
+ description = "enable docker integration";
+ type = types.bool;
+ default = false;
+ };
+ java = mkOption {
+ description = "enable java integration";
+ type = types.bool;
+ default = false;
+ };
+ cmake = mkOption {
+ description = "enable cmake integration";
+ type = types.bool;
+ default = false;
+ };
+ toml = mkOption {
+ description = "enable toml integration";
+ type = types.bool;
+ default = false;
+ };
+ };
+ };
+
+ config = mkIf cfg.enable {
+ programs.zed-editor = {
+ enable = true;
+ extensions =
+ [ ]
+ ++ (optionals cfg.langs.nix [ "nix" ])
+ ++ (optionals cfg.langs.python [ "python" ])
+ ++ (optionals cfg.langs.rust [ "rust" ])
+ ++ (optionals cfg.langs.go [ "go" ])
+ ++ (optionals cfg.langs.lua [ "lua" ])
+ ++ (optionals cfg.langs.docker [ "dockerfile" ])
+ ++ (optionals cfg.langs.java [ "java" ])
+ ++ (optionals cfg.langs.cmake [ "cmake" ])
+ ++ (optionals cfg.langs.toml [ "toml" ]);
+ userSettings = {
+ telemetry = {
+ metrics = false;
+ };
+ };
+ };
+ };
+}