diff options
| author | Luc Sinet <[email protected]> | 2021-08-25 07:47:48 +0200 | 
|---|---|---|
| committer | GitHub <[email protected]> | 2021-08-25 07:47:48 +0200 | 
| commit | 00b895d9e9577f084cf577a07f9d6d6e1f7a4cac (patch) | |
| tree | 1139617d5b3acd56f221f24ce301f51535267bdc /lua/config | |
| parent | f6c706ac0c346491cc79bdea46a52ee7a8694e0d (diff) | |
[Feature] Encapsulate config logic (#1338)
* Define core/builtins, streamline status_color interface
* Encapsulate configuration in its own module
* Add fallback to lv-config.lua
* Rectify settings loading order to allow overriding vim options
* Move default-config into config/ module
* replace uv.fs_stat with utils.is_file
Diffstat (limited to 'lua/config')
| -rw-r--r-- | lua/config/defaults.lua | 1162 | ||||
| -rw-r--r-- | lua/config/init.lua | 44 | ||||
| -rw-r--r-- | lua/config/settings.lua | 76 | 
3 files changed, 1282 insertions, 0 deletions
| diff --git a/lua/config/defaults.lua b/lua/config/defaults.lua new file mode 100644 index 00000000..5dc98698 --- /dev/null +++ b/lua/config/defaults.lua @@ -0,0 +1,1162 @@ +CONFIG_PATH = os.getenv "HOME" .. "/.local/share/lunarvim/lvim" +DATA_PATH = vim.fn.stdpath "data" +CACHE_PATH = vim.fn.stdpath "cache" +TERMINAL = vim.fn.expand "$TERMINAL" +USER = vim.fn.expand "$USER" +vim.cmd [[ set spellfile=~/.config/lvim/spell/en.utf-8.add ]] + +lvim = { +  leader = "space", +  colorscheme = "spacegray", +  line_wrap_cursor_movement = true, +  transparent_window = false, +  format_on_save = true, +  vsnip_dir = os.getenv "HOME" .. "/.config/snippets", +  database = { save_location = "~/.config/lunarvim_db", auto_execute = 1 }, +  keys = {}, + +  builtin = {}, + +  log = { +    ---@usage can be { "trace", "debug", "info", "warn", "error", "fatal" }, +    level = "warn", +    viewer = { +      ---@usage this will fallback on "less +F" if not found +      cmd = "lnav", +      layout_config = { +        ---@usage direction = 'vertical' | 'horizontal' | 'window' | 'float', +        direction = "horizontal", +        open_mapping = "", +        size = 40, +        float_opts = {}, +      }, +    }, +  }, + +  lsp = { +    completion = { +      item_kind = { +        "   (Text) ", +        "   (Method)", +        "   (Function)", +        "   (Constructor)", +        " ﴲ  (Field)", +        "[] (Variable)", +        "   (Class)", +        " ﰮ  (Interface)", +        "   (Module)", +        " 襁 (Property)", +        "   (Unit)", +        "   (Value)", +        " 練 (Enum)", +        "   (Keyword)", +        "   (Snippet)", +        "   (Color)", +        "   (File)", +        "   (Reference)", +        "   (Folder)", +        "   (EnumMember)", +        " ﲀ  (Constant)", +        " ﳤ  (Struct)", +        "   (Event)", +        "   (Operator)", +        "   (TypeParameter)", +      }, +    }, +    diagnostics = { +      signs = { +        active = true, +        values = { +          { name = "LspDiagnosticsSignError", text = "" }, +          { name = "LspDiagnosticsSignWarning", text = "" }, +          { name = "LspDiagnosticsSignHint", text = "" }, +          { name = "LspDiagnosticsSignInformation", text = "" }, +        }, +      }, +      virtual_text = { +        prefix = "", +        spacing = 0, +      }, +      underline = true, +      severity_sort = true, +    }, +    override = {}, +    document_highlight = true, +    popup_border = "single", +    on_attach_callback = nil, +    on_init_callback = nil, +    null_ls = { +      setup = {}, +    }, +  }, + +  plugins = { +    -- use config.lua for this not put here +  }, + +  autocommands = {}, +} + +local schemas = nil +local status_ok, jsonls_settings = pcall(require, "nlspsettings.jsonls") +if status_ok then +  schemas = jsonls_settings.get_default_schemas() +end + +-- TODO move all of this into lang specific files, only require when using +lvim.lang = { +  asm = { +    formatters = { +      -- { +      --   exe = "asmfmt", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "", +      setup = {}, +    }, +  }, +  beancount = { +    formatters = { +      -- { +      --   exe = "bean_format", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "beancount", +      setup = { +        cmd = { "beancount-langserver" }, +      }, +    }, +  }, +  c = { +    formatters = { +      -- { +      --   exe = "clang_format", +      --   args = {}, +      -- }, +      -- { +      --   exe = "uncrustify", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "clangd", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/cpp/clangd/bin/clangd", +          "--background-index", +          "--header-insertion=never", +          "--cross-file-rename", +          "--clang-tidy", +          "--clang-tidy-checks=-*,llvm-*,clang-analyzer-*", +        }, +      }, +    }, +  }, +  cpp = { +    formatters = { +      -- { +      --   exe = "clang_format", +      --   args = {}, +      -- }, +      -- { +      --   exe = "uncrustify", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "clangd", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/cpp/clangd/bin/clangd", +          "--background-index", +          "--header-insertion=never", +          "--cross-file-rename", +          "--clang-tidy", +          "--clang-tidy-checks=-*,llvm-*,clang-analyzer-*", +        }, +      }, +    }, +  }, +  crystal = { +    formatters = { +      -- { +      --   exe = "crystal_format", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "crystalline", +      setup = { +        cmd = { "crystalline" }, +      }, +    }, +  }, +  cs = { +    formatters = { +      -- { +      --   exe = "clang_format ", +      --   args = {}, +      -- }, +      -- { +      --   exe = "uncrustify", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "omnisharp", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/csharp/omnisharp/run", +          "--languageserver", +          "--hostPID", +          tostring(vim.fn.getpid()), +        }, +      }, +    }, +  }, +  cmake = { +    formatters = { +      -- { +      --   exe = "cmake_format", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "cmake", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/cmake/venv/bin/cmake-language-server", +        }, +      }, +    }, +  }, +  clojure = { +    formatters = {}, +    linters = {}, +    lsp = { +      provider = "clojure_lsp", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/clojure/clojure-lsp", +        }, +      }, +    }, +  }, +  css = { +    formatters = { +      -- { +      --   exe = "prettier", +      --   args = {}, +      -- }, +      -- { +      --   exe = "prettierd", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "cssls", +      setup = { +        cmd = { +          "node", +          DATA_PATH .. "/lspinstall/css/vscode-css/css-language-features/server/dist/node/cssServerMain.js", +          "--stdio", +        }, +      }, +    }, +  }, +  less = { +    formatters = { +      -- { +      --   exe = "prettier", +      --   args = {}, +      -- }, +      -- { +      --   exe = "prettierd", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "cssls", +      setup = { +        cmd = { +          "node", +          DATA_PATH .. "/lspinstall/css/vscode-css/css-language-features/server/dist/node/cssServerMain.js", +          "--stdio", +        }, +      }, +    }, +  }, +  d = { +    formatters = { +      -- { +      --   exe = "dfmt", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "serve_d", +      setup = { +        cmd = { "serve-d" }, +      }, +    }, +  }, +  dart = { +    formatters = { +      -- { +      --   exe = "dart_format", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "dartls", +      setup = { +        cmd = { +          "dart", +          "/usr/lib/dart/bin/snapshots/analysis_server.dart.snapshot", +          "--lsp", +        }, +      }, +    }, +  }, +  docker = { +    formatters = {}, +    linters = {}, +    lsp = { +      provider = "dockerls", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/dockerfile/node_modules/.bin/docker-langserver", +          "--stdio", +        }, +      }, +    }, +  }, +  elixir = { +    formatters = { +      -- { +      --   exe = "mix", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "elixirls", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/elixir/elixir-ls/language_server.sh", +        }, +      }, +    }, +  }, +  elm = { +    formatters = { +      -- { +      --   exe = "elm_format", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "elmls", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/elm/node_modules/.bin/elm-language-server", +        }, +        -- init_options = { +        -- elmAnalyseTrigger = "change", +        -- elmFormatPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/elm-format", +        -- elmPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/", +        -- elmTestPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/elm-test", +        -- }, +      }, +    }, +  }, +  erlang = { +    formatters = { +      -- { +      --   exe = "erlfmt", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "erlangls", +      setup = { +        cmd = { +          "erlang_ls", +        }, +      }, +    }, +  }, +  emmet = { active = false }, +  fish = { +    formatters = { +      -- { +      --   exe = "fish_indent", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "", +      setup = {}, +    }, +  }, +  fortran = { +    formatters = {}, +    linters = {}, +    lsp = { +      provider = "fortls", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/fortran/venv/bin/fortls", +        }, +      }, +    }, +  }, +  go = { +    formatters = { +      -- { +      --   exe = "gofmt", +      --   args = {}, +      -- }, +      -- { +      --   exe = "goimports", +      --   args = {}, +      -- }, +      -- { +      --   exe = "gofumpt", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "gopls", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/go/gopls", +        }, +      }, +    }, +  }, +  graphql = { +    formatters = {}, +    linters = {}, +    lsp = { +      provider = "graphql", +      setup = { +        cmd = { +          "graphql-lsp", +          "server", +          "-m", +          "stream", +        }, +      }, +    }, +  }, +  haskell = { +    formatters = {}, +    linters = {}, +    lsp = { +      provider = "hls", +      setup = { +        cmd = { DATA_PATH .. "/lspinstall/haskell/hls" }, +      }, +    }, +  }, +  html = { +    formatters = { +      -- { +      --   exe = "prettier", +      --   args = {}, +      -- }, +      -- { +      --   exe = "prettierd", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "html", +      setup = { +        cmd = { +          "node", +          DATA_PATH .. "/lspinstall/html/vscode-html/html-language-features/server/dist/node/htmlServerMain.js", +          "--stdio", +        }, +      }, +    }, +  }, +  java = { +    formatters = { +      -- { +      --   exe = "clang_format", +      --   args = {}, +      -- }, +      -- { +      --   exe = "uncrustify", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "jdtls", +      setup = { +        cmd = { DATA_PATH .. "/lspinstall/java/jdtls.sh" }, +      }, +    }, +  }, +  json = { +    formatters = { +      -- { +      --   exe = "json_tool", +      --   args = {}, +      -- }, +      -- { +      --   exe = "prettier", +      --   args = {}, +      -- }, +      -- { +      --   exe = "prettierd", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "jsonls", +      setup = { +        cmd = { +          "node", +          DATA_PATH .. "/lspinstall/json/vscode-json/json-language-features/server/dist/node/jsonServerMain.js", +          "--stdio", +        }, +        settings = { +          json = { +            schemas = schemas, +            --   = { +            --   { +            --     fileMatch = { "package.json" }, +            --     url = "https://json.schemastore.org/package.json", +            --   }, +            -- }, +          }, +        }, +        commands = { +          Format = { +            function() +              vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 }) +            end, +          }, +        }, +      }, +    }, +  }, +  julia = { +    formatters = {}, +    linters = {}, +    lsp = { +      provider = "julials", +      setup = { +        { +          "julia", +          "--startup-file=no", +          "--history-file=no", +          -- vim.fn.expand "~/.config/nvim/lua/lsp/julia/run.jl", +          CONFIG_PATH .. "/utils/julia/run.jl", +        }, +      }, +    }, +  }, +  kotlin = { +    formatters = {}, +    linters = {}, +    lsp = { +      provider = "kotlin_language_server", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/kotlin/server/bin/kotlin-language-server", +        }, +        root_dir = function(fname) +          local util = require "lspconfig/util" + +          local root_files = { +            "settings.gradle", -- Gradle (multi-project) +            "settings.gradle.kts", -- Gradle (multi-project) +            "build.xml", -- Ant +            "pom.xml", -- Maven +          } + +          local fallback_root_files = { +            "build.gradle", -- Gradle +            "build.gradle.kts", -- Gradle +          } +          return util.root_pattern(unpack(root_files))(fname) or util.root_pattern(unpack(fallback_root_files))(fname) +        end, +      }, +    }, +  }, +  lua = { +    formatters = { +      -- { +      --   exe = "stylua", +      --   args = {}, +      -- }, +      -- { +      --   exe = "lua_format", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "sumneko_lua", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/lua/sumneko-lua-language-server", +          "-E", +          DATA_PATH .. "/lspinstall/lua/main.lua", +        }, +        settings = { +          Lua = { +            runtime = { +              -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) +              version = "LuaJIT", +              -- Setup your lua path +              path = vim.split(package.path, ";"), +            }, +            diagnostics = { +              -- Get the language server to recognize the `vim` global +              globals = { "vim", "lvim" }, +            }, +            workspace = { +              -- Make the server aware of Neovim runtime files +              library = { +                [vim.fn.expand "~/.local/share/lunarvim/lvim/lua"] = true, +                [vim.fn.expand "$VIMRUNTIME/lua"] = true, +                [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true, +              }, +              maxPreload = 100000, +              preloadFileSize = 1000, +            }, +          }, +        }, +      }, +    }, +  }, +  nginx = { +    formatters = { +      -- { +      --   exe = "nginx_beautifier", +      --   args = { +      --     provider = "", +      --     setup = {}, +      --   }, +      -- }, +    }, +    linters = {}, +    lsp = {}, +  }, +  perl = { +    formatters = { +      -- { +      --   exe = "perltidy", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "", +      setup = {}, +    }, +  }, +  sql = { +    formatters = { +      -- { +      --   exe = "sqlformat", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "sqls", +      setup = { +        cmd = { "sqls" }, +      }, +    }, +  }, +  php = { +    formatters = { +      -- { +      --   exe = "phpcbf", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "intelephense", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/php/node_modules/.bin/intelephense", +          "--stdio", +        }, +        filetypes = { "php", "phtml" }, +        settings = { +          intelephense = { +            environment = { +              phpVersion = "7.4", +            }, +          }, +        }, +      }, +    }, +  }, +  puppet = { +    formatters = {}, +    linters = {}, +    lsp = { +      provider = "puppet", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/puppet/puppet-editor-services/puppet-languageserver", +          "--stdio", +        }, +      }, +    }, +  }, +  javascript = { +    formatters = { +      -- { +      --   exe = "prettier", +      --   args = {}, +      -- }, +      -- { +      --   exe = "prettier_d_slim", +      --   args = {}, +      -- }, +      -- { +      --   exe = "prettierd", +      --   args = {}, +      -- }, +    }, +    -- @usage can be {"eslint"} or {"eslint_d"} +    linters = {}, +    lsp = { +      provider = "tsserver", +      setup = { +        cmd = { +          -- TODO: +          DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server", +          "--stdio", +        }, +      }, +    }, +  }, +  javascriptreact = { +    formatters = { +      -- { +      --   exe = "prettier", +      --   args = {}, +      -- }, +      -- { +      --   exe = "prettier_d_slim", +      --   args = {}, +      -- }, +      -- { +      --   exe = "prettierd", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "tsserver", +      setup = { +        cmd = { +          -- TODO: +          DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server", +          "--stdio", +        }, +      }, +    }, +  }, +  python = { +    formatters = { +      -- { +      --   exe = "yapf", +      --   args = {}, +      -- }, +      -- { +      --   exe = "isort", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "pyright", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/python/node_modules/.bin/pyright-langserver", +          "--stdio", +        }, +      }, +    }, +  }, +  -- R -e 'install.packages("formatR",repos = "http://cran.us.r-project.org")' +  -- R -e 'install.packages("readr",repos = "http://cran.us.r-project.org")' +  r = { +    formatters = { +      -- { +      --   exe = "format_r", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "r_language_server", +      setup = { +        cmd = { +          "R", +          "--slave", +          "-e", +          "languageserver::run()", +        }, +      }, +    }, +  }, +  ruby = { +    formatters = { +      -- { +      --   exe = "rufo", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "solargraph", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/ruby/solargraph/solargraph", +          "stdio", +        }, +        filetypes = { "ruby" }, +        init_options = { +          formatting = true, +        }, +        root_dir = function(fname) +          local util = require("lspconfig").util +          return util.root_pattern("Gemfile", ".git")(fname) +        end, +        settings = { +          solargraph = { +            diagnostics = true, +          }, +        }, +      }, +    }, +  }, +  rust = { +    formatters = { +      -- { +      --   exe = "rustfmt", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "rust_analyzer", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/rust/rust-analyzer", +        }, +      }, +    }, +  }, +  scala = { +    formatters = { +      -- { +      --   exe = "scalafmt", +      --   args = {}, +      -- }, +    }, +    linters = { "" }, +    lsp = { +      provider = "metals", +      setup = {}, +    }, +  }, +  sh = { +    formatters = { +      -- { +      --   exe = "shfmt", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "bashls", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/bash/node_modules/.bin/bash-language-server", +          "start", +        }, +      }, +    }, +  }, +  svelte = { +    formatters = {}, +    linters = {}, +    lsp = { +      provider = "svelte", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/svelte/node_modules/.bin/svelteserver", +          "--stdio", +        }, +      }, +    }, +  }, +  swift = { +    formatters = { +      -- { +      --   exe = "swiftformat", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "sourcekit", +      setup = { +        cmd = { +          "xcrun", +          "sourcekit-lsp", +        }, +      }, +    }, +  }, +  tailwindcss = { +    active = false, +    filetypes = { +      "html", +      "css", +      "scss", +      "javascript", +      "javascriptreact", +      "typescript", +      "typescriptreact", +    }, +  }, +  terraform = { +    formatters = { +      -- { +      --   exe = "terraform_fmt", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "terraformls", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/terraform/terraform-ls", +          "serve", +        }, +      }, +    }, +  }, +  tex = { +    formatters = {}, +    linters = {}, +    lsp = { +      provider = "texlab", +      setup = { +        cmd = { DATA_PATH .. "/lspinstall/latex/texlab" }, +      }, +    }, +  }, +  typescript = { +    formatters = { +      -- { +      --   exe = "prettier", +      --   args = {}, +      -- }, +      -- { +      --   exe = "prettierd", +      --   args = {}, +      -- }, +      -- { +      --   exe = "prettier_d_slim", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "tsserver", +      setup = { +        cmd = { +          -- TODO: +          DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server", +          "--stdio", +        }, +      }, +    }, +  }, +  typescriptreact = { +    formatters = { +      -- { +      --   exe = "prettier", +      --   args = {}, +      -- }, +      -- { +      --   exe = "prettierd", +      --   args = {}, +      -- }, +      -- { +      --   exe = "prettier_d_slim", +      --   args = {}, +      -- }, +    }, +    -- @usage can be {"eslint"} or {"eslint_d"} +    linters = {}, +    lsp = { +      provider = "tsserver", +      setup = { +        cmd = { +          -- TODO: +          DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server", +          "--stdio", +        }, +      }, +    }, +  }, +  vim = { +    formatters = {}, +    linters = {}, +    lsp = { +      provider = "vimls", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/vim/node_modules/.bin/vim-language-server", +          "--stdio", +        }, +      }, +    }, +  }, +  vue = { +    formatters = { +      -- { +      --   exe = "prettier", +      --   args = {}, +      -- }, +      -- { +      --   exe = "prettierd", +      --   args = {}, +      -- }, +      -- { +      --   exe = "prettier_d_slim", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "vuels", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/vue/node_modules/.bin/vls", +        }, +      }, +    }, +  }, +  yaml = { +    formatters = { +      -- { +      --   exe = "prettier", +      --   args = {}, +      -- }, +      -- { +      --   exe = "prettierd", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "yamlls", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/yaml/node_modules/.bin/yaml-language-server", +          "--stdio", +        }, +      }, +    }, +  }, +  zig = { +    formatters = {}, +    linters = {}, +    lsp = { +      provider = "zls", +      setup = { +        cmd = { +          "zls", +        }, +      }, +    }, +  }, +  gdscript = { +    formatters = {}, +    linters = {}, +    lsp = { +      provider = "gdscript", +      setup = { +        cmd = { +          "nc", +          "localhost", +          "6008", +        }, +      }, +    }, +  }, +  ps1 = { +    formatters = {}, +    linters = {}, +    lsp = { +      provider = "powershell_es", +      setup = { +        bundle_path = "", +      }, +    }, +  }, +  nix = { +    formatters = { +      -- { +      --   exe = "nixfmt", +      --   args = {}, +      -- }, +    }, +    linters = {}, +    lsp = { +      provider = "rnix", +      setup = { +        cmd = { "rnix-lsp" }, +        filetypes = { "nix" }, +        init_options = {}, +        settings = {}, +        root_dir = function(fname) +          local util = require "lspconfig/util" +          return util.root_pattern ".git"(fname) or vim.fn.getcwd() +        end, +      }, +    }, +  }, +} diff --git a/lua/config/init.lua b/lua/config/init.lua new file mode 100644 index 00000000..9833fe6b --- /dev/null +++ b/lua/config/init.lua @@ -0,0 +1,44 @@ +local M = { +  path = string.format("%s/.config/lvim/config.lua", os.getenv "HOME"), +} + +--- Initialize lvim default configuration +-- Define lvim global variable +function M:init() +  local utils = require "utils" + +  require "config.defaults" + +  local builtins = require "core.builtins" +  builtins.config(self) + +  local settings = require "config.settings" +  settings.load_options() + +  -- Fallback config.lua to lv-config.lua +  if not utils.is_file(self.path) then +    local lv_config = self.path:gsub("config.lua$", "lv-config.lua") +    print(self.path, "not found, falling back to", lv_config) + +    self.path = lv_config +  end +end + +--- Override the configuration with a user provided one +-- @param config_path The path to the configuration overrides +function M:load(config_path) +  config_path = config_path or self.path +  local ok, err = pcall(vim.cmd, "luafile " .. config_path) +  if not ok then +    print("Invalid configuration", config_path) +    print(err) +    return +  end + +  self.path = config_path + +  local settings = require "config.settings" +  settings.load_commands() +end + +return M diff --git a/lua/config/settings.lua b/lua/config/settings.lua new file mode 100644 index 00000000..ba71a922 --- /dev/null +++ b/lua/config/settings.lua @@ -0,0 +1,76 @@ +local M = {} + +M.load_options = function() +  local default_options = { +    backup = false, -- creates a backup file +    clipboard = "unnamedplus", -- allows neovim to access the system clipboard +    cmdheight = 2, -- more space in the neovim command line for displaying messages +    colorcolumn = "99999", -- fixes indentline for now +    completeopt = { "menuone", "noselect" }, +    conceallevel = 0, -- so that `` is visible in markdown files +    fileencoding = "utf-8", -- the encoding written to a file +    foldmethod = "manual", -- folding, set to "expr" for treesitter based folding +    foldexpr = "", -- set to "nvim_treesitter#foldexpr()" for treesitter based folding +    guifont = "monospace:h17", -- the font used in graphical neovim applications +    hidden = true, -- required to keep multiple buffers and open multiple buffers +    hlsearch = true, -- highlight all matches on previous search pattern +    ignorecase = true, -- ignore case in search patterns +    mouse = "a", -- allow the mouse to be used in neovim +    pumheight = 10, -- pop up menu height +    showmode = false, -- we don't need to see things like -- INSERT -- anymore +    showtabline = 2, -- always show tabs +    smartcase = true, -- smart case +    smartindent = true, -- make indenting smarter again +    splitbelow = true, -- force all horizontal splits to go below current window +    splitright = true, -- force all vertical splits to go to the right of current window +    swapfile = false, -- creates a swapfile +    termguicolors = true, -- set term gui colors (most terminals support this) +    timeoutlen = 100, -- time to wait for a mapped sequence to complete (in milliseconds) +    title = true, -- set the title of window to the value of the titlestring +    -- opt.titlestring = "%<%F%=%l/%L - nvim" -- what the title of the window will be set to +    undodir = CACHE_PATH .. "/undo", -- set an undo directory +    undofile = true, -- enable persistent undo +    updatetime = 300, -- faster completion +    writebackup = false, -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited +    expandtab = true, -- convert tabs to spaces +    shiftwidth = 2, -- the number of spaces inserted for each indentation +    tabstop = 2, -- insert 2 spaces for a tab +    cursorline = true, -- highlight the current line +    number = true, -- set numbered lines +    relativenumber = false, -- set relative numbered lines +    numberwidth = 4, -- set number column width to 2 {default 4} +    signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time +    wrap = false, -- display lines as one long line +    spell = false, +    spelllang = "en", +    scrolloff = 8, -- is one of my fav +    sidescrolloff = 8, +  } ---  VIM ONLY COMMANDS  ---cmd "filetype plugin on"cmd('let &titleold="' .. TERMINAL .. '"')cmd "set inccommand=split"cmd "set iskeyword+=-" + +  ---  SETTINGS  --- + +  vim.opt.shortmess:append "c" + +  for k, v in pairs(default_options) do +    vim.opt[k] = v +  end +end + +M.load_commands = function() +  local cmd = vim.cmd +  if lvim.line_wrap_cursor_movement then +    cmd "set whichwrap+=<,>,[,],h,l" +  end + +  if lvim.transparent_window then +    cmd "au ColorScheme * hi Normal ctermbg=none guibg=none" +    cmd "au ColorScheme * hi SignColumn ctermbg=none guibg=none" +    cmd "au ColorScheme * hi NormalNC ctermbg=none guibg=none" +    cmd "au ColorScheme * hi MsgArea ctermbg=none guibg=none" +    cmd "au ColorScheme * hi TelescopeBorder ctermbg=none guibg=none" +    cmd "au ColorScheme * hi NvimTreeNormal ctermbg=none guibg=none" +    cmd "let &fcs='eob: '" +  end +end + +return M | 
