diff options
Diffstat (limited to '.config/nvim/lua/config/init.lua')
-rw-r--r-- | .config/nvim/lua/config/init.lua | 118 |
1 files changed, 113 insertions, 5 deletions
diff --git a/.config/nvim/lua/config/init.lua b/.config/nvim/lua/config/init.lua index 7d42ad1..f4179ee 100644 --- a/.config/nvim/lua/config/init.lua +++ b/.config/nvim/lua/config/init.lua @@ -1,26 +1,134 @@ -local home_dir = vim.loop.os_homedir() -local M = { - path = string.format("%s/.config/nvim/config.lua", home_dir), -} +local M = {} --- Initialize nvim default configuration -- Define nvim global variable -function M:init() +function M:init(opts) + opts = opts or {} + self.path = opts.path local utils = require "utils" require "config.defaults" + -- Fallback config.lua to config.lua + if not utils.is_file(self.path) then + local config = self.path:gsub("config.lua$", "config.lua") + print(self.path, "not found, falling back to", config) + + self.path = config + end + local builtins = require "core.builtins" builtins.config(self) local settings = require "config.settings" settings.load_options() + + local lsp_config = require "lsp.config" + options.lsp = vim.deepcopy(lsp_config) + + local supported_languages = { + "asm", + "bash", + "beancount", + "bibtex", + "bicep", + "c", + "c_sharp", + "clojure", + "cmake", + "comment", + "commonlisp", + "cpp", + "crystal", + "cs", + "css", + "cuda", + "d", + "dart", + "dockerfile", + "dot", + "elixir", + "elm", + "emmet", + "erlang", + "fennel", + "fish", + "fortran", + "gdscript", + "glimmer", + "go", + "gomod", + "graphql", + "haskell", + "hcl", + "heex", + "html", + "java", + "javascript", + "javascriptreact", + "jsdoc", + "json", + "json5", + "jsonc", + "julia", + "kotlin", + "latex", + "ledger", + "less", + "lua", + "markdown", + "nginx", + "nix", + "ocaml", + "ocaml_interface", + "perl", + "php", + "pioasm", + "ps1", + "puppet", + "python", + "ql", + "query", + "r", + "regex", + "rst", + "ruby", + "rust", + "scala", + "scss", + "sh", + "solidity", + "sparql", + "sql", + "supercollider", + "surface", + "svelte", + "swift", + "tailwindcss", + "terraform", + "tex", + "tlaplus", + "toml", + "tsx", + "turtle", + "typescript", + "typescriptreact", + "verilog", + "vim", + "vue", + "yaml", + "yang", + "zig", + } + + require("lsp.manager").init_defaults(supported_languages) end --- Override the configuration with a user provided one -- @param config_path The path to the configuration overrides function M:load(config_path) local autocmds = require "core.autocmds" + config_path = config_path or self.path local ok, err = pcall(vim.cmd, "luafile " .. config_path) if not ok then |