From b8dd418de01e90eba8ed9959b44df1b69b513dd9 Mon Sep 17 00:00:00 2001 From: Ivan Dimitrov Date: Sat, 18 Nov 2023 08:42:50 +0200 Subject: [PATCH] making neovim use ide flake --- flake.lock | 299 +++++++++++++++++++++++ flake.nix | 11 + home/ivand/default.nix | 1 - modules/programs/default.nix | 2 +- modules/programs/neovim/bash.nix | 22 -- modules/programs/neovim/default.nix | 58 +---- modules/programs/neovim/hs.nix | 20 -- modules/programs/neovim/js.nix | 43 ---- modules/programs/neovim/lua.nix | 25 -- modules/programs/neovim/nix.nix | 21 -- modules/programs/neovim/nvim/default.lua | 126 ---------- modules/programs/neovim/nvim/util.lua | 27 -- modules/programs/neovim/py.nix | 20 -- modules/programs/neovim/util.nix | 6 - 14 files changed, 316 insertions(+), 365 deletions(-) delete mode 100644 modules/programs/neovim/bash.nix delete mode 100644 modules/programs/neovim/hs.nix delete mode 100644 modules/programs/neovim/js.nix delete mode 100644 modules/programs/neovim/lua.nix delete mode 100644 modules/programs/neovim/nix.nix delete mode 100644 modules/programs/neovim/nvim/default.lua delete mode 100644 modules/programs/neovim/nvim/util.lua delete mode 100644 modules/programs/neovim/py.nix delete mode 100644 modules/programs/neovim/util.nix diff --git a/flake.lock b/flake.lock index 14c0409..686499d 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,125 @@ { "nodes": { + "beautysh": { + "inputs": { + "nixpkgs": [ + "ide", + "nixvim", + "nixpkgs" + ], + "poetry2nix": "poetry2nix", + "utils": "utils" + }, + "locked": { + "lastModified": 1680308980, + "narHash": "sha256-aUEHV0jk2qIFP3jlsWYWhBbm+w/N9gzH3e4I5DcdB5s=", + "owner": "lovesegfault", + "repo": "beautysh", + "rev": "9845efc3ea3e86cc0d41465d720a47f521b2799c", + "type": "github" + }, + "original": { + "owner": "lovesegfault", + "repo": "beautysh", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": [ + "ide", + "systems" + ] + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "ide", + "nixvim", + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660459072, + "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -40,6 +160,29 @@ "type": "github" } }, + "ide": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ], + "nixvim": "nixvim", + "systems": "systems_3" + }, + "locked": { + "lastModified": 1700289697, + "narHash": "sha256-/erb3yK7dVsqnZ8ehcpmHeWTm6f0hdoBcBNtbYQTwpQ=", + "owner": "ivandimitrov8080", + "repo": "xin-ide", + "rev": "907a557f480e1311e5ee6b38b94a0d2cb0cd3d2f", + "type": "github" + }, + "original": { + "owner": "ivandimitrov8080", + "repo": "xin-ide", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1699936420, @@ -55,12 +198,168 @@ "type": "github" } }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1685801374, + "narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c37ca420157f4abc31e26f436c1145f8951ff373", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixvim": { + "inputs": { + "beautysh": "beautysh", + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "ide", + "nixpkgs" + ], + "pre-commit-hooks": "pre-commit-hooks" + }, + "locked": { + "lastModified": 1700216821, + "narHash": "sha256-c0W9HelclC4rACUAXTK8Q8+X0oKlLTTXnsheLJoA0iw=", + "owner": "ivandimitrov8080", + "repo": "nixvim", + "rev": "5b615804cc96dcbc42b17b38d33264ade00976cc", + "type": "github" + }, + "original": { + "owner": "ivandimitrov8080", + "repo": "nixvim", + "type": "github" + } + }, + "poetry2nix": { + "inputs": { + "flake-utils": [ + "ide", + "nixvim", + "beautysh", + "utils" + ], + "nixpkgs": [ + "ide", + "nixvim", + "beautysh", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1658665240, + "narHash": "sha256-/wkx7D7enyBPRjIkK0w7QxLQhzEkb3UxNQnjyc3FTUI=", + "owner": "nix-community", + "repo": "poetry2nix", + "rev": "8b8edc85d24661d5a6d0d71d6a7011f3e699780f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "poetry2nix", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils_3", + "gitignore": "gitignore", + "nixpkgs": [ + "ide", + "nixvim", + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1698227354, + "narHash": "sha256-Fi5H9jbaQLmLw9qBi/mkR33CoFjNbobo5xWdX4tKz1Q=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "bd38df3d508dfcdff52cd243d297f218ed2257bf", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, "root": { "inputs": { "home-manager": "home-manager", "hosts": "hosts", + "ide": "ide", "nixpkgs": "nixpkgs" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_3": { + "locked": { + "lastModified": 1680978846, + "narHash": "sha256-Gtqg8b/v49BFDpDetjclCYXm8mAnTrUzR0JnE2nv5aw=", + "owner": "nix-systems", + "repo": "x86_64-linux", + "rev": "2ecfcac5e15790ba6ce360ceccddb15ad16d08a8", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "x86_64-linux", + "type": "github" + } + }, + "utils": { + "locked": { + "lastModified": 1678901627, + "narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 795309b..2da3513 100644 --- a/flake.nix +++ b/flake.nix @@ -9,6 +9,10 @@ url = "github:StevenBlack/hosts"; inputs.nixpkgs.follows = "nixpkgs"; }; + ide = { + url = "github:ivandimitrov8080/xin-ide"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = @@ -16,6 +20,7 @@ , nixpkgs , home-manager , hosts + , ide , ... }: let @@ -42,6 +47,12 @@ ./home/ivand ./modules/programs ./modules/packages + ( + import ./modules/programs/neovim + { + nvim = ide.homeManagerModules.${system}.nvim; + } + ) ]; pkgs = import nixpkgs { inherit system; diff --git a/home/ivand/default.nix b/home/ivand/default.nix index 09530de..69bcd08 100644 --- a/home/ivand/default.nix +++ b/home/ivand/default.nix @@ -47,7 +47,6 @@ }; programs = { - nv.enable = true; shell.enable = true; common.enable = true; }; diff --git a/modules/programs/default.nix b/modules/programs/default.nix index da02e0f..bd4bbf4 100644 --- a/modules/programs/default.nix +++ b/modules/programs/default.nix @@ -3,7 +3,7 @@ let cfg = config.programs.common; in { - imports = [ ./neovim ./neomutt ./sway ./tmux.nix ./zsh.nix ./lf ]; + imports = [ ./sway ./tmux.nix ./zsh.nix ./lf ]; options.programs.common = { enable = lib.mkEnableOption "common"; diff --git a/modules/programs/neovim/bash.nix b/modules/programs/neovim/bash.nix deleted file mode 100644 index 0671877..0000000 --- a/modules/programs/neovim/bash.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ pkgs, lib, ... }: - -let grammars = with pkgs.vimPlugins.nvim-treesitter-parsers; [ - bash -]; -in -{ - programs.neovim = { - extraPackages = with pkgs; [ - nodePackages_latest.bash-language-server - shfmt - shellcheck - ]; - plugins = with pkgs.vimPlugins; grammars ++ [ - ]; - extraLuaConfig = '' - addServers({ - bashls = {} - }) - ''; - }; -} diff --git a/modules/programs/neovim/default.nix b/modules/programs/neovim/default.nix index 67ac7e7..3e1f166 100644 --- a/modules/programs/neovim/default.nix +++ b/modules/programs/neovim/default.nix @@ -1,56 +1,8 @@ -{ pkgs, lib, config, ... }: -let - grammars = with pkgs.vimPlugins.nvim-treesitter-parsers; [ - diff - regex - vimdoc - comment - markdown - ungrammar - gitignore - gitcommit - git_rebase - git_config - gitattributes - dockerfile - ]; - cfg = config.programs.nv; -in +{ nvim, ... }: +nvim { - imports = [ ./firenvim.nix ./py.nix ./hs.nix ./bash.nix ./nix.nix ./lua.nix ./js.nix ./util.nix ]; - - options.programs.nv = { - enable = lib.mkEnableOption "nv"; - }; - - config = lib.mkIf cfg.enable { - programs.neovim = { - enable = true; - viAlias = true; - extraPackages = with pkgs; [ - ripgrep - ]; - plugins = with pkgs.vimPlugins; grammars ++ [ - nvim-treesitter - nvim-surround - nvim-ts-autotag - autoclose-nvim - barbar-nvim - cmp-nvim-lsp - comment-nvim - gitsigns-nvim - luasnip - catppuccin-nvim - nvim-cmp - nvim-lspconfig - nvim-web-devicons - plenary-nvim - telescope-nvim - toggleterm-nvim - vim-vinegar - lualine-nvim - ]; - extraLuaConfig = lib.fileContents ./nvim/default.lua; - }; + enable = true; + plugins.lsp.servers = { + bashls.enable = true; }; } diff --git a/modules/programs/neovim/hs.nix b/modules/programs/neovim/hs.nix deleted file mode 100644 index e0049b6..0000000 --- a/modules/programs/neovim/hs.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ pkgs, lib, ... }: - -let grammars = with pkgs.vimPlugins.nvim-treesitter-parsers; [ - haskell -]; -in -{ - programs.neovim = { - extraPackages = with pkgs; [ - haskell-language-server - ]; - plugins = with pkgs.vimPlugins; grammars ++ [ - ]; - extraLuaConfig = '' - addServers({ - hls = {} - }) - ''; - }; -} diff --git a/modules/programs/neovim/js.nix b/modules/programs/neovim/js.nix deleted file mode 100644 index dc9fee6..0000000 --- a/modules/programs/neovim/js.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ pkgs, lib, ... }: - -let grammars = with pkgs.vimPlugins.nvim-treesitter-parsers; [ - tsx - jsdoc - json - json5 - jsonnet - http - html - astro - svelte - prisma - graphql - typescript - javascript -]; -in -{ - programs.neovim = { - extraPackages = with pkgs; [ - nodePackages_latest.prettier - nodePackages_latest.typescript - nodePackages_latest.typescript-language-server - nodePackages_latest."@tailwindcss/language-server" - nodePackages_latest."@prisma/language-server" - nodePackages_latest.vscode-html-languageserver-bin - ]; - plugins = with pkgs.vimPlugins; grammars ++ [ - vim-prisma - ]; - extraLuaConfig = '' - addServers({ - tsserver = {}, - tailwindcss = {}, - prismals = {}, - html = { - cmd = { "html-languageserver", "--stdio" } - }, - }) - ''; - }; -} diff --git a/modules/programs/neovim/lua.nix b/modules/programs/neovim/lua.nix deleted file mode 100644 index 1feda69..0000000 --- a/modules/programs/neovim/lua.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ pkgs, lib, ... }: - -let grammars = with pkgs.vimPlugins.nvim-treesitter-parsers; [ - lua - luadoc - luau - luap -]; -in -{ - programs.neovim = { - extraPackages = with pkgs; [ - lua - lua-language-server - stylua - ]; - plugins = with pkgs.vimPlugins; grammars ++ [ - ]; - extraLuaConfig = '' - addServers({ - lua_ls = {} - }) - ''; - }; -} diff --git a/modules/programs/neovim/nix.nix b/modules/programs/neovim/nix.nix deleted file mode 100644 index 0a0c69e..0000000 --- a/modules/programs/neovim/nix.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ pkgs, lib, ... }: - -let grammars = with pkgs.vimPlugins.nvim-treesitter-parsers; [ - nix -]; -in -{ - programs.neovim = { - extraPackages = with pkgs; [ - nixd - nixpkgs-fmt - ]; - plugins = with pkgs.vimPlugins; grammars ++ [ - ]; - extraLuaConfig = '' - addServers({ - nixd = {} - }) - ''; - }; -} diff --git a/modules/programs/neovim/nvim/default.lua b/modules/programs/neovim/nvim/default.lua deleted file mode 100644 index fb312fc..0000000 --- a/modules/programs/neovim/nvim/default.lua +++ /dev/null @@ -1,126 +0,0 @@ -vim.wo.number = true -vim.o.scrolloff = 15 -vim.o.hlsearch = false -vim.o.updatetime = 20 -vim.o.autoread = true -vim.o.tabstop = 4 -vim.o.shiftwidth = 2 -vim.o.expandtab = true - -vim.g.mapleader = " " -vim.g.maplocalleader = " " -vim.keymap.set({ "n", "v" }, "", "", { silent = true }) -- nop leader - -local nmap = function(keys, cmd) - vim.keymap.set("n", keys, cmd, { noremap = true, silent = true }) -end -local vmap = function(keys, cmd) - vim.keymap.set("v", keys, cmd, { noremap = true, silent = true }) -end -local tmap = function(keys, cmd) - vim.keymap.set("t", keys, cmd, { noremap = true, silent = true }) -end - -nmap("/", require("Comment.api").toggle.linewise.current) -vmap("/", "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())") - -nmap("", "BufferNext") -nmap("", "BufferPrevious") -nmap("x", "BufferClose") - -nmap("h", "ToggleTerm") -tmap("h", "ToggleTerm") - -nmap("r", "!%:p") - -nmap("ff", require("telescope.builtin").find_files) -nmap("fw", require("telescope.builtin").live_grep) -nmap("e", vim.diagnostic.open_float) - -local cmp = require("cmp") -local lspconfig = require("lspconfig") -local cmp_capabilities = require("cmp_nvim_lsp").default_capabilities() -local on_attach = function(client, bufnr) - nmap("ca", vim.lsp.buf.code_action) - nmap("lr", vim.lsp.buf.rename) - nmap("gd", vim.lsp.buf.definition) - nmap("lf", function() - vim.lsp.buf.format() - end) - nmap("K", vim.lsp.buf.hover) - nmap("gr", require("telescope.builtin").lsp_references) - if client.server_capabilities.documentHighlightProvider then - vim.api.nvim_create_autocmd("CursorHold", { - buffer = bufnr, - callback = function() - vim.lsp.buf.document_highlight() - end, - }) - vim.api.nvim_create_autocmd("CursorMoved", { - buffer = bufnr, - callback = function() - vim.lsp.buf.clear_references() - end, - }) - end -end -cmp.setup({ - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.confirm({ select = true }), - }), - sources = cmp.config.sources({ { name = "nvim_lsp" }, { name = "luasnip" } }, { { name = "buffer" } }), -}) - -for server, cfg in pairs(servers) do - lspconfig[server].setup({ - cmd = cfg.cmd, - settings = cfg.settings, - capabilities = cmp_capabilities, - on_attach = on_attach, - }) -end - - -require 'nvim-treesitter.configs'.setup { - autotag = { - enable = true, - } -} - -require("Comment").setup() -require("toggleterm").setup() -require("autoclose").setup() -require("gitsigns").setup() -require("nvim-surround").setup() -require("telescope").setup { - defaults = { - file_ignore_patterns = { "hosts" }, - } -} - -require("lualine").setup({ - options = { - theme = "catppuccin" - } -}) -require("catppuccin").setup({ - flavour = "mocha", - transparent_background = true, - integrations = { - cmp = true, - gitsigns = true, - treesitter = true, - telescope = { - enabled = true, - }, - markdown = true - }, -}) - -vim.cmd.colorscheme("catppuccin") diff --git a/modules/programs/neovim/nvim/util.lua b/modules/programs/neovim/nvim/util.lua deleted file mode 100644 index c9e3925..0000000 --- a/modules/programs/neovim/nvim/util.lua +++ /dev/null @@ -1,27 +0,0 @@ -local servers = {} - -local addServers = function(srv) - servers = vim.tbl_deep_extend("force", servers, srv) -end - -local function dump(o) - if type(o) == 'table' then - local s = '{ ' - for k, v in pairs(o) do - if type(k) ~= 'number' then k = '"' .. k .. '"' end - s = s .. '[' .. k .. '] = ' .. dump(v) .. ',' - end - return s .. '} ' - else - return tostring(o) - end -end - -local function log(o) - local file = io.open("./.nvim.log", "a+") - if file then - file:write(os.date("%Y/%m/%d %H:%M:%S") .. " || " .. dump(o) .. "\n") - file:write("---\n") - file:close() - end -end diff --git a/modules/programs/neovim/py.nix b/modules/programs/neovim/py.nix deleted file mode 100644 index 73766f8..0000000 --- a/modules/programs/neovim/py.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ pkgs, lib, ... }: - -let grammars = with pkgs.vimPlugins.nvim-treesitter-parsers; [ - python -]; -in -{ - programs.neovim = { - extraPackages = with pkgs; [ - python311Packages.python-lsp-server - ]; - plugins = with pkgs.vimPlugins; grammars ++ [ - ]; - extraLuaConfig = '' - addServers({ - pylsp = {}, - }) - ''; - }; -} diff --git a/modules/programs/neovim/util.nix b/modules/programs/neovim/util.nix deleted file mode 100644 index 3c0039f..0000000 --- a/modules/programs/neovim/util.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ pkgs, lib, ... }: -{ - programs.neovim = { - extraLuaConfig = lib.fileContents ./nvim/util.lua; - }; -}