Decoupling config from nvim (#1038)

This commit is contained in:
Christian Chiarulli 2021-07-19 22:50:07 -04:00 committed by GitHub
parent acb6a7a2ce
commit d02265175f
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 63 additions and 39 deletions

View file

@ -1,5 +1,17 @@
vim.cmd [[
set packpath-=~/.config/nvim
set packpath-=~/.config/nvim/after
set packpath-=~/.local/share/nvim/site
set packpath^=~/.local/share/lunarvim/site
set packpath^=~/.config/lvim
set runtimepath-=~/.config/nvim
set runtimepath-=~/.config/nvim/after
set runtimepath^=~/.config/lvim
]]
-- vim.opt.rtp:append() instead of vim.cmd ?
require "default-config" require "default-config"
local status_ok, error = pcall(vim.cmd, "luafile " .. CONFIG_PATH .. "/lv-config.lua") local status_ok, error = pcall(vim.cmd, "luafile ~/.config/lvim/lv-config.lua")
if not status_ok then if not status_ok then
print "something is wrong with your lv-config" print "something is wrong with your lv-config"
print(error) print(error)

View file

@ -43,7 +43,8 @@ M.config = function()
}, },
d = { d = {
description = { " Settings " }, description = { " Settings " },
command = ":e " .. CONFIG_PATH .. "/lv-config.lua", -- command = ":e " .. CONFIG_PATH .. "/lv-config.lua",
command = ":e ~/.config/lvim/lv-config.lua",
}, },
}, },
@ -67,8 +68,8 @@ M.setup = function()
-- command = "Telescope find_files cwd=" .. CONFIG_PATH, -- command = "Telescope find_files cwd=" .. CONFIG_PATH,
-- }, -- },
-- e = {description = {' Marks '}, command = 'Telescope marks'} -- e = {description = {' Marks '}, command = 'Telescope marks'}
vim.cmd "let g:dashboard_session_directory = $HOME..'/.config/nvim/.sessions'" vim.cmd 'let g:dashboard_session_directory = "~/.config/lvim/.sessions"'
vim.cmd "let packages = len(globpath('~/.local/share/nvim/site/pack/packer/start', '*', 0, 1))" vim.cmd "let packages = len(globpath('~/.local/share/lunarvim/site/pack/packer/start', '*', 0, 1))"
vim.api.nvim_exec( vim.api.nvim_exec(
[[ [[

View file

@ -281,7 +281,7 @@ table.insert(gls.right, {
condition = condition.hide_in_width, condition = condition.hide_in_width,
separator = " ", separator = " ",
separator_highlight = { "NONE", colors.alt_bg }, separator_highlight = { "NONE", colors.alt_bg },
highlight = { colors.alt_bg, colors.alt_bg }, highlight = { colors.grey, colors.alt_bg },
}, },
}) })

View file

@ -3,7 +3,7 @@ local M = {}
M.setup = function() M.setup = function()
if O.lint_on_save then if O.lint_on_save then
require("lv-utils").define_augroups { require("lv-utils").define_augroups {
autolint = { autolint_on_save = {
{ {
"BufWritePost", "BufWritePost",
"<buffer>", "<buffer>",

View file

@ -64,7 +64,7 @@ M.config = function()
["w"] = { "<cmd>w!<CR>", "Save" }, ["w"] = { "<cmd>w!<CR>", "Save" },
["q"] = { "<cmd>q!<CR>", "Quit" }, ["q"] = { "<cmd>q!<CR>", "Quit" },
["/"] = { "<cmd>CommentToggle<CR>", "Comment" }, ["/"] = { "<cmd>CommentToggle<CR>", "Comment" },
["c"] = { "<cmd>BufferClose<CR>", "Close Buffer" }, ["c"] = { "<cmd>BufferClose!<CR>", "Close Buffer" },
["e"] = { "<cmd>lua require'core.nvimtree'.toggle_tree()<CR>", "Explorer" }, ["e"] = { "<cmd>lua require'core.nvimtree'.toggle_tree()<CR>", "Explorer" },
["f"] = { "<cmd>Telescope find_files<CR>", "Find File" }, ["f"] = { "<cmd>Telescope find_files<CR>", "Find File" },
["h"] = { '<cmd>let @/=""<CR>', "No Highlight" }, ["h"] = { '<cmd>let @/=""<CR>', "No Highlight" },

View file

@ -1,4 +1,4 @@
CONFIG_PATH = vim.fn.stdpath "config" CONFIG_PATH = os.getenv "HOME" .. "/.local/share/lunarvim/lvim"
DATA_PATH = vim.fn.stdpath "data" DATA_PATH = vim.fn.stdpath "data"
CACHE_PATH = vim.fn.stdpath "cache" CACHE_PATH = vim.fn.stdpath "cache"
TERMINAL = vim.fn.expand "$TERMINAL" TERMINAL = vim.fn.expand "$TERMINAL"
@ -13,7 +13,7 @@ O = {
transparent_window = false, transparent_window = false,
format_on_save = true, format_on_save = true,
lint_on_save = true, lint_on_save = true,
vsnip_dir = vim.fn.stdpath "config" .. "/snippets", vsnip_dir = os.getenv "HOME" .. "/.config/snippets",
default_options = { default_options = {
backup = false, -- creates a backup file backup = false, -- creates a backup file

View file

@ -58,7 +58,8 @@ M.lsp = function()
else else
print "Unsupported system" print "Unsupported system"
end end
JAVA_LS_EXECUTABLE = CONFIG_PATH .. "/utils/bin/jdtls"
JAVA_LS_EXECUTABLE = os.getenv "HOME" .. "/.local/share/lunarvim/lvim/utils/bin/jdtls"
require("jdtls").start_or_attach { require("jdtls").start_or_attach {
on_attach = require("lsp").common_on_attach, on_attach = require("lsp").common_on_attach,

View file

@ -59,11 +59,12 @@ M.lsp = function()
}, },
diagnostics = { diagnostics = {
-- Get the language server to recognize the `vim` global -- Get the language server to recognize the `vim` global
globals = { "vim" }, globals = { "vim", "O" },
}, },
workspace = { workspace = {
-- Make the server aware of Neovim runtime files -- Make the server aware of Neovim runtime files
library = { library = {
[vim.fn.expand "~/.local/share/lunarvim/lvim/lua"] = true,
[vim.fn.expand "$VIMRUNTIME/lua"] = true, [vim.fn.expand "$VIMRUNTIME/lua"] = true,
[vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true, [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true,
}, },

View file

@ -57,11 +57,13 @@ function lv_utils.generate_settings()
end end
function lv_utils.reload_lv_config() function lv_utils.reload_lv_config()
vim.cmd "source ~/.config/nvim/lua/keymappings.lua" vim.cmd "source ~/.config/lvim/lv-config.lua"
vim.cmd "source ~/.config/nvim/lv-config.lua" vim.cmd "source ~/.local/share/lunarvim/lvim/lua/plugins.lua"
vim.cmd "source ~/.config/nvim/lua/plugins.lua" local plugins = require "plugins"
vim.cmd "source ~/.config/nvim/lua/settings.lua" local plugin_loader = require("plugin-loader").init()
vim.cmd "source ~/.config/nvim/lua/core/formatter.lua" plugin_loader:load { plugins, O.user_plugins }
vim.cmd "source ~/.local/share/lunarvim/lvim/lua/settings.lua"
vim.cmd "source ~/.local/share/lunarvim/lvim/lua/core/formatter.lua"
vim.cmd ":PackerCompile" vim.cmd ":PackerCompile"
vim.cmd ":PackerInstall" vim.cmd ":PackerInstall"
-- vim.cmd ":PackerClean" -- vim.cmd ":PackerClean"

View file

@ -4,7 +4,7 @@ function plugin_loader:init()
local execute = vim.api.nvim_command local execute = vim.api.nvim_command
local fn = vim.fn local fn = vim.fn
local install_path = fn.stdpath "data" .. "/site/pack/packer/start/packer.nvim" local install_path = "~/.local/share/lunarvim/site/pack/packer/start/packer.nvim"
if fn.empty(fn.glob(install_path)) > 0 then if fn.empty(fn.glob(install_path)) > 0 then
execute("!git clone https://github.com/wbthomason/packer.nvim " .. install_path) execute("!git clone https://github.com/wbthomason/packer.nvim " .. install_path)
execute "packadd packer.nvim" execute "packadd packer.nvim"
@ -15,12 +15,15 @@ function plugin_loader:init()
return return
end end
local util = require "packer.util"
packer.init { packer.init {
-- package_root = require("packer.util").join_paths(vim.fn.stdpath "data", "lvim", "pack"), package_root = util.join_paths "~/.local/share/lunarvim/site/pack/",
compile_path = util.join_paths("~/.config/lvim", "plugin", "packer_compiled.lua"),
git = { clone_timeout = 300 }, git = { clone_timeout = 300 },
display = { display = {
open_fn = function() open_fn = function()
return require("packer.util").float { border = "single" } return util.float { border = "single" }
end, end,
}, },
} }

View file

@ -40,16 +40,16 @@ fi
# JAR="$HOME/.config/nvim/.language-servers/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/plugins/org.eclipse.equinox.launcher_*.jar" # JAR="$HOME/.config/nvim/.language-servers/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/plugins/org.eclipse.equinox.launcher_*.jar"
JAR="$HOME/.local/share/nvim/lspinstall/java/plugins/org.eclipse.equinox.launcher_*.jar" JAR="$HOME/.local/share/nvim/lspinstall/java/plugins/org.eclipse.equinox.launcher_*.jar"
GRADLE_HOME="$HOME/gradle" "$JAVACMD" \ GRADLE_HOME=$HOME/gradle "$JAVACMD" \
-Declipse.application=org.eclipse.jdt.ls.core.id1 \ -Declipse.application=org.eclipse.jdt.ls.core.id1 \
-Dosgi.bundles.defaultStartLevel=4 \ -Dosgi.bundles.defaultStartLevel=4 \
-Declipse.product=org.eclipse.jdt.ls.core.product \ -Declipse.product=org.eclipse.jdt.ls.core.product \
-Dlog.protocol=true \ -Dlog.protocol=true \
-Dlog.level=ALL \ -Dlog.level=ALL \
-javaagent:"$HOME/.local/share/nvim/lspinstall/java/lombok.jar" \ -javaagent:$HOME/.local/share/nvim/lspinstall/java/lombok.jar \
-Xms1g \ -Xms1g \
-Xmx2G \ -Xmx2G \
-jar "$JAR" \ -jar $(echo "$JAR") \
-configuration "$CONFIG" \ -configuration "$CONFIG" \
-data "${1:-$HOME/workspace}" \ -data "${1:-$HOME/workspace}" \
--add-modules=ALL-SYSTEM \ --add-modules=ALL-SYSTEM \

3
utils/bin/lvim Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" "$@"

View file

@ -15,9 +15,9 @@ installnodeubuntu() {
sudo apt install npm sudo apt install npm
} }
moveoldnvim() { moveoldlvim() {
echo "Not installing LunarVim" echo "Not installing LunarVim"
echo "Please move your ~/.config/nvim folder before installing" echo "Please move your ~/.local/share/lunarvim folder before installing"
exit exit
} }
@ -96,25 +96,27 @@ installpynvim() {
} }
installpacker() { installpacker() {
git clone https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/start/packer.nvim git clone https://github.com/wbthomason/packer.nvim ~/.local/share/lunarvim/site/pack/packer/start/packer.nvim
} }
cloneconfig() { cloneconfig() {
echo "Cloning LunarVim configuration" echo "Cloning LunarVim configuration"
git clone --branch "$LVBRANCH" https://github.com/ChristianChiarulli/lunarvim.git ~/.config/nvim git clone --branch "$LVBRANCH" https://github.com/ChristianChiarulli/lunarvim.git ~/.local/share/lunarvim/lvim
cp "$HOME/.config/nvim/utils/installer/lv-config.example-no-ts.lua" "$HOME/.config/nvim/lv-config.lua" mkdir -p "$HOME/.config/lvim"
nvim --headless \ sudo cp "$HOME/.local/share/lunarvim/lvim/utils/bin/lvim" "/usr/local/bin"
cp "$HOME/.local/share/lunarvim/lvim/utils/installer/lv-config.example-no-ts.lua" "$HOME/.config/lvim/lv-config.lua"
nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" --headless \
+'autocmd User PackerComplete sleep 100m | qall' \ +'autocmd User PackerComplete sleep 100m | qall' \
+PackerInstall +PackerInstall
nvim --headless \ nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" --headless \
+'autocmd User PackerComplete sleep 100m | qall' \ +'autocmd User PackerComplete sleep 100m | qall' \
+PackerSync +PackerSync
printf "\nCompile Complete\n" printf "\nCompile Complete\n"
rm "$HOME/.config/nvim/lv-config.lua" rm "$HOME/.config/lvim/lv-config.lua"
cp "$HOME/.config/nvim/utils/installer/lv-config.example.lua" "$HOME/.config/nvim/lv-config.lua" cp "$HOME/.local/share/lunarvim/lvim/utils/installer/lv-config.example.lua" "$HOME/.config/lvim/lv-config.lua"
# nvim --headless -cq ':silent TSUpdate' -cq ':qall' >/dev/null 2>&1
} }
asktoinstallnode() { asktoinstallnode() {
@ -176,15 +178,14 @@ echo 'Installing LunarVim'
case "$@" in case "$@" in
*--overwrite*) *--overwrite*)
echo '!!Warning!! -> Removing all nvim related config because of the --overwrite flag' echo '!!Warning!! -> Removing all lunarvim related config because of the --overwrite flag'
rm -rf "$HOME/.config/nvim" rm -rf "$HOME/.local/share/lunarvim"
rm -rf "$HOME/.cache/nvim" rm -rf "$HOME/.cache/nvim"
rm -rf "$HOME/.local/share/nvim/site/pack/packer"
;; ;;
esac esac
# move old nvim directory if it exists # move old lvim directory if it exists
[ -d "$HOME/.config/nvim" ] && moveoldnvim [ -d "$HOME/.local/share/lunarvim" ] && moveoldlvim
# install pip # install pip
(command -v pip3 >/dev/null && echo "pip installed, moving on...") || asktoinstallpip (command -v pip3 >/dev/null && echo "pip installed, moving on...") || asktoinstallpip
@ -195,13 +196,13 @@ esac
# install pynvim # install pynvim
(pip3 list | grep pynvim >/dev/null && echo "pynvim installed, moving on...") || installpynvim (pip3 list | grep pynvim >/dev/null && echo "pynvim installed, moving on...") || installpynvim
if [ -e "$HOME/.local/share/nvim/site/pack/packer/start/packer.nvim" ]; then if [ -e "$HOME/.local/share/lunarvim/site/pack/packer/start/packer.nvim" ]; then
echo 'packer already installed' echo 'packer already installed'
else else
installpacker installpacker
fi fi
if [ -e "$HOME/.config/nvim/init.lua" ]; then if [ -e "$HOME/.local/share/lunarvim/lvim/init.lua" ]; then
echo 'LunarVim already installed' echo 'LunarVim already installed'
else else
# clone config down # clone config down