mirror of
https://github.com/LunarVim/LunarVim.git
synced 2024-09-20 18:45:08 +02:00
feat(windows): add custom config_win.example.lua (#2330)
This commit is contained in:
parent
637658ae2c
commit
4c705bc07d
10 changed files with 433 additions and 213 deletions
4
.github/workflows/format.yaml
vendored
4
.github/workflows/format.yaml
vendored
|
@ -1,10 +1,8 @@
|
|||
name: format
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: "**"
|
||||
pull_request:
|
||||
branches:
|
||||
- "master"
|
||||
- "rolling"
|
||||
|
||||
jobs:
|
||||
|
|
45
.github/workflows/install.yaml
vendored
45
.github/workflows/install.yaml
vendored
|
@ -1,7 +1,6 @@
|
|||
name: install
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["**"]
|
||||
pull_request:
|
||||
branches:
|
||||
- "master"
|
||||
|
@ -37,27 +36,27 @@ jobs:
|
|||
# NOTE: make sure to adjust the timeout if you start adding a lot of tests
|
||||
timeout-minutes: 4
|
||||
run: make test
|
||||
# freebsd:
|
||||
# runs-on: macos-latest
|
||||
# if: github.event.pull_request.draft == false
|
||||
# continue-on-error: true # we don't support freebsd yet
|
||||
# name: "FreeBSD macos-latest"
|
||||
# steps:
|
||||
# - uses: actions/checkout@v2
|
||||
|
||||
# - name: Install dependencies for FreeBSD
|
||||
# uses: vmactions/freebsd-vm@v0.1.5
|
||||
# with:
|
||||
# prepare: pkg install -y curl neovim
|
||||
# run: bash ./utils/installer/install.sh
|
||||
windows:
|
||||
name: "windows-latest"
|
||||
runs-on: windows-latest
|
||||
if: github.event.pull_request.draft == false
|
||||
continue-on-error: true # windows support is still experimental
|
||||
defaults:
|
||||
run:
|
||||
shell: pwsh
|
||||
steps:
|
||||
# it's not currently possbile to run tests on windows, see nvim-lua/plenary.nvim#255
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
# - name: Test LunarVim PackerCompile
|
||||
# uses: vmactions/freebsd-vm@v0.1.5
|
||||
# with:
|
||||
# run: if nvim --headless +PackerCompile -c ':qall' 2>&1|grep -q 'Error'; then false; fi
|
||||
|
||||
# - name: Test LunarVim Health
|
||||
# uses: vmactions/freebsd-vm@v0.1.5
|
||||
# with:
|
||||
# run: if nvim --headless +checkhealth -c ':qall' 2>&1|grep -q 'Error'; then false; fi
|
||||
- name: Install neovim binary
|
||||
uses: rhysd/action-setup-vim@v1
|
||||
with:
|
||||
neovim: true
|
||||
version: v0.6.1
|
||||
|
||||
- name: Install LunarVim
|
||||
timeout-minutes: 4
|
||||
run: |
|
||||
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
||||
pwsh.exe -NoLogo -ExecutionPolicy Bypass -NonInteractive -Command "./utils/installer/install.ps1 --local"
|
||||
|
|
4
.github/workflows/lint.yaml
vendored
4
.github/workflows/lint.yaml
vendored
|
@ -1,10 +1,8 @@
|
|||
name: lint
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: "**"
|
||||
pull_request:
|
||||
branches:
|
||||
- "master"
|
||||
- "rolling"
|
||||
|
||||
jobs:
|
||||
|
|
|
@ -153,7 +153,9 @@ function M.setup()
|
|||
end
|
||||
|
||||
if lvim.builtin.telescope.extensions and lvim.builtin.telescope.extensions.fzf then
|
||||
pcall(function()
|
||||
require("telescope").load_extension "fzf"
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
$env:XDG_DATA_HOME = ($env:XDG_DATA_HOME, "$env:APPDATA", 1 -ne $null)[0]
|
||||
$env:XDG_CONFIG_HOME = ($env:XDG_CONFIG_HOME, "$env:LOCALAPPDATA", 1 -ne $null)[0]
|
||||
$env:XDG_CACHE_HOME = ($env:XDG_CACHE_HOME, "$env:TEMP", 1 -ne $null)[0]
|
||||
#Requires -Version 7.1
|
||||
$ErrorActionPreference = "Stop" # exit when command fails
|
||||
|
||||
$env:LUNARVIM_RUNTIME_DIR = ($env:LUNARVIM_RUNTIME_DIR, "$env:XDG_DATA_HOME\lunarvim", 1 -ne $null)[0]
|
||||
$env:LUNARVIM_CONFIG_DIR = ($env:LUNARVIM_CONFIG_DIR, "$env:XDG_CONFIG_HOME\lvim", 1 -ne $null)[0]
|
||||
$env:LUNARVIM_CACHE_DIR = ($env:LUNARVIM_CACHE_DIR, "$env:XDG_CACHE_HOME\lvim", 1 -ne $null)[0]
|
||||
$env:XDG_DATA_HOME = $env:XDG_DATA_HOME ?? $env:APPDATA
|
||||
$env:XDG_CONFIG_HOME = $env:XDG_CONFIG_HOME ?? $env:LOCALAPPDATA
|
||||
$env:XDG_CACHE_HOME = $env:XDG_CACHE_HOME ?? $env:TEMP
|
||||
|
||||
$env:LUNARVIM_RUNTIME_DIR = $env:LUNARVIM_RUNTIME_DIR ?? "$env:XDG_DATA_HOME\lunarvim"
|
||||
$env:LUNARVIM_CONFIG_DIR = $env:LUNARVIM_CONFIG_DIR ?? "$env:XDG_CONFIG_HOME\lvim"
|
||||
$env:LUNARVIM_CACHE_DIR = $env:LUNARVIM_CACHE_DIR ?? "$env:XDG_CACHE_HOME\lvim"
|
||||
$env:LUNARVIM_BASE_DIR = $env:LUNARVIM_BASE_DIR ?? "$env:LUNARVIM_RUNTIME_DIR\lvim"
|
||||
|
||||
nvim -u "$env:LUNARVIM_RUNTIME_DIR\lvim\init.lua" @args
|
||||
|
|
166
utils/installer/config_win.example.lua
Normal file
166
utils/installer/config_win.example.lua
Normal file
|
@ -0,0 +1,166 @@
|
|||
--[[
|
||||
THESE ARE EXAMPLE CONFIGS FEEL FREE TO CHANGE TO WHATEVER YOU WANT
|
||||
`lvim` is the global options object
|
||||
]]
|
||||
|
||||
-- Enable powershell as your default shell
|
||||
vim.opt.shell = "pwsh.exe -NoLogo"
|
||||
vim.opt.shellcmdflag =
|
||||
"-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;"
|
||||
vim.cmd [[
|
||||
let &shellredir = '2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode'
|
||||
let &shellpipe = '2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode'
|
||||
set shellquote= shellxquote=
|
||||
]]
|
||||
|
||||
-- Set a compatible clipboard manager
|
||||
vim.g.clipboard = {
|
||||
copy = {
|
||||
["+"] = "win32yank.exe -i --crlf",
|
||||
["*"] = "win32yank.exe -i --crlf",
|
||||
},
|
||||
paste = {
|
||||
["+"] = "win32yank.exe -o --lf",
|
||||
["*"] = "win32yank.exe -o --lf",
|
||||
},
|
||||
}
|
||||
|
||||
-- general
|
||||
lvim.log.level = "warn"
|
||||
lvim.format_on_save = true
|
||||
lvim.colorscheme = "onedarker"
|
||||
|
||||
-- keymappings [view all the defaults by pressing <leader>Lk]
|
||||
lvim.leader = "space"
|
||||
-- add your own keymapping
|
||||
lvim.keys.normal_mode["<C-s>"] = ":w<cr>"
|
||||
-- unmap a default keymapping
|
||||
-- lvim.keys.normal_mode["<C-Up>"] = false
|
||||
-- edit a default keymapping
|
||||
-- lvim.keys.normal_mode["<C-q>"] = ":q<cr>"
|
||||
|
||||
-- Change Telescope navigation to use j and k for navigation and n and p for history in both input and normal mode.
|
||||
-- we use protected-mode (pcall) just in case the plugin wasn't loaded yet.
|
||||
-- local _, actions = pcall(require, "telescope.actions")
|
||||
-- lvim.builtin.telescope.defaults.mappings = {
|
||||
-- -- for input mode
|
||||
-- i = {
|
||||
-- ["<C-j>"] = actions.move_selection_next,
|
||||
-- ["<C-k>"] = actions.move_selection_previous,
|
||||
-- ["<C-n>"] = actions.cycle_history_next,
|
||||
-- ["<C-p>"] = actions.cycle_history_prev,
|
||||
-- },
|
||||
-- -- for normal mode
|
||||
-- n = {
|
||||
-- ["<C-j>"] = actions.move_selection_next,
|
||||
-- ["<C-k>"] = actions.move_selection_previous,
|
||||
-- },
|
||||
-- }
|
||||
|
||||
-- Use which-key to add extra bindings with the leader-key prefix
|
||||
-- lvim.builtin.which_key.mappings["P"] = { "<cmd>Telescope projects<CR>", "Projects" }
|
||||
-- lvim.builtin.which_key.mappings["t"] = {
|
||||
-- name = "+Trouble",
|
||||
-- r = { "<cmd>Trouble lsp_references<cr>", "References" },
|
||||
-- f = { "<cmd>Trouble lsp_definitions<cr>", "Definitions" },
|
||||
-- d = { "<cmd>Trouble lsp_document_diagnostics<cr>", "Diagnostics" },
|
||||
-- q = { "<cmd>Trouble quickfix<cr>", "QuickFix" },
|
||||
-- l = { "<cmd>Trouble loclist<cr>", "LocationList" },
|
||||
-- w = { "<cmd>Trouble lsp_workspace_diagnostics<cr>", "Diagnostics" },
|
||||
-- }
|
||||
|
||||
-- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile
|
||||
lvim.builtin.dashboard.active = true
|
||||
lvim.builtin.notify.active = true
|
||||
lvim.builtin.terminal.active = false
|
||||
-- lvim.builtin.terminal.shell = "pwsh.exe -NoLogo"
|
||||
|
||||
-- nvim-tree has some performance issues on windows, see kyazdani42/nvim-tree.lua#549
|
||||
lvim.builtin.nvimtree.setup.diagnostics.enable = false
|
||||
lvim.builtin.nvimtree.setup.filters.custom = false
|
||||
lvim.builtin.nvimtree.setup.git.enable = false
|
||||
lvim.builtin.nvimtree.setup.update_cwd = false
|
||||
lvim.builtin.nvimtree.setup.update_focused_file.update_cwd = false
|
||||
lvim.builtin.nvimtree.setup.view.side = "left"
|
||||
lvim.builtin.nvimtree.git_hl = false
|
||||
lvim.builtin.nvimtree.show_icons.git = 0
|
||||
|
||||
-- if you don't want all the parsers change this to a table of the ones you want
|
||||
lvim.builtin.treesitter.ensure_installed = {
|
||||
"c",
|
||||
"lua",
|
||||
}
|
||||
|
||||
lvim.builtin.treesitter.ignore_install = { "haskell" }
|
||||
lvim.builtin.treesitter.highlight.enabled = true
|
||||
|
||||
-- generic LSP settings
|
||||
|
||||
-- ---@usage disable automatic installation of servers
|
||||
-- lvim.lsp.automatic_servers_installation = false
|
||||
|
||||
-- ---@usage Select which servers should be configured manually. Requires `:LvimCacheRest` to take effect.
|
||||
-- See the full default list `:lua print(vim.inspect(lvim.lsp.override))`
|
||||
-- vim.list_extend(lvim.lsp.override, { "pyright" })
|
||||
|
||||
-- ---@usage setup a server -- see: https://www.lunarvim.org/languages/#overriding-the-default-configuration
|
||||
-- local opts = {} -- check the lspconfig documentation for a list of all possible options
|
||||
-- require("lvim.lsp.manager").setup("pylsp", opts)
|
||||
|
||||
-- -- you can set a custom on_attach function that will be used for all the language servers
|
||||
-- -- See <https://github.com/neovim/nvim-lspconfig#keybindings-and-completion>
|
||||
-- lvim.lsp.on_attach_callback = function(client, bufnr)
|
||||
-- local function buf_set_option(...)
|
||||
-- vim.api.nvim_buf_set_option(bufnr, ...)
|
||||
-- end
|
||||
-- --Enable completion triggered by <c-x><c-o>
|
||||
-- buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||
-- end
|
||||
|
||||
-- -- set a formatter, this will override the language server formatting capabilities (if it exists)
|
||||
-- local formatters = require "lvim.lsp.null-ls.formatters"
|
||||
-- formatters.setup {
|
||||
-- { command = "black", filetypes = { "python" } },
|
||||
-- { command = "isort", filetypes = { "python" } },
|
||||
-- {
|
||||
-- -- each formatter accepts a list of options identical to https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/BUILTINS.md#Configuration
|
||||
-- command = "prettier",
|
||||
-- ---@usage arguments to pass to the formatter
|
||||
-- -- these cannot contain whitespaces, options such as `--line-width 80` become either `{'--line-width', '80'}` or `{'--line-width=80'}`
|
||||
-- extra_args = { "--print-with", "100" },
|
||||
-- ---@usage specify which filetypes to enable. By default a providers will attach to all the filetypes it supports.
|
||||
-- filetypes = { "typescript", "typescriptreact" },
|
||||
-- },
|
||||
-- }
|
||||
|
||||
-- -- set additional linters
|
||||
-- local linters = require "lvim.lsp.null-ls.linters"
|
||||
-- linters.setup {
|
||||
-- { command = "flake8", filetypes = { "python" } },
|
||||
-- {
|
||||
-- -- each linter accepts a list of options identical to https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/BUILTINS.md#Configuration
|
||||
-- command = "shellcheck",
|
||||
-- ---@usage arguments to pass to the formatter
|
||||
-- -- these cannot contain whitespaces, options such as `--line-width 80` become either `{'--line-width', '80'}` or `{'--line-width=80'}`
|
||||
-- extra_args = { "--severity", "warning" },
|
||||
-- },
|
||||
-- {
|
||||
-- command = "codespell",
|
||||
-- ---@usage specify which filetypes to enable. By default a providers will attach to all the filetypes it supports.
|
||||
-- filetypes = { "javascript", "python" },
|
||||
-- },
|
||||
-- }
|
||||
|
||||
-- Additional Plugins
|
||||
-- lvim.plugins = {
|
||||
-- {"folke/tokyonight.nvim"},
|
||||
-- {
|
||||
-- "folke/trouble.nvim",
|
||||
-- cmd = "TroubleToggle",
|
||||
-- },
|
||||
-- }
|
||||
|
||||
-- Autocommands (https://neovim.io/doc/user/autocmd.html)
|
||||
-- lvim.autocommands.custom_groups = {
|
||||
-- { "BufWinEnter", "*.lua", "setlocal ts=8 sw=8" },
|
||||
-- }
|
|
@ -2,112 +2,98 @@
|
|||
$ErrorActionPreference = "Stop" # exit when command fails
|
||||
|
||||
# set script variables
|
||||
$LV_BRANCH = ($LV_BRANCH, "rolling", 1 -ne $null)[0]
|
||||
$LV_REMOTE = ($LV_REMOTE, "lunarvim/lunarvim.git", 1 -ne $null)[0]
|
||||
$INSTALL_PREFIX = ($INSTALL_PREFIX, "$HOME\.local", 1 -ne $null)[0]
|
||||
$LV_BRANCH = $LV_BRANCH ?? "rolling"
|
||||
$LV_REMOTE = $LV_REMOTE ?? "lunarvim/lunarvim.git"
|
||||
$INSTALL_PREFIX = $INSTALL_PREFIX ?? "$HOME\.local"
|
||||
|
||||
$env:XDG_DATA_HOME = ($env:XDG_DATA_HOME, "$env:APPDATA", 1 -ne $null)[0]
|
||||
$env:XDG_CONFIG_HOME = ($env:XDG_CONFIG_HOME, "$env:LOCALAPPDATA", 1 -ne $null)[0]
|
||||
$env:XDG_CACHE_HOME = ($env:XDG_CACHE_HOME, "$env:TEMP", 1 -ne $null)[0]
|
||||
$env:LUNARVIM_RUNTIME_DIR = ($env:LUNARVIM_RUNTIME_DIR, "$env:XDG_DATA_HOME\lunarvim", 1 -ne $null)[0]
|
||||
$env:LUNARVIM_CONFIG_DIR = ($env:LUNARVIM_CONFIG_DIR, "$env:XDG_CONFIG_HOME\lvim", 1 -ne $null)[0]
|
||||
$env:LUNARVIM_CACHE_DIR = ($env:LUNARVIM_CACHE_DIR, "$env:XDG_CACHE_HOME\lvim", 1 -ne $null)[0]
|
||||
$env:XDG_DATA_HOME = $env:XDG_DATA_HOME ?? $env:APPDATA
|
||||
$env:XDG_CONFIG_HOME = $env:XDG_CONFIG_HOME ?? $env:LOCALAPPDATA
|
||||
$env:XDG_CACHE_HOME = $env:XDG_CACHE_HOME ?? $env:TEMP
|
||||
|
||||
$env:LUNARVIM_RUNTIME_DIR = $env:LUNARVIM_RUNTIME_DIR ?? "$env:XDG_DATA_HOME\lunarvim"
|
||||
$env:LUNARVIM_CONFIG_DIR = $env:LUNARVIM_CONFIG_DIR ?? "$env:XDG_CONFIG_HOME\lvim"
|
||||
$env:LUNARVIM_CACHE_DIR = $env:LUNARVIM_CACHE_DIR ?? "$env:XDG_CACHE_HOME\lvim"
|
||||
$env:LUNARVIM_BASE_DIR = $env:LUNARVIM_BASE_DIR ?? "$env:LUNARVIM_RUNTIME_DIR\lvim"
|
||||
|
||||
$__lvim_dirs = (
|
||||
"$env:LUNARVIM_CONFIG_DIR",
|
||||
"$env:LUNARVIM_RUNTIME_DIR",
|
||||
"$env:LUNARVIM_CACHE_DIR"
|
||||
$env:LUNARVIM_BASE_DIR,
|
||||
$env:LUNARVIM_RUNTIME_DIR,
|
||||
$env:LUNARVIM_CONFIG_DIR,
|
||||
$env:LUNARVIM_CACHE_DIR
|
||||
)
|
||||
|
||||
function main($cliargs) {
|
||||
Write-Output "
|
||||
|
||||
88\ 88\
|
||||
88 | \__|
|
||||
88 |88\ 88\ 888888$\ 888888\ 888888\ 88\ 88\ 88\ 888888\8888\
|
||||
88 |88 | 88 |88 __88\ \____88\ 88 __88\\88\ 88 |88 |88 _88 _88\
|
||||
88 |88 | 88 |88 | 88 | 888888$ |88 | \__|\88\88 / 88 |88 / 88 / 88 |
|
||||
88 |88 | 88 |88 | 88 |88 __88 |88 | \88$ / 88 |88 | 88 | 88 |
|
||||
88 |\888888 |88 | 88 |\888888$ |88 | \$ / 88 |88 | 88 | 88 |
|
||||
\__| \______/ \__| \__| \_______|\__| \_/ \__|\__| \__| \__|
|
||||
|
||||
"
|
||||
function __add_separator($div_width) {
|
||||
"-" * $div_width
|
||||
Write-Output ""
|
||||
}
|
||||
|
||||
function msg($text){
|
||||
Write-Output $text
|
||||
__add_separator "80"
|
||||
}
|
||||
|
||||
# skip this in a Github workflow
|
||||
if ( $null -eq "$GITHUB_ACTIONS" ) {
|
||||
install_packer
|
||||
setup_shim
|
||||
function main($cliargs) {
|
||||
|
||||
print_logo
|
||||
|
||||
verify_lvim_dirs
|
||||
|
||||
if ($cliargs.Contains("--overwrite")) {
|
||||
Write-Output "!!Warning!! -> Removing all lunarvim related config because of the --overwrite flag"
|
||||
$answer = Read-Host "Would you like to continue? [y]es or [n]o "
|
||||
if ("$answer" -ne "y" -and "$answer" -ne "Y") {
|
||||
exit 1
|
||||
}
|
||||
uninstall_lvim
|
||||
}
|
||||
if ($cliargs.Contains("--local") -or $cliargs.Contains("--testing")) {
|
||||
msg "Using local LunarVim installation"
|
||||
local_install
|
||||
exit
|
||||
}
|
||||
|
||||
__add_separator "80"
|
||||
|
||||
msg "Checking dependencies.."
|
||||
check_system_deps
|
||||
|
||||
Write-Output "Would you like to check lunarvim's NodeJS dependencies?"
|
||||
$answer = Read-Host "[y]es or [n]o (default: no) "
|
||||
$answer = Read-Host "Would you like to check lunarvim's NodeJS dependencies? [y]es or [n]o (default: no) "
|
||||
if ("$answer" -eq "y" -or "$answer" -eq "Y") {
|
||||
install_nodejs_deps
|
||||
}
|
||||
|
||||
Write-Output "Would you like to check lunarvim's Python dependencies?"
|
||||
$answer = Read-Host "[y]es or [n]o (default: no) "
|
||||
$answer = Read-Host "Would you like to check lunarvim's Python dependencies? [y]es or [n]o (default: no) "
|
||||
if ("$answer" -eq "y" -or "$answer" -eq "Y") {
|
||||
install_python_deps
|
||||
}
|
||||
|
||||
__add_separator "80"
|
||||
|
||||
Write-Output "Backing up old LunarVim configuration"
|
||||
backup_old_config
|
||||
|
||||
__add_separator "80"
|
||||
|
||||
verify_lvim_dirs
|
||||
|
||||
if (Test-Path "$env:LUNARVIM_RUNTIME_DIR\site\pack\packer\start\packer.nvim") {
|
||||
Write-Output "Packer already installed"
|
||||
}
|
||||
else {
|
||||
install_packer
|
||||
}
|
||||
|
||||
__add_separator "80"
|
||||
|
||||
if (Test-Path "$env:LUNARVIM_RUNTIME_DIR\lvim\init.lua" ) {
|
||||
Write-Output "Updating LunarVim"
|
||||
update_lvim
|
||||
}
|
||||
else {
|
||||
if ($cliargs.Contains("--testing")) {
|
||||
copy_local_lvim_repository
|
||||
if (Test-Path "$env:LUNARVIM_BASE_DIR\init.lua" ) {
|
||||
msg "Updating LunarVim"
|
||||
validate_lunarvim_files
|
||||
}
|
||||
else {
|
||||
msg "Cloning Lunarvim"
|
||||
clone_lvim
|
||||
}
|
||||
setup_lvim
|
||||
}
|
||||
|
||||
__add_separator "80"
|
||||
}
|
||||
|
||||
function print_missing_dep_msg($dep) {
|
||||
Write-Output "[ERROR]: Unable to find dependency [$dep]"
|
||||
Write-Output "Please install it first and re-run the installer. Try: $RECOMMEND_INSTALL $dep"
|
||||
Write-Output "Please install it first and re-run the installer."
|
||||
}
|
||||
|
||||
$winget_package_matrix=@{"git" = "Git.Git"; "nvim" = "nvim.nvim"; "make" = "GnuWin32.Make"; "node" = "OpenJS.NodeJS"; "pip" = "Python.Python.3"}
|
||||
$scoop_package_matrix=@{"git" = "git"; "nvim" = "neovim-nightly"; "make" = "make"; "node" = "nodejs"; "pip" = "python3"}
|
||||
|
||||
function install_system_package($dep) {
|
||||
if (Get-Command -Name "winget" -ErrorAction SilentlyContinue) {
|
||||
Write-Output "[INFO]: Attempting to install dependency [$dep] with winget"
|
||||
$install_cmd = "winget install --interactive"
|
||||
Write-Output "Attempting to install dependency [$dep] with winget"
|
||||
$install_cmd = "winget install --interactive $winget_package_matrix[$dep]"
|
||||
}
|
||||
elseif (Get-Command -Name "scoop" -ErrorAction SilentlyContinue) {
|
||||
Write-Output "[INFO]: Attempting to install dependency [$dep] with scoop"
|
||||
Write-Output "Attempting to install dependency [$dep] with scoop"
|
||||
# TODO: check if it's fine to not run it with --global
|
||||
$install_cmd = "scoop install"
|
||||
$install_cmd = "scoop install $scoop_package_matrix[$dep]"
|
||||
}
|
||||
else {
|
||||
print_missing_dep_msg "$dep"
|
||||
|
@ -115,7 +101,7 @@ function install_system_package($dep) {
|
|||
}
|
||||
|
||||
try {
|
||||
Invoke-Command $install_cmd $dep -ErrorAction Stop
|
||||
Invoke-Command $install_cmd -ErrorAction Stop
|
||||
}
|
||||
catch {
|
||||
print_missing_dep_msg "$dep"
|
||||
|
@ -133,10 +119,9 @@ function check_system_dep($dep) {
|
|||
}
|
||||
|
||||
function check_system_deps() {
|
||||
Write-Output "[INFO]: Checking dependencies.."
|
||||
check_system_dep "git"
|
||||
check_system_dep "nvim"
|
||||
|
||||
check_system_dep "make"
|
||||
}
|
||||
|
||||
function install_nodejs_deps() {
|
||||
|
@ -162,54 +147,44 @@ function install_python_deps() {
|
|||
}
|
||||
|
||||
function backup_old_config() {
|
||||
foreach ($dir in $__lvim_dirs) {
|
||||
# we create an empty folder for subsequent commands \
|
||||
# that require an existing directory
|
||||
if ( Test-Path "$dir") {
|
||||
New-Item "$dir.bak" -ItemType Directory -Force
|
||||
Copy-Item -Recurse "$dir\*" "$dir.bak\."
|
||||
$src = "$env:LUNARVIM_CONFIG_DIR"
|
||||
if (Test-Path $src) {
|
||||
New-Item "$src.old" -ItemType Directory -Force | Out-Null
|
||||
Copy-Item -Force -Recurse "$src\*" "$src.old\." | Out-Null
|
||||
}
|
||||
}
|
||||
|
||||
Write-Output "Backup operation complete"
|
||||
msg "Backup operation complete"
|
||||
}
|
||||
|
||||
|
||||
function install_packer() {
|
||||
Invoke-Command -ErrorAction Stop -ScriptBlock { git clone --progress --depth 1 "https://github.com/wbthomason/packer.nvim" "$env:LUNARVIM_RUNTIME_DIR\site\pack\packer\start\packer.nvim" }
|
||||
}
|
||||
|
||||
function copy_local_lvim_repository() {
|
||||
Write-Output "Copy local LunarVim configuration"
|
||||
Copy-Item -Path "$((Get-Item $PWD).Parent.Parent.FullName)" -Destination "$env:LUNARVIM_RUNTIME_DIR/lvim" -Recurse
|
||||
function local_install() {
|
||||
verify_lvim_dirs
|
||||
$repoDir = git rev-parse --show-toplevel
|
||||
$gitLocalCloneCmd = git clone --progress "$repoDir" "$env:LUNARVIM_BASE_DIR"
|
||||
Invoke-Command -ErrorAction Stop -ScriptBlock { $gitLocalCloneCmd; setup_lvim }
|
||||
}
|
||||
|
||||
function clone_lvim() {
|
||||
Write-Output "Cloning LunarVim configuration"
|
||||
try {
|
||||
Invoke-Command -ErrorAction Stop -ScriptBlock { git clone --progress --branch "$LV_BRANCH" --depth 1 "https://github.com/$LV_REMOTE" "$env:LUNARVIM_RUNTIME_DIR/lvim" }
|
||||
$gitCloneCmd = git clone --progress --depth 1 --branch "$LV_BRANCH" `
|
||||
"https://github.com/$LV_REMOTE" `
|
||||
"$env:LUNARVIM_BASE_DIR"
|
||||
Invoke-Command -ErrorAction Stop -ScriptBlock { $gitCloneCmd }
|
||||
}
|
||||
catch {
|
||||
Write-Output "Failed to clone repository. Installation failed."
|
||||
msg "Failed to clone repository. Installation failed."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
function setup_shim() {
|
||||
if ((Test-Path "$INSTALL_PREFIX\bin") -eq $false) {
|
||||
New-Item "$INSTALL_PREFIX\bin" -ItemType Directory
|
||||
}
|
||||
Copy-Item "$env:LUNARVIM_RUNTIME_DIR\lvim\utils\bin\lvim.ps1" -Destination "$INSTALL_PREFIX\bin\lvim.ps1" -Force
|
||||
New-Item "$INSTALL_PREFIX\bin" -ItemType Directory | Out-Null
|
||||
}
|
||||
|
||||
function verify_lvim_dirs() {
|
||||
if ($cliargs.Contains("--overwrite")) {
|
||||
Write-Output "!!Warning!! -> Removing all lunarvim related config because of the --overwrite flag"
|
||||
$answer = Read-Host "Would you like to continue? [y]es or [n]o "
|
||||
if ("$answer" -ne "y" -and "$answer" -ne "Y") {
|
||||
exit 1
|
||||
Copy-Item -Force "$env:LUNARVIM_BASE_DIR\utils\bin\lvim.ps1" "$INSTALL_PREFIX\bin\lvim.ps1"
|
||||
}
|
||||
|
||||
function uninstall_lvim() {
|
||||
foreach ($dir in $__lvim_dirs) {
|
||||
if (Test-Path "$dir") {
|
||||
Remove-Item -Force -Recurse "$dir"
|
||||
|
@ -217,76 +192,99 @@ function verify_lvim_dirs() {
|
|||
}
|
||||
}
|
||||
|
||||
function verify_lvim_dirs() {
|
||||
foreach ($dir in $__lvim_dirs) {
|
||||
if ((Test-Path "$dir") -eq $false) {
|
||||
New-Item "$dir" -ItemType Directory
|
||||
New-Item "$dir" -ItemType Directory | Out-Null
|
||||
}
|
||||
}
|
||||
backup_old_config
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function setup_lvim() {
|
||||
Write-Output "Installing LunarVim shim"
|
||||
|
||||
msg "Installing LunarVim shim"
|
||||
setup_shim
|
||||
|
||||
Write-Output "Preparing Packer setup"
|
||||
msg "Installing sample configuration"
|
||||
|
||||
if (Test-Path "$env:LUNARVIM_CONFIG_DIR\config.lua") {
|
||||
Remove-Item -Force "$env:LUNARVIM_CONFIG_DIR\config.lua"
|
||||
Move-Item "$env:LUNARVIM_CONFIG_DIR\config.lua" "$env:LUNARVIM_CONFIG_DIR\config.lua.old"
|
||||
}
|
||||
|
||||
Out-File -FilePath "$env:LUNARVIM_CONFIG_DIR\config.lua"
|
||||
New-Item -ItemType File -Path "$env:LUNARVIM_CONFIG_DIR\config.lua" | Out-Null
|
||||
|
||||
Write-Output "Packer setup complete"
|
||||
$exampleConfig = "$env:LUNARVIM_BASE_DIR\utils\installer\config_win.example.lua"
|
||||
Copy-Item -Force "$exampleConfig" "$env:LUNARVIM_CONFIG_DIR\config.lua"
|
||||
|
||||
__add_separator "80"
|
||||
# FIXME: this has never worked
|
||||
# Invoke-Expression "$INSTALL_PREFIX\bin\lvim.ps1 --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'"
|
||||
|
||||
Copy-Item "$env:LUNARVIM_RUNTIME_DIR\lvim\utils\installer\config.example.lua" "$env:LUNARVIM_CONFIG_DIR\config.lua"
|
||||
Write-Host "Make sure to run `:PackerSync` at first launch" -ForegroundColor Green
|
||||
|
||||
$answer = Read-Host $(`
|
||||
"Would you like to create an alias inside your Powershell profile?`n" + `
|
||||
"(This enables you to start lvim with the command 'lvim') [y]es or [n]o (default: no)" )
|
||||
if ("$answer" -eq "y" -and "$answer" -eq "Y") {
|
||||
create_alias
|
||||
}
|
||||
|
||||
__add_separator "80"
|
||||
msg "Thank you for installing LunarVim!!"
|
||||
|
||||
Write-Output "Thank you for installing LunarVim!!"
|
||||
Write-Output "You can start it by running: $INSTALL_PREFIX\bin\lvim.ps1"
|
||||
Write-Output "Do not forget to use a font with glyphs (icons) support [https://github.com/ryanoasis/nerd-fonts]"
|
||||
}
|
||||
|
||||
|
||||
function update_lvim() {
|
||||
function validate_lunarvim_files() {
|
||||
Set-Alias lvim "$INSTALL_PREFIX\bin\lvim.ps1"
|
||||
try {
|
||||
Invoke-Command git -C "$env:LUNARVIM_RUNTIME_DIR/lvim" status -uno
|
||||
$verify_version_cmd='if v:errmsg != "" | cquit | else | quit | endif'
|
||||
Invoke-Command -ScriptBlock { lvim --headless -c 'LvimUpdate' -c "$verify_version_cmd" } -ErrorAction SilentlyContinue
|
||||
}
|
||||
catch {
|
||||
git -C "$env:LUNARVIM_RUNTIME_DIR/lvim" pull --ff-only --progress -or
|
||||
Write-Output "Unable to guarantee data integrity while updating. Please do that manually instead."
|
||||
Write-Output "Unable to guarantee data integrity while updating. Please run `:LvimUpdate` manually instead."
|
||||
exit 1
|
||||
}
|
||||
Write-Output "Your LunarVim installation is now up to date!"
|
||||
}
|
||||
|
||||
function __add_separator($div_width) {
|
||||
"-" * $div_width
|
||||
Write-Output ""
|
||||
}
|
||||
|
||||
function create_alias {
|
||||
if ($null -eq $(Get-Alias | Select-String "lvim")) {
|
||||
Add-Content -Path $PROFILE -Value $( -join @('Set-Alias lvim "', "$INSTALL_PREFIX", '\bin\lvim.ps1"'))
|
||||
|
||||
Write-Output ""
|
||||
Write-Host 'To use the new alias in this window reload your profile with ". $PROFILE".' -ForegroundColor Yellow
|
||||
|
||||
try {
|
||||
$answer = Read-Host $(`
|
||||
"Would you like to create an alias inside your Powershell profile?`n" + `
|
||||
"(This enables you to start lvim with the command 'lvim') [y]es or [n]o (default: no)" )
|
||||
}
|
||||
else {
|
||||
catch {
|
||||
msg "Non-interactive mode detected. Skipping alias creation"
|
||||
return
|
||||
}
|
||||
|
||||
if ("$answer" -ne "y" -or "$answer" -ne "Y") {
|
||||
return
|
||||
}
|
||||
|
||||
$lvim_bin="$INSTALL_PREFIX\bin\lvim.ps1"
|
||||
$lvim_alias = Get-Alias lvim -ErrorAction SilentlyContinue
|
||||
|
||||
if ($lvim_alias.Definition == $lvim_bin) {
|
||||
Write-Output "Alias is already set and will not be reset."
|
||||
return
|
||||
}
|
||||
|
||||
Add-Content -Path $PROFILE -Value $("Set-Alias lvim $lvim_bin")
|
||||
|
||||
Write-Host 'To use the new alias in this window reload your profile with: `. $PROFILE`' -ForegroundColor Green
|
||||
}
|
||||
|
||||
function print_logo(){
|
||||
Write-Output "
|
||||
|
||||
88\ 88\
|
||||
88 | \__|
|
||||
88 |88\ 88\ 888888$\ 888888\ 888888\ 88\ 88\ 88\ 888888\8888\
|
||||
88 |88 | 88 |88 __88\ \____88\ 88 __88\\88\ 88 |88 |88 _88 _88\
|
||||
88 |88 | 88 |88 | 88 | 888888$ |88 | \__|\88\88 / 88 |88 / 88 / 88 |
|
||||
88 |88 | 88 |88 | 88 |88 __88 |88 | \88$ / 88 |88 | 88 | 88 |
|
||||
88 |\888888 |88 | 88 |\888888$ |88 | \$ / 88 |88 | 88 | 88 |
|
||||
\__| \______/ \__| \__| \_______|\__| \_/ \__|\__| \__| \__|
|
||||
|
||||
"
|
||||
}
|
||||
|
||||
main "$args"
|
||||
|
|
|
@ -321,30 +321,29 @@ function verify_lvim_dirs() {
|
|||
}
|
||||
|
||||
function backup_old_config() {
|
||||
for dir in "${__lvim_dirs[@]}"; do
|
||||
local src="$LUNARVIM_CONFIG_DIR"
|
||||
if [ ! -d "$dir" ]; then
|
||||
continue
|
||||
return
|
||||
fi
|
||||
mkdir -p "$dir.bak"
|
||||
touch "$dir/ignore"
|
||||
msg "Backing up old $dir to $dir.bak"
|
||||
mkdir -p "$src.old"
|
||||
touch "$src/ignore"
|
||||
msg "Backing up old $src to $src.old"
|
||||
if command -v rsync &>/dev/null; then
|
||||
rsync --archive -hh --stats --partial --copy-links --cvs-exclude "$dir"/ "$dir.bak"
|
||||
rsync --archive -hh --stats --partial --copy-links --cvs-exclude "$src"/ "$src.old"
|
||||
else
|
||||
OS="$(uname -s)"
|
||||
case "$OS" in
|
||||
Linux | *BSD)
|
||||
cp -r "$dir/"* "$dir.bak/."
|
||||
cp -r "$src/"* "$src.old/."
|
||||
;;
|
||||
Darwin)
|
||||
cp -R "$dir/"* "$dir.bak/."
|
||||
cp -R "$src/"* "$src.old/."
|
||||
;;
|
||||
*)
|
||||
echo "OS $OS is not currently supported."
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
msg "Backup operation complete"
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1,57 @@
|
|||
Remove-Item -Path "$HOME/.local/share/lunarvim" -Recurse -Force
|
||||
#Requires -Version 7.1
|
||||
$ErrorActionPreference = "Stop" # exit when command fails
|
||||
|
||||
# set script variables
|
||||
$LV_BRANCH = $LV_BRANCH ?? "rolling"
|
||||
$LV_REMOTE = $LV_REMOTE ?? "lunarvim/lunarvim.git"
|
||||
$INSTALL_PREFIX = $INSTALL_PREFIX ?? "$HOME\.local"
|
||||
|
||||
$env:XDG_DATA_HOME = $env:XDG_DATA_HOME ?? $env:APPDATA
|
||||
$env:XDG_CONFIG_HOME = $env:XDG_CONFIG_HOME ?? $env:LOCALAPPDATA
|
||||
$env:XDG_CACHE_HOME = $env:XDG_CACHE_HOME ?? $env:TEMP
|
||||
|
||||
$env:LUNARVIM_RUNTIME_DIR = $env:LUNARVIM_RUNTIME_DIR ?? "$env:XDG_DATA_HOME\lunarvim"
|
||||
$env:LUNARVIM_CONFIG_DIR = $env:LUNARVIM_CONFIG_DIR ?? "$env:XDG_CONFIG_HOME\lvim"
|
||||
$env:LUNARVIM_CACHE_DIR = $env:LUNARVIM_CACHE_DIR ?? "$env:XDG_CACHE_HOME\lvim"
|
||||
$env:LUNARVIM_BASE_DIR = $env:LUNARVIM_BASE_DIR ?? "$env:LUNARVIM_RUNTIME_DIR\lvim"
|
||||
|
||||
$__lvim_dirs = (
|
||||
$env:LUNARVIM_BASE_DIR,
|
||||
$env:LUNARVIM_RUNTIME_DIR,
|
||||
$env:LUNARVIM_CONFIG_DIR,
|
||||
$env:LUNARVIM_CACHE_DIR
|
||||
)
|
||||
|
||||
function main($cliargs) {
|
||||
Write-Output "Removing LunarVim binary..."
|
||||
remove_lvim_bin
|
||||
Write-Output "Removing LunarVim directories..."
|
||||
$force = $false
|
||||
if ($cliargs.Contains("--remove-backups")) {
|
||||
$force = $true
|
||||
}
|
||||
remove_lvim_dirs $force
|
||||
Write-Output "Uninstalled LunarVim!"
|
||||
}
|
||||
|
||||
function remove_lvim_bin(){
|
||||
$lvim_bin="$INSTALL_PREFIX\bin\lvim"
|
||||
if (Test-Path $lvim_bin) {
|
||||
Remove-Item -Force $lvim_bin
|
||||
}
|
||||
if (Test-Path alias:lvim) {
|
||||
Write-Warning "Please make sure to remove the 'lvim' alias from your `$PROFILE`: $PROFILE"
|
||||
}
|
||||
}
|
||||
|
||||
function remove_lvim_dirs($force) {
|
||||
foreach ($dir in $__lvim_dirs) {
|
||||
if (Test-Path $dir) {
|
||||
Remove-Item -Force -Recurse $dir
|
||||
}
|
||||
if ($force -eq $true -and (Test-Path "$dir.bak" -or Test-Path "$dir.old")) {
|
||||
Remove-Item -Force -Recurse "$dir.{bak,old}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ function remove_lvim_dirs() {
|
|||
for dir in "${__lvim_dirs[@]}"; do
|
||||
rm -rf "$dir"
|
||||
if [ "$ARGS_REMOVE_BACKUPS" -eq 1 ]; then
|
||||
rm -rf "$dir.bak"
|
||||
rm -rf "$dir.{bak,old}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue