From f13121056193a822ebca4bbeb446c7a8a0c458f1 Mon Sep 17 00:00:00 2001 From: Payas Relekar Date: Wed, 13 Sep 2023 19:11:31 +0530 Subject: [PATCH] emacs: Load neovim config from a Lua file this allows for better editing experience compared to the stringly mess from before. So now Emacs is good for modifying NeoVim config, with support for both Nix and Lua, and NeoVim is capable of editing Emacs config via orgmode. Nice :) --- hosts/bebop/home.nix | 3 ++- hosts/hermes/doom/config.org | 2 +- hosts/hermes/home.nix | 1 + modules/common-home.nix | 48 +----------------------------------- modules/neovim/init.lua | 32 ++++++++++++++++++++++++ modules/neovim/nvim.nix | 24 ++++++++++++++++++ modules/root-home.nix | 2 +- 7 files changed, 62 insertions(+), 50 deletions(-) create mode 100644 modules/neovim/init.lua create mode 100644 modules/neovim/nvim.nix diff --git a/hosts/bebop/home.nix b/hosts/bebop/home.nix index 40d68c4..d692742 100644 --- a/hosts/bebop/home.nix +++ b/hosts/bebop/home.nix @@ -1,7 +1,8 @@ -{ config, pkgs, ... }: +{ ... }: { imports = [ ../../modules/common-home.nix + ../../modules/neovim/nvim.nix ]; } diff --git a/hosts/hermes/doom/config.org b/hosts/hermes/doom/config.org index 64804ea..dbba957 100644 --- a/hosts/hermes/doom/config.org +++ b/hosts/hermes/doom/config.org @@ -1162,7 +1162,7 @@ When Emacs is opened in Windows Subsystem for Linux, open web links in Firefox o ** Lua #+begin_src emacs-lisp :lexical t (use-package! lua-mode - :config + :init (setq! lua-indent-close-paren-align nil lua-indent-level 4 lua-indent-nested-block-content-align t)) diff --git a/hosts/hermes/home.nix b/hosts/hermes/home.nix index 805473b..e3e7d31 100644 --- a/hosts/hermes/home.nix +++ b/hosts/hermes/home.nix @@ -3,6 +3,7 @@ { imports = [ ../../modules/common-home.nix + ../../modules/neovim/nvim.nix ./mail.nix ./emacs.nix diff --git a/modules/common-home.nix b/modules/common-home.nix index c6d7273..7585fd4 100644 --- a/modules/common-home.nix +++ b/modules/common-home.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ config, ... }: { home.stateVersion = "22.05"; @@ -78,52 +78,6 @@ enableFishIntegration = true; }; - neovim = { - enable = true; - vimAlias = true; - withPython3 = false; - withRuby = false; - withNodeJs = false; - plugins = with pkgs.vimPlugins; [ - nvim-treesitter.withAllGrammars - neogit - orgmode - lualine-nvim - ]; - extraConfig = '' - set nobackup - set number - set relativenumber - ''; - extraLuaConfig = '' - -- Neogit (magit clone) - local neogit = require('neogit') - neogit.setup {} - - -- Lualine - require('lualine').setup() - - -- Load custom treesitter grammar for org filetype - require('orgmode').setup_ts_grammar() - - -- Treesitter configuration - require('nvim-treesitter.configs').setup { - -- If TS highlights are not enabled at all, or disabled via `disable` prop, - -- highlighting will fallback to default Vim syntax highlighting - highlight = { - enable = true, - -- Required for spellcheck, some LaTex highlights and - -- code block highlights that do not have ts grammar - additional_vim_regex_highlighting = {'org'}, - }, - } - - require('orgmode').setup({ - org_agenda_files = {'~/org/**/*'}, - }) - ''; - }; - htop = { enable = true; settings = { diff --git a/modules/neovim/init.lua b/modules/neovim/init.lua new file mode 100644 index 0000000..db24cf1 --- /dev/null +++ b/modules/neovim/init.lua @@ -0,0 +1,32 @@ +-- Vim/NeoVim built-ins +vim.o.nobackup = true +vim.o.number = true +vim.o.relativenumber = true + +-- Neogit (magit clone) +require('neogit').setup() + +-- Lualine +require('lualine').setup() + +-- Load custom treesitter grammar for org filetype +require('orgmode').setup_ts_grammar() + +-- Treesitter configuration +require('nvim-treesitter.configs').setup { + -- If TS highlights are not enabled at all, or disabled via `disable` prop, + -- highlighting will fallback to default Vim syntax highlighting + highlight = { + enable = true, + -- Required for spellcheck, some LaTex highlights and + -- code block highlights that do not have ts grammar + additional_vim_regex_highlighting = {'org'}, + }, +} + +-- Orgmode +require('orgmode').setup({ + org_agenda_files = { + '~/org/**/*' + }, +}) diff --git a/modules/neovim/nvim.nix b/modules/neovim/nvim.nix new file mode 100644 index 0000000..0671ca4 --- /dev/null +++ b/modules/neovim/nvim.nix @@ -0,0 +1,24 @@ +{ pkgs, ... }: +{ + xdg.configFile = { + "nvim/init.lua" = { + source = ./init.lua; + }; + }; + + programs = { + neovim = { + enable = true; + vimAlias = true; + withPython3 = false; + withRuby = false; + withNodeJs = false; + plugins = with pkgs.vimPlugins; [ + nvim-treesitter.withAllGrammars + neogit + orgmode + lualine-nvim + ]; + }; + }; +} diff --git a/modules/root-home.nix b/modules/root-home.nix index c80cb82..6df54a9 100644 --- a/modules/root-home.nix +++ b/modules/root-home.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ ... }: { imports = [