From 92caa088aa994bc2f58108c0ce6c12ffe967ba85 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 15 May 2022 21:56:19 +0300 Subject: [PATCH] feat: no more using nix to install nvim plugins --- README.md | 3 + dotfiles/neovim/init.lua | 5 - dotfiles/neovim/lua/my/init.lua | 13 ++ dotfiles/neovim/lua/my/options/files.lua | 1 - dotfiles/neovim/lua/my/paq.lua | 49 ++++++ dotfiles/neovim/lua/my/plugins/lspconfig.lua | 31 ++-- dotfiles/neovim/lua/my/plugins/telescope.lua | 4 +- dotfiles/neovim/lua/my/plugins/treesitter.lua | 8 +- dotfiles/tmux/tmux.conf | 2 +- modules/applications/neovim.nix | 148 +++++++----------- modules/default.nix | 1 + modules/meta/default.nix | 3 + modules/meta/simlink.nix | 13 ++ modules/themes/catppuccin/default.nix | 10 +- modules/themes/catppuccin/foreign.nix | 6 - modules/themes/catppuccin/nvim.lua | 20 ++- 16 files changed, 182 insertions(+), 135 deletions(-) delete mode 100644 dotfiles/neovim/init.lua create mode 100644 dotfiles/neovim/lua/my/init.lua create mode 100644 dotfiles/neovim/lua/my/paq.lua create mode 100644 modules/meta/default.nix create mode 100644 modules/meta/simlink.nix diff --git a/README.md b/README.md index 5f4699b..3468157 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,6 @@ My flake based nixos configuration. To use this, just rebuild your system using - automatically save/restore state using continuum - customize status bar - clean out the mess I made for installing fish themes +- customize picom +- vim: + - configure lualine more diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua deleted file mode 100644 index 6f28d6c..0000000 --- a/dotfiles/neovim/init.lua +++ /dev/null @@ -1,5 +0,0 @@ --- Import my other files -require("my.options").setup() -require('my.keymaps').setup() -require('my.plugins').setup() -require("telescope.extensions.unicode").setupAbbreviations() diff --git a/dotfiles/neovim/lua/my/init.lua b/dotfiles/neovim/lua/my/init.lua new file mode 100644 index 0000000..0c5cb1c --- /dev/null +++ b/dotfiles/neovim/lua/my/init.lua @@ -0,0 +1,13 @@ +local M = {} + +function M.setup() + -- Import my other files + require("my.paq").setup() + require("my.theme").setup() + require("my.options").setup() + require('my.keymaps').setup() + require('my.plugins').setup() + require("telescope.extensions.unicode").setupAbbreviations() +end + +return M diff --git a/dotfiles/neovim/lua/my/options/files.lua b/dotfiles/neovim/lua/my/options/files.lua index 0e79706..8b3f19f 100644 --- a/dotfiles/neovim/lua/my/options/files.lua +++ b/dotfiles/neovim/lua/my/options/files.lua @@ -10,7 +10,6 @@ function M.setup() "setf " .. syntax) end end) - end return M diff --git a/dotfiles/neovim/lua/my/paq.lua b/dotfiles/neovim/lua/my/paq.lua new file mode 100644 index 0000000..85e5dd4 --- /dev/null +++ b/dotfiles/neovim/lua/my/paq.lua @@ -0,0 +1,49 @@ +local M = {} + +function M.setup() + local paq = require("paq") + local themePackages = require("my.theme").deps + local base = { + "neovim/nvim-lspconfig", -- configures lsps for me + "windwp/nvim-autopairs", -- closes pairs for me (should look for a better one) + "nvim-lua/plenary.nvim", -- async utility lib it seems? + "nvim-telescope/telescope.nvim", -- fuzzy search for say opening files + "purescript-contrib/purescript-vim", -- purescript support + "terrortylor/nvim-comment", -- allows toggling line comments + {"nvim-treesitter/nvim-treesitter", run = ":TSUpdate"}, -- use treesitter for syntax highlighting + {"nvim-treesitter/nvim-treesitter-textobjects", run = ":TSUpdate"}, -- the lean plugin wants me to install this, lol + "startup-nvim/startup.nvim", -- splash screen + "kyazdani42/nvim-web-devicons", -- nice looking icons + "nvim-lualine/lualine.nvim", -- customizable status line + "kyazdani42/nvim-tree.lua", -- file tree + "lervag/vimtex", -- latex support + "jose-elias-alvarez/null-ls.nvim", -- generic language server + "nvim-telescope/telescope-file-browser.nvim", -- file creation/deletion menu + "onsails/lspkind.nvim", -- show icons in lsp completion menus + "preservim/vimux", -- interact with tmux from within vim + "christoomey/vim-tmux-navigator", -- easly switch between tmux and vim panes + "kana/vim-arpeggio", -- chord support, let"s fucking goooo + {"andweeb/presence.nvim", run = ":DownloadUnicode"}, -- discord rich presence + "Julian/lean.nvim", -- lean support + "kmonad/kmonad-vim", -- kmonad config support + "LucHermitte/lh-vim-lib", -- dependency for lh-brackets + "LucHermitte/lh-brackets", -- kinda useless bruh + -- Cmp related stuff + "hrsh7th/cmp-nvim-lsp", -- lsp completion + "hrsh7th/cmp-buffer", -- idr what this is + "hrsh7th/cmp-path", -- path completion ig? + "hrsh7th/cmp-cmdline", -- cmdline completion perhaps? + "hrsh7th/nvim-cmp", -- completion engine + "L3MON4D3/LuaSnip", -- snippeting engine + "saadparwaiz1/cmp_luasnip" -- snippet support for cmp + } + + for _, v in ipairs(themePackages) do + -- append package in the base list + table.insert(base, v) + end + + paq(base) +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/lspconfig.lua b/dotfiles/neovim/lua/my/plugins/lspconfig.lua index d55c0bd..adbef3a 100644 --- a/dotfiles/neovim/lua/my/plugins/lspconfig.lua +++ b/dotfiles/neovim/lua/my/plugins/lspconfig.lua @@ -3,6 +3,7 @@ local A = require("my.plugins.arpeggio") local M = {} local function map(buf, mode, lhs, rhs, opts) + local options = {noremap = true, silent = true} if opts then options = vim.tbl_extend('force', options, opts) end vim.api.nvim_buf_set_keymap(buf, mode, lhs, rhs, options) @@ -12,7 +13,8 @@ function M.on_attach(client, bufnr) -- Enable completion triggered by vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') - if client.resolved_capabilities.document_formatting then + if client.server_capabilities.documentFormattingProvider then + print("Initializing formatter...") vim.cmd([[ augroup LspFormatting autocmd! * @@ -21,36 +23,39 @@ function M.on_attach(client, bufnr) ]]) end + print("Setting up keybinds...") -- Go to declaration / definition / implementation map(bufnr, "n", 'gD', 'lua vim.lsp.buf.declaration()') map(bufnr, "n", 'gd', 'lua vim.lsp.buf.definition()') map(bufnr, 'n', 'gi', 'lua vim.lsp.buf.implementation()') -- Hover - map(bufnr, 'n', 'J', - "lua vim.lsp.diagnostic.show_line_diagnostics()") + map(bufnr, 'n', 'J', "lua vim.diagnostic.open_float()") map(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()') map(bufnr, 'n', 'L', 'lua vim.lsp.buf.signature_help()') -- Workspace stuff - map(bufnr, 'n', 'wa', - 'lua vim.lsp.buf.add_workspace_folder()') - map(bufnr, 'n', 'wr', - 'lua vim.lsp.buf.remove_workspace_folder()') - map(bufnr, 'n', 'wl', - 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))') + -- map(bufnr, 'n', 'wa', + -- 'lua vim.lsp.buf.add_workspace_folder()') + -- map(bufnr, 'n', 'wr', + -- 'lua vim.lsp.buf.remove_workspace_folder()') + -- map(bufnr, 'n', 'wl', + -- 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))') -- Code actions map(bufnr, 'n', 'D', 'lua vim.lsp.buf.type_definition()') map(bufnr, 'n', 'rn', 'lua vim.lsp.buf.rename()') - -- map(bufnr, 'n', 'ca', 'lua vim.lsp.buf.code_action()') + map(bufnr, 'n', 'ca', 'lua vim.lsp.buf.code_action()') map(bufnr, 'n', 'gr', 'lua vim.lsp.buf.references()') - map(bufnr, 'n', 'f', 'lua vim.lsp.buf.formatting()') + map(bufnr, 'n', 'f', + 'lua vim.lsp.buf.format({async = true})') + + print("Initialized language server!") end local function on_attach_typescript(client, bufnr) - client.resolved_capabilities.document_formatting = false - client.resolved_capabilities.document_range_formatting = false + -- We handle formatting using null-ls and prettierd + client.server_capabilities.documentFormattingProvider = false M.on_attach(client, bufnr) end diff --git a/dotfiles/neovim/lua/my/plugins/telescope.lua b/dotfiles/neovim/lua/my/plugins/telescope.lua index b6c51f7..6f84bb0 100644 --- a/dotfiles/neovim/lua/my/plugins/telescope.lua +++ b/dotfiles/neovim/lua/my/plugins/telescope.lua @@ -12,9 +12,7 @@ local bindings = { live_grep = "", -- See diagnostics with space + d - lsp_document_diagnostics = "d", - lsp_workspace_diagnostics = "wd", - lsp_code_actions = "ca", + diagnostics = "d", -- Open a list with all the pickers builtin = "t", diff --git a/dotfiles/neovim/lua/my/plugins/treesitter.lua b/dotfiles/neovim/lua/my/plugins/treesitter.lua index 9d002f5..6ed5218 100644 --- a/dotfiles/neovim/lua/my/plugins/treesitter.lua +++ b/dotfiles/neovim/lua/my/plugins/treesitter.lua @@ -2,10 +2,16 @@ local M = {} function M.setup() require'nvim-treesitter.configs'.setup { - ensure_installed = "maintained", + ensure_installed = { + "bash", "javascript", "typescript", "c", "cpp", "css", "dockerfile", + "elixir", "fish", "html", "json", "latex", "python", "rust", "scss", + "toml", "tsx", "vim", "yaml", "nix" + }, sync_install = false, + indent = {enable = true}, highlight = { enable = true, + disable = {"lua"}, -- WHY TF DOES THIS NOT WORK -- Setting this to true will run `:h syntax` and tree-sitter at the same time. -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). diff --git a/dotfiles/tmux/tmux.conf b/dotfiles/tmux/tmux.conf index a95d284..f7f5d95 100644 --- a/dotfiles/tmux/tmux.conf +++ b/dotfiles/tmux/tmux.conf @@ -40,4 +40,4 @@ set-option -g @fastcopy-action 'tmux load-buffer -w -' set-option -g @fastcopy-key a # Keep state around using resurrect -set -g @resurrect-processes '"./result/bin/qkm ./myConfig.json"' +set -g @resurrect-processes '"~python3"' diff --git a/modules/applications/neovim.nix b/modules/applications/neovim.nix index f230eaa..69bf683 100644 --- a/modules/applications/neovim.nix +++ b/modules/applications/neovim.nix @@ -1,101 +1,69 @@ -{ pkgs, lib, ... }: +{ pkgs, lib, paths, ... }: let + paq = pkgs.fetchFromGitHub { + owner = "savq"; + repo = "paq-nvim"; + rev = "cbbb8a550e35b1e6c9ddf7b098b25e6c2d8b1e86"; + sha256 = "0fsbww2kqwayi1azhglsjal6mwh68n03ylxxqzq17v7sar17vx4c"; + }; + theme = pkgs.myThemes.current; - # config-nvim = "/etc/nixos/configuration/dotfiles/neovim"; - config-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { - name = "config-nvim"; - src = ../../dotfiles/neovim; - }; + extraPackages = with pkgs; [ + # Language servers + # haskellPackages.agda-language-server # agda + nodePackages.typescript-language-server # typescript + easy-purescript-nix.purescript-language-server # purescript + sumneko-lua-language-server # lua + rnix-lsp # nix + haskell-language-server # haskell - # Lua code for importing a theme - loadTheme = (theme: '' - ${theme.neovim.theme} + # Formatters + luaformatter # lua + ormolu # haskell + prettierd # prettier but faster + # Others + fd # file finder + ripgrep # grep rewrite (I think?) + nodePackages.typescript # typescript language + update-nix-fetchgit # useful for nix stuff + tree-sitter # syntax highlighting + + texlive.combined.scheme-full # latex stuff + python38Packages.pygments # required for latex syntax highlighting + ]; + + myConfig = '' vim.g.lualineTheme = ${theme.neovim.lualineTheme} - ''); + vim.opt.runtimepath:append("${paths.dotfiles}/neovim") + -- dofile("${paths.dotfiles}/neovim/my/init.lua").setup() + require("my.init").setup() + ''; + + base = pkgs.neovim-nightly; + neovim = + pkgs.symlinkJoin { + inherit (base) name meta; + paths = [ base ]; + nativeBuildInputs = [ pkgs.makeWrapper ]; + postBuild = '' + wrapProgram $out/bin/nvim \ + --prefix PATH : ${lib.makeBinPath extraPackages} + ''; + }; - # Wrap a piece of lua code - lua = (code: '' - lua << EOF - ${code} - EOF - ''); in { - home-manager.users.adrielus.programs.neovim = { - enable = true; - package = pkgs.neovim-nightly; + home-manager.users.adrielus = + { + home.file.".local/share/nvim/site/pack/paqs/start/paq-nvim".source = paq; + xdg.configFile."nvim/init.lua".text = myConfig; + xdg.configFile."nvim/lua/my/theme.lua".source = theme.neovim.theme; + home.packages = [ neovim ]; - extraConfig = '' - ${lua (loadTheme theme)} - luafile ${config-nvim}/init.lua - ''; - - extraPackages = with pkgs; [ - # Language servers - # haskellPackages.agda-language-server # agda - nodePackages.typescript-language-server # typescript - easy-purescript-nix.purescript-language-server # purescript - sumneko-lua-language-server # lua - rnix-lsp # nix - haskell-language-server # haskell - - # Formatters - luaformatter # lua - ormolu # haskell - prettierd # prettier but faster - - # Others - fd # file finder - ripgrep # grep rewrite (I think?) - nodePackages.typescript # typescript language - update-nix-fetchgit # useful for nix stuff - - texlive.combined.scheme-full # latex stuff - python38Packages.pygments # required for latex syntax highlighting - ]; - - plugins = with pkgs.vimPlugins; - with pkgs.vimExtraPlugins; with pkgs.myVimPlugins; theme.neovim.plugins ++ [ - config-nvim # my neovim config - nvim-lspconfig # configures lsps for me - nvim-autopairs # close pairs for me - telescope-nvim # fuzzy search for say opening files - purescript-vim # purescript syntax highlighting - nvim-comment # allows toggling line-comments - nvim-treesitter # use treesitter for syntax highlighting - nvim-treesitter-textobjects # the lean plugin told me to add this - startup-nvim # splash screen - vim-devicons # nice looking icons - nvim-web-devicons # fork of vim-devicons? - plenary-nvim # async utility lib it seems? - lualine-nvim # customizable status line - nvim-tree-lua # file tree - vimtex # latex plugin - null-ls-nvim # generic language server - telescope-file-browser-nvim # file creation/deletion using telescope - lspkind-nvim # show icons in lsp completion menus - # symbols-outline-nvim # tree view for symbols in document - vimux # interact with tmux from within vim - vim-tmux-navigator # easly switch between tmux and vim panes - arpeggio # allows me to setup chord keybinds (keybinds where all the keys are pressed at the same time) - presence-nvim # discord rich presence - agda-nvim # agda support - unicode-vim # better unicode support - lean-nvim # lean support - kmonad # support for the kmonad config language - lh-vim-lib # dependency for lh-brackets - lh-brackets # bracket customization - - # Cmp related stuff. See https://github.com/hrsh7th/nvim-cmp - cmp-nvim-lsp - cmp-buffer - cmp-path - cmp-cmdline - cmp_luasnip - nvim-cmp # completion engine - luasnip # snippet engine - ]; - }; + programs.neovim = { + enable = false; + }; + }; } diff --git a/modules/default.nix b/modules/default.nix index 1818b82..6c646c7 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -4,6 +4,7 @@ ./applications ./themes ./overlays + ./meta ./network.nix ./xserver.nix diff --git a/modules/meta/default.nix b/modules/meta/default.nix new file mode 100644 index 0000000..f6f7bca --- /dev/null +++ b/modules/meta/default.nix @@ -0,0 +1,3 @@ +{ pkgs, ... }: { + home-manager.sharedModules = [ ./simlink.nix ]; +} diff --git a/modules/meta/simlink.nix b/modules/meta/simlink.nix new file mode 100644 index 0000000..cba8d4d --- /dev/null +++ b/modules/meta/simlink.nix @@ -0,0 +1,13 @@ +# This is a home-manager config!!! +{ pkgs, lib, config, ... }: with lib; { + options.home.sfile = mkOption { + description = "Attribute set of files to link into the user home without placing them into the store first"; + default = { }; + type = types.attrsOf types.string; + }; + config.systemd.user.tmpfiles.rules = mapAttrsToList + (name: value: + "L+ ${name} - - - - ${value}" + ) + config.home.sfile; +} diff --git a/modules/themes/catppuccin/default.nix b/modules/themes/catppuccin/default.nix index 3ba5613..e63cd44 100644 --- a/modules/themes/catppuccin/default.nix +++ b/modules/themes/catppuccin/default.nix @@ -9,16 +9,8 @@ in wallpaper = wallpaper.foreign or "${foreign.wallpapers}/${wallpaper}"; neovim = { - theme = builtins.readFile ./nvim.lua; + theme = ./nvim.lua; lualineTheme = "catppuccin"; - plugins = [ - ( - pkgs.vimUtils.buildVimPluginFrom2Nix { - name = "catppuccin"; - src = foreign.nvim; - } - ) - ]; }; # grub.path = "${foreign.grub}/catppuccin-grub-theme/theme.txt"; diff --git a/modules/themes/catppuccin/foreign.nix b/modules/themes/catppuccin/foreign.nix index 6a56eb9..887a135 100644 --- a/modules/themes/catppuccin/foreign.nix +++ b/modules/themes/catppuccin/foreign.nix @@ -1,10 +1,4 @@ { fetchFromGitHub, ... }: { - nvim = fetchFromGitHub { - owner = "catppuccin"; - repo = "nvim"; - sha256 = "1w96rvpbm7lk9lcc5i13d6dyb5b10vkjh1902xmklqvpzy1wya19"; - rev = "8a67df6da476cba68ecf26a519a5279686edbd2e"; - }; tmux = fetchFromGitHub { owner = "catppuccin"; repo = "tmux"; diff --git a/modules/themes/catppuccin/nvim.lua b/modules/themes/catppuccin/nvim.lua index df25908..d78a180 100644 --- a/modules/themes/catppuccin/nvim.lua +++ b/modules/themes/catppuccin/nvim.lua @@ -1,8 +1,16 @@ -local catppuccin = require("catppuccin") +local M = {} -catppuccin.setup({ - transparent_background = true, - integrations = {nvimtree = {transparent_panel = true}} -}) +M.deps = {{"catppuccin/nvim", as = "catppuccin"}} -vim.cmd [[colorscheme catppuccin]] +function M.setup() + local catppuccin = require("catppuccin") + + catppuccin.setup({ + transparent_background = true, + integrations = {nvimtree = {transparent_panel = true}} + }) + + vim.cmd [[colorscheme catppuccin]] +end + +return M