Browse Source

feat: add Windows support (UNTESTED)

my-config
NTBBloodbath 3 years ago
parent
commit
1cbaf105fa
No known key found for this signature in database GPG Key ID: 18D6730BC846AAC5
  1. 1
      lua/doom/core/README.md
  2. 35
      lua/doom/core/system/init.lua
  3. 27
      lua/doom/utils/init.lua

1
lua/doom/core/README.md

@ -9,3 +9,4 @@ Those modules are the following:
- settings - Doom configurations for Neovim, e.g. `tabwidth`, `showmode`.
- functions - Doom core functions, e.g. `create_report`.
- health - Doom health add-on.
- system - Doom system detection utilities.

35
lua/doom/core/system/init.lua

@ -0,0 +1,35 @@
---[[---------------------------------------]]---
-- system - Doom Nvim system integration --
-- Author: NTBBloodbath --
-- License: GPLv2 --
---[[---------------------------------------]]---
local M = {}
-- get_config_dir will get the config path based in the current system, e.g.
-- 'C:\Users\JohnDoe\AppData\Local' for windows and '~/.config' for *nix
-- @return string
local function get_config_dir()
if (jit and jit.os == "Windows") or (vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1) then
return os.getenv("USERPROFILE") .. "\\AppData\\Local\\"
end
return (os.getenv("XDG_CONFIG_HOME") and os.getenv("XDG_CONFIG_HOME"))
or (os.getenv("HOME") .. "/.config")
end
-- get_separator will return the system paths separator, e.g. \ for Windows and / for *nix
-- @return string
local function get_separator()
if (jit and jit.os == "Windows") or (vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1) then
return "\\"
end
return "/"
end
M.config_dir = get_config_dir()
M.sep = get_separator()
return M

27
lua/doom/utils/init.lua

@ -6,19 +6,19 @@
local M = {}
local system = require("doom.core.system")
-------------------- HELPERS --------------------
-- Doom Nvim version
M.doom_version = "3.1.0"
-- Get the user config directory, e.g. '/home/JohnDoe/.config'
local config_dir = os.getenv("XDG_CONFIG_HOME") and os.getenv("XDG_CONFIG_HOME")
or os.getenv("HOME") .. "/.config"
local config_dir, sep = system.config_dir, system.sep
-- The doom-nvim root directory, works as a fallback for looking Doom Nvim configurations
-- in case that doom_configs_root directory does not exists.
M.doom_root = string.format("%s/nvim", config_dir)
M.doom_root = string.format("%s%snvim", config_dir, sep)
-- The doom-nvim configurations root directory
M.doom_configs_root = string.format("%s/doom-nvim", config_dir)
M.doom_configs_root = string.format("%s%sdoom-nvim", config_dir, sep)
-- The doom-nvim logs file path
M.doom_logs = vim.fn.stdpath("data") .. "/doom.log"
-- The doom-nvim bug report file path
@ -110,23 +110,6 @@ M.has_value = function(tabl, val)
return false
end
-- Get current OS, returns 'Other' if the current OS is not recognized
-- @return string
M.get_os = function()
--[[
-- Target OS names:
-- - Windows
-- - Linux
-- - OSX
-- - BSD
-- - POSIX
-- - Other
--]]
-- We make use of JIT because LuaJIT is bundled in Neovim
return jit.os
end
-- file_exists checks if the given file exists
-- @tparam string path The path to the file
-- @return boolean

Loading…
Cancel
Save