diff options
110 files changed, 3194 insertions, 2819 deletions
| diff --git a/.github/workflows/format.yaml b/.github/workflows/format.yaml new file mode 100644 index 00000000..22e56d61 --- /dev/null +++ b/.github/workflows/format.yaml @@ -0,0 +1,43 @@ +name: format +on: +  push: +    branches: '**' +  pull_request: +    branches: +      - 'master' +      - 'rolling' + +jobs: +  stylua-check: +    name: "Formatting check with Stylua" +    runs-on: ubuntu-20.04 +    steps: +      - uses: actions/checkout@v2 + +      - name: Prepare dependencies +        run: | +          sudo apt install -y curl unzip --no-install-recommends +          bash ./utils/installer/install_stylua.sh + +      - name: Check formatting +        run: | +          ./utils/stylua --config-path .stylua.toml -c . +  shfmt-check: +    name: "Formatting check with shfmt" +    runs-on: ubuntu-20.04 +    steps: +      - uses: actions/checkout@v2 + +      - name: Setup Go +        uses: actions/setup-go@v2 +        with: +          go-version: '1.16' +       +      - name: Use shfmt +        run: | +          GO111MODULE=on go get mvdan.cc/sh/v3/cmd/shfmt + +      - name: Check formatting +        run: | +          shfmt -l -d . +     diff --git a/.github/workflows/install.yaml b/.github/workflows/install.yaml new file mode 100644 index 00000000..e31607fe --- /dev/null +++ b/.github/workflows/install.yaml @@ -0,0 +1,72 @@ +name: install +on: +  push: +    branches: '**' +  pull_request: +    branches: +      - 'master' +      - 'rolling' + +jobs: +  unixish: +    name: ${{ matrix.os }} ${{ matrix.runner }} +    strategy: +      fail-fast: false +      matrix: +        include: +          - runner: ubuntu-20.04 +            os: linux +          - runner: macos-10.15 +            os: osx +    runs-on: ${{ matrix.runner }} +    if: github.event.pull_request.draft == false +    steps: +      - uses: actions/checkout@v2 +       +      - name: Install dependencies for Linux +        if: matrix.os == 'linux' +        run: | +          sudo add-apt-repository ppa:neovim-ppa/unstable -y +          sudo apt-get update +          sudo apt-get install neovim -y + +      - name: Installl dependencies for OSX +        if: matrix.os == 'osx' +        run: | +          brew update >/dev/null +          brew install neovim + +      - name: Install LunarVim +        run: | +          bash ./utils/installer/install.sh --testing + +      - name: Test LunarVim PackerCompile +        run: if lvim --headless +PackerCompile -c ':qall' 2>&1|grep -q 'Error'; then false; fi + +      - name: Test LunarVim Health +        run: if lvim --headless +checkhealth -c ':qall' 2>&1|grep -q 'Error'; then false; fi + +#   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/[email protected] +#         with: +#           prepare: pkg install -y curl neovim +#           run: bash ./utils/installer/install.sh + +#       - name: Test LunarVim PackerCompile +#         uses: vmactions/[email protected] +#         with: +#           run: if nvim --headless +PackerCompile -c ':qall' 2>&1|grep -q 'Error'; then false; fi + +#       - name: Test LunarVim Health +#         uses: vmactions/[email protected] +#         with: +#           run: if nvim --headless +checkhealth -c ':qall' 2>&1|grep -q 'Error'; then false; fi + diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 00000000..87f93a00 --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,38 @@ +name: lint +on: +  push: +    branches: '**' +  pull_request: +    branches: +      - 'master' +      - 'rolling' + +jobs: +  lua-linter: +    name: "Linting with luacheck" +    runs-on: ubuntu-20.04 +    steps: +      - uses: actions/checkout@v2 +       +      - uses: leafo/gh-actions-lua@v8 +      - uses: leafo/gh-actions-luarocks@v4 + +      - name: Use luacheck +        run: luarocks install luacheck +       +      - name: Run luacheck +        run: luacheck *.lua lua/ +     +  shell-linter: +    name: "Linting with shellcheck" +    runs-on: ubuntu-20.04 +    steps: +      - uses: actions/checkout@v2 +       +      - name: Use shellcheck +        run: sudo apt-get install shellcheck +       +      - name: Run shellcheck +        run:  | +          pwd +          shellcheck $(find . -name "*.sh") @@ -19,6 +19,11 @@ eclipse.jdt.ls/  spell/  nv-settings.lua  lv-settings.lua -.stylua.toml  lua/lv-user/  lua/lv-user-config/ + +*.tmp +*.temp +*.bak +*.backup +*.old diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 00000000..b55bbb23 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,38 @@ +-- vim: ft=lua tw=80 + +stds.nvim = { +	globals = { +		"lvim", +		vim = { fields = { "g" } }, +		"CONFIG_PATH", +		"CACHE_PATH", +		"DATA_PATH", +		"TERMINAL", +		"USER", +    "C", +    "Config", +    "WORKSPACE_PATH", +    "JAVA_LS_EXECUTABLE", +    "MUtils", +    os = {fields = {"capture"}} +	}, +	read_globals = { +		"jit", +		"os", +		"vim", +		-- vim = { fields = { "cmd", "api", "fn", "o" } }, +	}, +} +std = "lua51+nvim" + + +-- Don't report unused self arguments of methods. +self = false + +-- Rerun tests only if their modification time changed. +cache = true + +ignore = { +	"631", -- max_line_length +	"212/_.*", -- unused argument, for vars with "_" prefix +} diff --git a/utils/.stylua.toml b/.stylua.toml index df96b7b0..df96b7b0 100644 --- a/utils/.stylua.toml +++ b/.stylua.toml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cf6bbb96..f1a8ea57 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,7 +18,8 @@ One of the best ways to begin contributing in a meaningful way is by helping fin  ## Setting up development tools  1. Install [stylua](https://github.com/johnnymorganz/stylua#installation) -2. Copy tools/.stylua.toml into the LunarVim root directory + +2. Install [shfmt](https://github.com/mvdan/sh#shfmt)  ## Some Guidelines @@ -39,6 +40,16 @@ ex: (feature|bugfix|hotfix)/what-my-pr-does  All lua code is formatted with [Stylua](https://github.com/JohnnyMorganz/StyLua).  * Use snake_case  * Avoid platform-dependent code +```bash +stylua --config-path ./utils/.stylua.toml -c . +``` + +All shell code is formatted according to [Google Shell Style Guide](https://google.github.io/styleguide/shellguide.html) +* use two spaces instead of tabs +```bash +shfmt -i 2 -ci -l -d . +``` +  ## Communication @@ -28,19 +28,32 @@ Make sure you have the newest version of Neovim (0.5).  bash <(curl -s https://raw.githubusercontent.com/ChristianChiarulli/lunarvim/master/utils/installer/install.sh)  ``` -If you help to develop Lunarvim, you can install a specific branch branch directly +### Installing +The following command installs LunarVim.  Change `LVBRANCH` to the branch you'd like to install.  `master` for the stable branch and `rolling` for the latest changes.  ``` bash  LVBRANCH=rolling bash <(curl -s https://raw.githubusercontent.com/ChristianChiarulli/lunarvim/rolling/utils/installer/install.sh)  ``` +### BREAKING CHANGE on the rolling branch +* The latest changes to LunarVim require you to [remove it completely](https://github.com/ChristianChiarulli/LunarVim/wiki/Uninstalling-LunarVim) before upgrading +* Going forward LunarVim will no longer reside in the nvim configuration folder.  LunarVim has been moved to `~/.local/share/lunarvim`.   +* To launch Lunarvim use the new `lvim` command.  `nvim` will only launch standard neovim.   +* Your personal configuration file (`lv-config.lua`) can now be found in `~/.config/lvim`.  You can initialize this folder as a git repository to track changes to your configuration files. +* If you want to keep launching LunarVim with the `nvim` command, add an alias entry to your shell's config file:  `alias nvim=lvim`.  To temporarily revert to the default `nvim` prefix it with a backslash `\nvim`. +* Many options formerly available in `lv-config.lua` have been renamed.  For details [look here](https://github.com/ChristianChiarulli/LunarVim/wiki/Breaking-changes-in-rolling) + +### Fixing installation problems  If your installation is stuck on `Ok to remove? [y/N]`, it means there are some leftovers, \ -you can run the script with `--overwrite` but be warned this will remove the following folder: -- `~/.config/nvim` +you can run the script with `--overwrite` but be warned this will remove the following folders:  - `~/.cache/nvim` -- `~/.local/share/nvim/site/pack/packer` +- `~/.config/nvim`                        #Removed only on Master Branch +- `~/.local/share/nvim/site/pack/packer`  #Removed only on Master Branch +- `~/.local/share/lunarvim`               #Removed only on Rolling Branch +- `~/.config/lvim`                        #Removed only on Rolling Branch  ```bash -curl -s https://raw.githubusercontent.com/ChristianChiarulli/lunarvim/rolling/utils/installer/install.sh| LVBRANCH=rolling bash -s -- --overwrite +curl -s https://raw.githubusercontent.com/ChristianChiarulli/lunarvim/rolling/utils/installer/install.sh | LVBRANCH=rolling bash -s -- --overwrite  ``` +then run nvim and wait for treesitter to finish the installation  ## Installing LSP for your language @@ -49,85 +62,76 @@ Just enter `:LspInstall` followed by `<TAB>` to see your options  **NOTE** I recommend installing `lua` for autocomplete in `lv-config.lua` +For the julia language server look [here](https://github.com/ChristianChiarulli/LunarVim/wiki/Enabling-a-language-server#julia-support) +  ## Configuration file -To activate other plugins and language features use the `lv-config.lua` file provided in the `nvim` folder (`~/.config/nvim/lv-config.lua`) +To activate other plugins and language features use the `lv-config.lua` file provided in the `nvim` folder (`~/.config/nvim/lv-config.lua`) in the master branch or (`~/.config/lvim/lv-config.lua`) on rolling  Example:  ```lua --- O is the global options object - --- THESE ARE EXAMPLE CONFIGS FEEL FREE TO CHANGE TO WHATEVER YOU WANT  -- general --- O.default_options.wrap = true -- wrap long lines -O.completion.autocomplete = true -O.default_options.relativenumber = true -O.colorscheme = 'spacegray' -O.default_options.timeoutlen = 100 -O.leader_key = ' ' - --- After changing plugin config it is recommended to run :PackerCompile -O.plugin.dashboard.active = true -O.plugin.floatterm.active = true -O.plugin.zen.active = true +lvim.format_on_save = true +lvim.lint_on_save = true +lvim.colorscheme = "spacegray" + +lvim.builtin.compe.autocomplete = true + +-- keymappings +lvim.leader = "space" + +-- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile +lvim.builtin.dashboard.active = true +lvim.builtin.terminal.active = true  -- if you don't want all the parsers change this to a table of the ones you want -O.treesitter.ensure_installed = "all" -O.treesitter.ignore_install = {"haskell"} -O.treesitter.highlight.enabled = true - --- lua -O.lang.lua.autoformat = false -O.lang.lua.formatter = 'lua-format' - --- javascript -O.lang.tsserver.formatter = 'prettier' -O.lang.tsserver.linter = nil -O.lang.tsserver.autoformat = true - --- python -O.lang.python.isort = true -O.lang.python.diagnostics.virtual_text = true -O.lang.python.analysis.use_library_code_types = true --- to change default formatter from yapf to black --- O.lang.python.formatter.exe = "black" --- O.lang.python.formatter.args = {"-"} - --- go --- to change default formatter from gofmt to goimports --- O.lang.formatter.go.exe = "goimports" +lvim.builtin.treesitter.ensure_installed = "maintained" +lvim.builtin.treesitter.ignore_install = { "haskell" } +lvim.builtin.treesitter.highlight.enabled = true --- Additional Plugins --- O.user_plugins = { ---   {"folke/tokyonight.nvim"}, ---   { ---     "ray-x/lsp_signature.nvim", ---     config = function() ---       require"lsp_signature".on_attach() ---     end, ---     event = "InsertEnter" ---   }, --- } +lvim.lang.python.formatter.exe = "black" +lvim.lang.python.linters = "" --- } +lvim.lsp.diagnostics.virtual_text = false + +-- Additional Plugins +lvim.plugins = { +    {"lunarvim/colorschemes"}, +    {"folke/tokyonight.nvim"}, { +        "ray-x/lsp_signature.nvim", +        config = function() require"lsp_signature".on_attach() end, +        event = "InsertEnter" +    } +}  -- Autocommands (https://neovim.io/doc/user/autocmd.html) --- O.user_autocommands = {{ "BufWinEnter", "*", "echo \"hi again\""}} +-- lvim.autocommands.custom_groups = { +--   { "BufWinEnter", "*.lua", "setlocal ts=8 sw=8" }, +-- }  -- Additional Leader bindings for WhichKey --- O.user_which_key = { ---   A = { ---     name = "+Custom Leader Keys", ---     a = { "<cmd>echo 'first custom command'<cr>", "Description for a" }, ---     b = { "<cmd>echo 'second custom command'<cr>", "Description for b" }, ---   }, +-- lvim.builtin.which_key.mappings["P"] = { "<cmd>lua require'telescope'.extensions.project.project{}<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>", "Diagnosticss" }, +--   q = { "<cmd>Trouble quickfix<cr>", "QuickFix" }, +--   l = { "<cmd>Trouble loclist<cr>", "LocationList" }, +--   w = { "<cmd>Trouble lsp_workspace_diagnostics<cr>", "Diagnosticss" },  -- } --- To link your init.vim (until you find Lua replacements) --- vim.cmd('source ' .. CONFIG_PATH .. '/lua/lv-user/init.vim')  ``` +In case you want to see all the settings inside LunarVim, run the following: + +```bash +cd /tmp +lvim --headless +'lua require("utils").generate_settings()' +qa && sort -o lv-settings.lua{,} +``` +and then inspect `/tmp/lv-settings.lua` file +  ## Updating LunarVim  In order to update you should be aware of three things `Plugins`, `LunarVim` and `Neovim` @@ -141,10 +145,16 @@ To update plugins:  To update LunarVim:  ```bash +# Master Branch  cd ~/.config/nvim && git pull +:PackerSync   + +# Rolling Branch +cd ~/.local/share/lunarvim/lvim && git pull +:PackerSync  ``` -To update Neovim use your package manager +To update Neovim use your package manager or [compile from source](https://github.com/ChristianChiarulli/LunarVim/wiki/Installation#get-the-latest-version-of-neovim)  ## Project Goals diff --git a/ftdetect/fish.lua b/ftdetect/fish.lua new file mode 100644 index 00000000..c908c46e --- /dev/null +++ b/ftdetect/fish.lua @@ -0,0 +1,3 @@ +vim.cmd [[ + au BufRead,BufNewFile *.fish set filetype=fish +]] diff --git a/ftdetect/julia.lua b/ftdetect/julia.lua new file mode 100644 index 00000000..2f8087cd --- /dev/null +++ b/ftdetect/julia.lua @@ -0,0 +1 @@ +vim.cmd [[ au BufRead,BufNewFile *.jl set filetype=julia ]] diff --git a/ftplugin/c.lua b/ftplugin/c.lua index 8beaae5d..3f931e4a 100644 --- a/ftplugin/c.lua +++ b/ftplugin/c.lua @@ -1,40 +1,4 @@ -O.formatters.filetype["c"] = { -  function() -    return { -      exe = O.lang.c.formatter.exe, -      args = O.lang.c.formatter.args, -      stdin = not (O.lang.c.formatter.stdin ~= nil), -    } -  end, -} -O.formatters.filetype["cpp"] = O.formatters.filetype["c"] +require("lsp").setup "c" -require("formatter.config").set_defaults { -  logging = false, -  filetype = O.formatters.filetype, -} - -if require("lv-utils").check_lsp_client_active "clangd" then -  return -end - -local clangd_flags = { "--background-index" } - -if O.lang.clang.cross_file_rename then -  table.insert(clangd_flags, "--cross-file-rename") -end - -table.insert(clangd_flags, "--header-insertion=" .. O.lang.clang.header_insertion) - -require("lspconfig").clangd.setup { -  cmd = { DATA_PATH .. "/lspinstall/cpp/clangd/bin/clangd", unpack(clangd_flags) }, -  on_attach = require("lsp").common_on_attach, -  handlers = { -    ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { -      virtual_text = O.lang.clang.diagnostics.virtual_text, -      signs = O.lang.clang.diagnostics.signs, -      underline = O.lang.clang.diagnostics.underline, -      update_in_insert = true, -    }), -  }, -} +-- TODO get from dap +-- require("lang.c").dap() diff --git a/ftplugin/clojure.lua b/ftplugin/clojure.lua new file mode 100644 index 00000000..683720a5 --- /dev/null +++ b/ftplugin/clojure.lua @@ -0,0 +1 @@ +require("lsp").setup "clojure" diff --git a/ftplugin/cmake.lua b/ftplugin/cmake.lua index 35369a15..56d30106 100644 --- a/ftplugin/cmake.lua +++ b/ftplugin/cmake.lua @@ -1,9 +1 @@ -if require("lv-utils").check_lsp_client_active "cmake" then -  return -end - -require("lspconfig").cmake.setup { -  cmd = { DATA_PATH .. "/lspinstall/cmake/venv/bin/cmake-language-server" }, -  on_attach = require("lsp").common_on_attach, -  filetypes = { "cmake" }, -} +require("lsp").setup "cmake" diff --git a/ftplugin/cpp.lua b/ftplugin/cpp.lua index d2be5311..6028ea49 120000..100644 --- a/ftplugin/cpp.lua +++ b/ftplugin/cpp.lua @@ -1 +1 @@ -c.lua
\ No newline at end of file +require("lsp").setup "cpp" diff --git a/ftplugin/cs.lua b/ftplugin/cs.lua index e0a0f62a..6c349494 100644 --- a/ftplugin/cs.lua +++ b/ftplugin/cs.lua @@ -1,10 +1 @@ -if require("lv-utils").check_lsp_client_active "omnisharp" then -  return -end - --- C# language server (csharp/OmniSharp) setup -require("lspconfig").omnisharp.setup { -  on_attach = require("lsp").common_on_attach, -  root_dir = require("lspconfig").util.root_pattern(".sln", ".git"), -  cmd = { DATA_PATH .. "/lspinstall/csharp/omnisharp/run", "--languageserver", "--hostPID", tostring(vim.fn.getpid()) }, -} +require("lsp").setup "cs" diff --git a/ftplugin/css.lua b/ftplugin/css.lua index 9cd7cc71..094ed2a3 100644 --- a/ftplugin/css.lua +++ b/ftplugin/css.lua @@ -1,16 +1 @@ -if not require("lv-utils").check_lsp_client_active "cssls" then -  local capabilities = vim.lsp.protocol.make_client_capabilities() -  capabilities.textDocument.completion.completionItem.snippetSupport = true -  -- npm install -g vscode-css-languageserver-bin -  require("lspconfig").cssls.setup { -    cmd = { -      "node", -      DATA_PATH .. "/lspinstall/css/vscode-css/css-language-features/server/dist/node/cssServerMain.js", -      "--stdio", -    }, -    on_attach = require("lsp").common_on_attach, -    capabilities = capabilities, -  } -end - -vim.cmd "setl ts=2 sw=2" +require("lsp").setup "css" diff --git a/ftplugin/dart.lua b/ftplugin/dart.lua index f9b68e9d..9f0ccfa0 100644 --- a/ftplugin/dart.lua +++ b/ftplugin/dart.lua @@ -1,29 +1 @@ -O.formatters.filetype["dart"] = { -  function() -    return { -      exe = O.lang.dart.formatter.exe, -      args = O.lang.dart.formatter.args, -      stdin = not (O.lang.dart.formatter.stdin ~= nil), -    } -  end, -} - -require("formatter.config").set_defaults { -  logging = false, -  filetype = O.formatters.filetype, -} -if require("lv-utils").check_lsp_client_active "dartls" then -  return -end - -require("lspconfig").dartls.setup { -  cmd = { "dart", O.lang.dart.sdk_path, "--lsp" }, -  on_attach = require("lsp").common_on_attach, -  init_options = { -    closingLabels = false, -    flutterOutline = false, -    onlyAnalyzeProjectsWithOpenFiles = false, -    outline = false, -    suggestFromUnimportedLibraries = true, -  }, -} +require("lsp").setup "dart" diff --git a/ftplugin/dockerfile.lua b/ftplugin/dockerfile.lua index e0fa97af..72ec7f90 100644 --- a/ftplugin/dockerfile.lua +++ b/ftplugin/dockerfile.lua @@ -1,10 +1 @@ -if require("lv-utils").check_lsp_client_active "dockerls" then -  return -end - --- npm install -g dockerfile-language-server-nodejs -require("lspconfig").dockerls.setup { -  cmd = { DATA_PATH .. "/lspinstall/dockerfile/node_modules/.bin/docker-langserver", "--stdio" }, -  on_attach = require("lsp").common_on_attach, -  root_dir = vim.loop.cwd, -} +require("lsp").setup "docker" diff --git a/ftplugin/elixir.lua b/ftplugin/elixir.lua index f3869ee5..f16f71fa 100644 --- a/ftplugin/elixir.lua +++ b/ftplugin/elixir.lua @@ -1,14 +1,9 @@ -if require("lv-utils").check_lsp_client_active "elixirls" then -  return -end - -require("lspconfig").elixirls.setup { -  cmd = { DATA_PATH .. "/lspinstall/elixir/elixir-ls/language_server.sh" }, -} +require("lsp").setup "elixir" +-- TODO: do we need this?  -- needed for the LSP to recognize elixir files (alternativly just use elixir-editors/vim-elixir) --- vim.cmd([[ +-- vim.cmd [[  --   au BufRead,BufNewFile *.ex,*.exs set filetype=elixir  --   au BufRead,BufNewFile *.eex,*.leex,*.sface set filetype=eelixir  --   au BufRead,BufNewFile mix.lock set filetype=elixir --- ]]) +-- ]] diff --git a/ftplugin/elm.lua b/ftplugin/elm.lua index d1d6ee12..38fda314 100644 --- a/ftplugin/elm.lua +++ b/ftplugin/elm.lua @@ -1,13 +1 @@ -if require("lv-utils").check_lsp_client_active "elmls" then -  return -end - -require("lspconfig").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/elm", -    elmTestPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/elm-test", -  }, -} +require("lsp").setup "elm" diff --git a/ftplugin/erlang.lua b/ftplugin/erlang.lua new file mode 100644 index 00000000..c6426dba --- /dev/null +++ b/ftplugin/erlang.lua @@ -0,0 +1 @@ +require("lsp").setup "erlang" diff --git a/ftplugin/euphoria3.lua b/ftplugin/euphoria3.lua index b59a265a..391c51ad 100644 --- a/ftplugin/euphoria3.lua +++ b/ftplugin/euphoria3.lua @@ -1,15 +1,9 @@ -if require("lv-utils").check_lsp_client_active "elixirls" then -  return -end - --- TODO: Remove this at some point -require("lspconfig").elixirls.setup { -  cmd = { DATA_PATH .. "/lspinstall/elixir/elixir-ls/language_server.sh" }, -} +require("lsp").setup "erlang" +-- TODO: do we need this?  -- needed for the LSP to recognize elixir files (alternativly just use elixir-editors/vim-elixir) --- vim.cmd([[ +-- vim.cmd [[  --   au BufRead,BufNewFile *.ex,*.exs set filetype=elixir  --   au BufRead,BufNewFile *.eex,*.leex,*.sface set filetype=eelixir  --   au BufRead,BufNewFile mix.lock set filetype=elixir --- ]]) +-- ]] diff --git a/ftplugin/fish.lua b/ftplugin/fish.lua new file mode 100644 index 00000000..575ec434 --- /dev/null +++ b/ftplugin/fish.lua @@ -0,0 +1 @@ +require("lsp").setup "fish" diff --git a/ftplugin/go.lua b/ftplugin/go.lua index 47de932f..218b634c 100644 --- a/ftplugin/go.lua +++ b/ftplugin/go.lua @@ -1,29 +1 @@ -O.formatters.filetype["go"] = { -  function() -    return { -      exe = O.lang.go.formatter.exe, -      args = O.lang.go.formatter.args, -      stdin = not (O.lang.go.formatter.stdin ~= nil), -    } -  end, -} - -require("formatter.config").set_defaults { -  logging = false, -  filetype = O.formatters.filetype, -} - -if not require("lv-utils").check_lsp_client_active "gopls" then -  require("lspconfig").gopls.setup { -    cmd = { DATA_PATH .. "/lspinstall/go/gopls" }, -    settings = { gopls = { analyses = { unusedparams = true }, staticcheck = true } }, -    root_dir = require("lspconfig").util.root_pattern(".git", "go.mod"), -    init_options = { usePlaceholders = true, completeUnimported = true }, -    on_attach = require("lsp").common_on_attach, -  } -end - -vim.opt_local.tabstop = 4 -vim.opt_local.shiftwidth = 4 -vim.opt_local.softtabstop = 4 -vim.opt_local.expandtab = false +require("lsp").setup "go" diff --git a/ftplugin/graphql.lua b/ftplugin/graphql.lua index c9ce5437..83e8878d 100644 --- a/ftplugin/graphql.lua +++ b/ftplugin/graphql.lua @@ -1,6 +1 @@ -if require("lv-utils").check_lsp_client_active "graphql" then -  return -end - --- npm install -g graphql-language-service-cli -require("lspconfig").graphql.setup { on_attach = require("lsp").common_on_attach } +require("lsp").setup "graphql" diff --git a/ftplugin/html.lua b/ftplugin/html.lua index fa60e0a6..c60394c0 100644 --- a/ftplugin/html.lua +++ b/ftplugin/html.lua @@ -1,17 +1 @@ -if not require("lv-utils").check_lsp_client_active "html" then -  -- npm install -g vscode-html-languageserver-bin -  local capabilities = vim.lsp.protocol.make_client_capabilities() -  capabilities.textDocument.completion.completionItem.snippetSupport = true - -  require("lspconfig").html.setup { -    cmd = { -      "node", -      DATA_PATH .. "/lspinstall/html/vscode-html/html-language-features/server/dist/node/htmlServerMain.js", -      "--stdio", -    }, -    on_attach = require("lsp").common_on_attach, -    capabilities = capabilities, -  } -end - -vim.cmd "setl ts=2 sw=2" +require("lsp").setup "html" diff --git a/ftplugin/java.lua b/ftplugin/java.lua index 7db90f0e..dcb46ca2 100644 --- a/ftplugin/java.lua +++ b/ftplugin/java.lua @@ -1,96 +1 @@ -vim.cmd "let proj = FindRootDirectory()" -local root_dir = vim.api.nvim_get_var "proj" - --- use the global prettier if you didn't find the local one -local prettier_instance = root_dir .. "/node_modules/.bin/prettier" -if vim.fn.executable(prettier_instance) ~= 1 then -  prettier_instance = O.lang.tsserver.formatter.exe -end - -O.formatters.filetype["java"] = { -  function() -    return { -      exe = prettier_instance, -      -- TODO: allow user to override this -      args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0) }, -      stdin = true, -    } -  end, -} - -require("formatter.config").set_defaults { -  logging = false, -  filetype = O.formatters.filetype, -} - -if require("lv-utils").check_lsp_client_active "jdtls" then -  return -end - -if O.lang.java.java_tools.active then -  -- find_root looks for parent directories relative to the current buffer containing one of the given arguments. -  if vim.fn.has "mac" == 1 then -    WORKSPACE_PATH = "/Users/" .. USER .. "/workspace/" -  elseif vim.fn.has "unix" == 1 then -    WORKSPACE_PATH = "/home/" .. USER .. "/workspace/" -  else -    print "Unsupported system" -  end -  JAVA_LS_EXECUTABLE = CONFIG_PATH .. "/utils/bin/jdtls" - -  require("jdtls").start_or_attach { -    on_attach = require("lsp").common_on_attach, -    cmd = { JAVA_LS_EXECUTABLE, WORKSPACE_PATH .. vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t") }, -  } - -  vim.api.nvim_set_keymap( -    "n", -    "<leader>la", -    ":lua require('jdtls').code_action()<CR>", -    { noremap = true, silent = true } -  ) -  vim.api.nvim_set_keymap( -    "n", -    "<leader>lR", -    ":lua require('jdtls').code_action(false, 'refactor')<CR>", -    { noremap = true, silent = true } -  ) - -  vim.cmd "command! -buffer JdtCompile lua require('jdtls').compile()" -  vim.cmd "command! -buffer JdtUpdateConfig lua require('jdtls').update_project_config()" -  -- vim.cmd "command! -buffer JdtJol lua require('jdtls').jol()" -  vim.cmd "command! -buffer JdtBytecode lua require('jdtls').javap()" -  -- vim.cmd "command! -buffer JdtJshell lua require('jdtls').jshell()" -else -  local util = require "lspconfig/util" - -  require("lspconfig").jdtls.setup { -    on_attach = require("lsp").common_on_attach, -    cmd = { DATA_PATH .. "/lspinstall/java/jdtls.sh" }, -    filetypes = { "java" }, -    root_dir = util.root_pattern { ".git", "build.gradle", "pom.xml" }, -    -- init_options = {bundles = bundles} -    -- on_attach = require'lsp'.common_on_attach -  } -end - --- local bundles = { ---     vim.fn.glob( ---         CONFIG_PATH.."/.debuggers/java-debug/com.microsoft.java.debug.plugin/target/com.microsoft.java.debug.plugin-*.jar") --- }; - --- require('jdtls').start_or_attach({ ---     on_attach = on_attach, ---     cmd = {DATA_PATH .. "/lspinstall/java/jdtls.sh"}, ---     root_dir = require('jdtls.setup').find_root({'build.gradle', 'pom.xml', '.git'}), ---     init_options = {bundles = bundles} --- }) - --- TODO: setup autoformat stuff later --- _java = { ---     -- {'FileType', 'java', 'luafile '..CONFIG_PATH..'/lua/lsp/java-ls.lua'}, ---     { ---         'FileType', 'java', ---         'nnoremap ca <Cmd>lua require(\'jdtls\').code_action()<CR>' ---     } --- } +require("lsp").setup "java" diff --git a/ftplugin/javascript.lua b/ftplugin/javascript.lua index fc59ab68..37b95c71 100644 --- a/ftplugin/javascript.lua +++ b/ftplugin/javascript.lua @@ -1 +1 @@ -require "lsp.tsserver-ls" +require("lsp").setup "javascript" diff --git a/ftplugin/javascriptreact.lua b/ftplugin/javascriptreact.lua index f74b54e9..90920166 100644 --- a/ftplugin/javascriptreact.lua +++ b/ftplugin/javascriptreact.lua @@ -1,3 +1 @@ -require "lsp.tsserver-ls" - -vim.cmd "setl ts=2 sw=2" +require("lsp").setup "javascriptreact" diff --git a/ftplugin/json.lua b/ftplugin/json.lua index cb73995c..18368cf9 100644 --- a/ftplugin/json.lua +++ b/ftplugin/json.lua @@ -1,35 +1 @@ -O.formatters.filetype["json"] = { -  function() -    return { -      exe = O.lang.json.formatter.exe, -      args = O.lang.json.formatter.args, -      stdin = not (O.lang.json.formatter.stdin ~= nil), -    } -  end, -} - -require("formatter.config").set_defaults { -  logging = false, -  filetype = O.formatters.filetype, -} -if require("lv-utils").check_lsp_client_active "jsonls" then -  return -end - --- npm install -g vscode-json-languageserver -require("lspconfig").jsonls.setup { -  cmd = { -    "node", -    DATA_PATH .. "/lspinstall/json/vscode-json/json-language-features/server/dist/node/jsonServerMain.js", -    "--stdio", -  }, -  on_attach = require("lsp").common_on_attach, - -  commands = { -    Format = { -      function() -        vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 }) -      end, -    }, -  }, -} +require("lsp").setup "json" diff --git a/ftplugin/julia.lua b/ftplugin/julia.lua new file mode 100644 index 00000000..9840be1f --- /dev/null +++ b/ftplugin/julia.lua @@ -0,0 +1 @@ +require("lsp").setup "julia" diff --git a/ftplugin/kotlin.lua b/ftplugin/kotlin.lua index 8d034e6f..a0e6d5d6 100644 --- a/ftplugin/kotlin.lua +++ b/ftplugin/kotlin.lua @@ -1,38 +1 @@ -if require("lv-utils").check_lsp_client_active "kotlin_language_server" then -  return -end - ---- default config for gradle-projects of the ---- kotlin-language-server: https://github.com/fwcd/kotlin-language-server ---- ---- This server requires vim to be aware of the kotlin-filetype. ---- You could refer for this capability to: ---- 	https://github.com/udalov/kotlin-vim (recommended) ---- 	Note that there is no LICENSE specified yet. - -local util = require "lspconfig/util" - -local bin_name = DATA_PATH .. "/lspinstall/kotlin/server/bin/kotlin-language-server" -if vim.fn.has "win32" == 1 then -  bin_name = bin_name .. ".bat" -end - -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 -} - -require("lspconfig").kotlin_language_server.setup { -  cmd = { bin_name }, -  on_attach = require("lsp").common_on_attach, -  root_dir = function(fname) -    return util.root_pattern(unpack(root_files))(fname) or util.root_pattern(unpack(fallback_root_files))(fname) -  end, -} +require("lsp").setup "kotlin" diff --git a/ftplugin/lua.lua b/ftplugin/lua.lua index eb7b9944..2ed88315 100644 --- a/ftplugin/lua.lua +++ b/ftplugin/lua.lua @@ -1,47 +1 @@ -O.formatters.filetype["lua"] = { -  function() -    return { -      exe = O.lang.lua.formatter.exe, -      args = O.lang.lua.formatter.args, -      stdin = not (O.lang.lua.formatter.stdin ~= nil), -    } -  end, -} - -require("formatter.config").set_defaults { -  logging = false, -  filetype = O.formatters.filetype, -} -if not require("lv-utils").check_lsp_client_active "sumneko_lua" then -  -- https://github.com/sumneko/lua-language-server/wiki/Build-and-Run-(Standalone) -  local sumneko_root_path = DATA_PATH .. "/lspinstall/lua" -  local sumneko_binary = sumneko_root_path .. "/sumneko-lua-language-server" - -  require("lspconfig").sumneko_lua.setup { -    cmd = { sumneko_binary, "-E", sumneko_root_path .. "/main.lua" }, -    on_attach = require("lsp").common_on_attach, -    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" }, -        }, -        workspace = { -          -- Make the server aware of Neovim runtime files -          library = { -            [vim.fn.expand "$VIMRUNTIME/lua"] = true, -            [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true, -          }, -          maxPreload = 100000, -          preloadFileSize = 1000, -        }, -      }, -    }, -  } -end +require("lsp").setup "lua" diff --git a/ftplugin/php.lua b/ftplugin/php.lua index 054dff79..4eabcf71 100644 --- a/ftplugin/php.lua +++ b/ftplugin/php.lua @@ -1,41 +1 @@ -O.formatters.filetype["php"] = { -  function() -    return { -      exe = O.lang.php.formatter.exe, -      args = O.lang.php.formatter.args, -      stdin = not (O.lang.php.formatter.stdin ~= nil), -    } -  end, -} - -require("formatter.config").set_defaults { -  logging = false, -  filetype = O.formatters.filetype, -} -if require("lv-utils").check_lsp_client_active "intelephense" then -  return -end - -require("lspconfig").intelephense.setup { -  cmd = { DATA_PATH .. "/lspinstall/php/node_modules/.bin/intelephense", "--stdio" }, -  on_attach = require("lsp").common_on_attach, -  handlers = { -    ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { -      virtual_text = O.lang.php.diagnostics.virtual_text, -      signs = O.lang.php.diagnostics.signs, -      underline = O.lang.php.diagnostics.underline, -      update_in_insert = true, -    }), -  }, -  filetypes = O.lang.php.filetypes, -  settings = { -    intelephense = { -      format = { -        braces = O.lang.php.format.braces, -      }, -      environment = { -        phpVersion = O.lang.php.environment.php_version, -      }, -    }, -  }, -} +require("lsp").setup "php" diff --git a/ftplugin/puppet.lua b/ftplugin/puppet.lua new file mode 100644 index 00000000..f8521762 --- /dev/null +++ b/ftplugin/puppet.lua @@ -0,0 +1 @@ +require("lsp").setup "puppet" diff --git a/ftplugin/python.lua b/ftplugin/python.lua index d2ade7e2..3e79e6bc 100644 --- a/ftplugin/python.lua +++ b/ftplugin/python.lua @@ -1,85 +1,3 @@ -O.formatters.filetype["python"] = { -  function() -    return { -      exe = O.lang.python.formatter.exe, -      args = O.lang.python.formatter.args, -      stdin = not (O.lang.python.formatter.stdin ~= nil), -    } -  end, -} - -require("formatter.config").set_defaults { -  logging = false, -  filetype = O.formatters.filetype, -} - -local python_arguments = {} - --- TODO: replace with path argument -local flake8 = { -  LintCommand = "flake8 --ignore=E501 --stdin-display-name ${INPUT} -", -  lintStdin = true, -  lintFormats = { "%f:%l:%c: %m" }, -} - -local isort = { formatCommand = "isort --quiet -", formatStdin = true } - -local yapf = { formatCommand = "yapf --quiet", formatStdin = true } -local black = { formatCommand = "black --quiet -", formatStdin = true } - -if O.lang.python.linter == "flake8" then -  table.insert(python_arguments, flake8) -end - -if O.lang.python.isort then -  table.insert(python_arguments, isort) -end - -if not require("lv-utils").check_lsp_client_active "efm" then -  require("lspconfig").efm.setup { -    -- init_options = {initializationOptions}, -    cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" }, -    init_options = { documentFormatting = true, codeAction = false }, -    root_dir = require("lspconfig").util.root_pattern(".git/", "requirements.txt"), -    filetypes = { "python" }, -    settings = { -      rootMarkers = { ".git/", "requirements.txt" }, -      languages = { -        python = python_arguments, -      }, -    }, -  } -end - -if not require("lv-utils").check_lsp_client_active "pyright" then -  -- npm i -g pyright -  require("lspconfig").pyright.setup { -    cmd = { -      DATA_PATH .. "/lspinstall/python/node_modules/.bin/pyright-langserver", -      "--stdio", -    }, -    on_attach = require("lsp").common_on_attach, -    handlers = { -      ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { -        virtual_text = O.lang.python.diagnostics.virtual_text, -        signs = O.lang.python.diagnostics.signs, -        underline = O.lang.python.diagnostics.underline, -        update_in_insert = true, -      }), -    }, -    settings = { -      python = { -        analysis = { -          typeCheckingMode = O.lang.python.analysis.type_checking, -          autoSearchPaths = O.lang.python.analysis.auto_search_paths, -          useLibraryCodeForTypes = O.lang.python.analysis.use_library_code_types, -        }, -      }, -    }, -  } -end - -if O.plugin.dap.active then -  local dap_install = require "dap-install" -  dap_install.config("python_dbg", {}) -end +require("lsp").setup "python" +-- TODO get from dap +-- require("lang.python").dap() diff --git a/ftplugin/r.lua b/ftplugin/r.lua new file mode 100644 index 00000000..296d3c86 --- /dev/null +++ b/ftplugin/r.lua @@ -0,0 +1,2 @@ +-- R -e 'install.packages("languageserver",repos = "http://cran.us.r-project.org")' +require("lsp").setup "r" diff --git a/ftplugin/rmd.lua b/ftplugin/rmd.lua new file mode 120000 index 00000000..401cef17 --- /dev/null +++ b/ftplugin/rmd.lua @@ -0,0 +1 @@ +r.lua
\ No newline at end of file diff --git a/ftplugin/ruby.lua b/ftplugin/ruby.lua index ff7e7c8b..7e968917 100644 --- a/ftplugin/ruby.lua +++ b/ftplugin/ruby.lua @@ -1,32 +1,2 @@ -O.formatters.filetype["ruby"] = { -  function() -    return { -      exe = O.lang.ruby.formatter.exe, -      args = O.lang.ruby.formatter.args, -      stdin = not (O.lang.ruby.formatter.stdin ~= nil), -    } -  end, -} - -require("formatter.config").set_defaults { -  logging = false, -  filetype = O.formatters.filetype, -} -if require("lv-utils").check_lsp_client_active "solargraph" then -  return -end - --- If you are using rvm, make sure to change below configuration -require("lspconfig").solargraph.setup { -  cmd = { DATA_PATH .. "/lspinstall/ruby/solargraph/solargraph", "stdio" }, -  on_attach = require("lsp").common_on_attach, -  handlers = { -    ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { -      virtual_text = O.lang.ruby.diagnostics.virtual_text, -      signs = O.lang.ruby.diagnostics.signs, -      underline = O.lang.ruby.diagnostics.underline, -      update_in_insert = true, -    }), -  }, -  filetypes = O.lang.ruby.filetypes, -} +-- also support sorbet +require("lsp").setup "ruby" diff --git a/ftplugin/rust.lua b/ftplugin/rust.lua index dd34483e..f1623f25 100644 --- a/ftplugin/rust.lua +++ b/ftplugin/rust.lua @@ -1,111 +1,4 @@ -O.formatters.filetype["rust"] = { -  function() -    return { -      exe = O.lang.rust.formatter.exe, -      args = O.lang.rust.formatter.args, -      stdin = not (O.lang.rust.formatter.stdin ~= nil), -    } -  end, -} +require("lsp").setup "rust" -require("formatter.config").set_defaults { -  logging = false, -  filetype = O.formatters.filetype, -} -if require("lv-utils").check_lsp_client_active "rust_analyzer" then -  return -end - -if O.lang.rust.rust_tools.active then -  local opts = { -    tools = { -- rust-tools options -      -- automatically set inlay hints (type hints) -      -- There is an issue due to which the hints are not applied on the first -      -- opened file. For now, write to the file to trigger a reapplication of -      -- the hints or just run :RustSetInlayHints. -      -- default: true -      autoSetHints = true, - -      -- whether to show hover actions inside the hover window -      -- this overrides the default hover handler -      -- default: true -      hover_with_actions = true, - -      runnables = { -        -- whether to use telescope for selection menu or not -        -- default: true -        use_telescope = true, - -        -- rest of the opts are forwarded to telescope -      }, - -      inlay_hints = { -        -- wheter to show parameter hints with the inlay hints or not -        -- default: true -        show_parameter_hints = true, - -        -- prefix for parameter hints -        -- default: "<-" -        parameter_hints_prefix = O.lang.rust.rust_tools.parameter_hints_prefix, - -        -- prefix for all the other hints (type, chaining) -        -- default: "=>" -        other_hints_prefix = O.lang.rust.rust_tools.other_hints_prefix, - -        -- whether to align to the lenght of the longest line in the file -        max_len_align = false, - -        -- padding from the left if max_len_align is true -        max_len_align_padding = 1, - -        -- whether to align to the extreme right or not -        right_align = false, - -        -- padding from the right if right_align is true -        right_align_padding = 7, -      }, - -      hover_actions = { -        -- the border that is used for the hover window -        -- see vim.api.nvim_open_win() -        border = { -          { "╭", "FloatBorder" }, -          { "─", "FloatBorder" }, -          { "╮", "FloatBorder" }, -          { "│", "FloatBorder" }, -          { "╯", "FloatBorder" }, -          { "─", "FloatBorder" }, -          { "╰", "FloatBorder" }, -          { "│", "FloatBorder" }, -        }, -      }, -    }, - -    -- all the opts to send to nvim-lspconfig -    -- these override the defaults set by rust-tools.nvim -    -- see https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#rust_analyzer -    server = { -      cmd = { DATA_PATH .. "/lspinstall/rust/rust-analyzer" }, -      on_attach = require("lsp").common_on_attach, -    }, -- rust-analyser options -  } -  require("rust-tools").setup(opts) -else -  require("lspconfig").rust_analyzer.setup { -    cmd = { DATA_PATH .. "/lspinstall/rust/rust-analyzer" }, -    on_attach = require("lsp").common_on_attach, -    filetypes = { "rust" }, -    root_dir = require("lspconfig.util").root_pattern("Carrust.toml", "rust-project.json"), -  } -end - --- TODO: fix these mappings -vim.api.nvim_exec( -  [[ -    autocmd Filetype rust nnoremap <leader>lm <Cmd>RustExpandMacro<CR> -    autocmd Filetype rust nnoremap <leader>lH <Cmd>RustToggleInlayHints<CR> -    autocmd Filetype rust nnoremap <leader>le <Cmd>RustRunnables<CR> -    autocmd Filetype rust nnoremap <leader>lh <Cmd>RustHoverActions<CR> -    ]], -  true -) +-- TODO get from dap +-- require("lang.rust").dap() diff --git a/ftplugin/sbt.lua b/ftplugin/sbt.lua new file mode 120000 index 00000000..d0d6ce5b --- /dev/null +++ b/ftplugin/sbt.lua @@ -0,0 +1 @@ +scala.lua
\ No newline at end of file diff --git a/ftplugin/scala.lua b/ftplugin/scala.lua new file mode 100644 index 00000000..169e36ad --- /dev/null +++ b/ftplugin/scala.lua @@ -0,0 +1 @@ +require("lsp").setup "scala" diff --git a/ftplugin/sh.lua b/ftplugin/sh.lua index 54002f19..4f18fbca 100644 --- a/ftplugin/sh.lua +++ b/ftplugin/sh.lua @@ -1,52 +1 @@ -O.formatters.filetype["sh"] = { -  function() -    return { -      exe = O.lang.sh.formatter.exe, -      args = O.lang.sh.formatter.args, -      stdin = not (O.lang.sh.formatter.stdin ~= nil), -    } -  end, -} - -require("formatter.config").set_defaults { -  logging = false, -  filetype = O.formatters.filetype, -} -if not require("lv-utils").check_lsp_client_active "bashls" then -  -- npm i -g bash-language-server -  require("lspconfig").bashls.setup { -    cmd = { DATA_PATH .. "/lspinstall/bash/node_modules/.bin/bash-language-server", "start" }, -    on_attach = require("lsp").common_on_attach, -    filetypes = { "sh", "zsh" }, -  } -end - --- sh -local sh_arguments = {} - -local shfmt = { formatCommand = "shfmt -ci -s -bn", formatStdin = true } - -local shellcheck = { -  LintCommand = "shellcheck -f gcc -x", -  lintFormats = { "%f:%l:%c: %trror: %m", "%f:%l:%c: %tarning: %m", "%f:%l:%c: %tote: %m" }, -} - -if O.lang.sh.linter == "shellcheck" then -  table.insert(sh_arguments, shellcheck) -end - -if not require("lv-utils").check_lsp_client_active "efm" then -  require("lspconfig").efm.setup { -    -- init_options = {initializationOptions}, -    cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" }, -    init_options = { documentFormatting = true, codeAction = false }, -    root_dir = require("lspconfig").util.root_pattern ".git/", -    filetypes = { "sh" }, -    settings = { -      rootMarkers = { ".git/" }, -      languages = { -        sh = sh_arguments, -      }, -    }, -  } -end +require("lsp").setup "sh" diff --git a/ftplugin/svelte.lua b/ftplugin/svelte.lua new file mode 100644 index 00000000..175a5cbd --- /dev/null +++ b/ftplugin/svelte.lua @@ -0,0 +1 @@ +require("lsp").setup "svelte" diff --git a/ftplugin/swift.lua b/ftplugin/swift.lua new file mode 100644 index 00000000..1ae7554a --- /dev/null +++ b/ftplugin/swift.lua @@ -0,0 +1 @@ +require("lsp").setup "swift" diff --git a/ftplugin/tex.lua b/ftplugin/tex.lua index c5748189..e9a98ec5 100644 --- a/ftplugin/tex.lua +++ b/ftplugin/tex.lua @@ -1,38 +1 @@ -if require("lv-utils").check_lsp_client_active "texlab" then -  return -end - -require("lspconfig").texlab.setup { -  cmd = { DATA_PATH .. "/lspinstall/latex/texlab" }, -  on_attach = require("lsp").common_on_attach, -} - -vim.g.vimtex_compiler_method = "latexmk" -vim.g.vimtex_view_method = "zathura" -vim.g.vimtex_fold_enabled = 0 -vim.g.vimtex_quickfix_ignore_filters = O.lang.latex.ignore_errors - -O.plugin.which_key.mappings["L"] = { -  name = "+Latex", -  c = { "<cmd>VimtexCompile<cr>", "Toggle Compilation Mode" }, -  f = { "<cmd>call vimtex#fzf#run()<cr>", "Fzf Find" }, -  i = { "<cmd>VimtexInfo<cr>", "Project Information" }, -  s = { "<cmd>VimtexStop<cr>", "Stop Project Compilation" }, -  t = { "<cmd>VimtexTocToggle<cr>", "Toggle Table Of Content" }, -  v = { "<cmd>VimtexView<cr>", "View PDF" }, -} - --- Compile on initialization, cleanup on quit -vim.api.nvim_exec( -  [[ -        augroup vimtex_event_1 -            au! -            au User VimtexEventQuit     call vimtex#compiler#clean(0) -            au User VimtexEventInitPost call vimtex#compiler#compile() -        augroup END -    ]], -  false -) -if O.lang.latex.auto_save then -  vim.api.nvim_exec([[au FocusLost * :wa]], false) -end +require("lsp").setup "tex" diff --git a/ftplugin/tf.lua b/ftplugin/tf.lua index a328f7c2..3486663d 100644 --- a/ftplugin/tf.lua +++ b/ftplugin/tf.lua @@ -1,25 +1 @@ -O.formatters.filetype["hcl"] = { -  function() -    return { -      exe = O.lang.terraform.formatter.exe, -      args = O.lang.terraform.formatter.args, -      stdin = not (O.lang.terraform.formatter.stdin ~= nil), -    } -  end, -} -O.formatters.filetype["tf"] = O.formatters.filetype["hcl"] - -require("formatter.config").set_defaults { -  logging = false, -  filetype = O.formatters.filetype, -} - -if require("lv-utils").check_lsp_client_active "terraformls" then -  return -end - -require("lspconfig").terraformls.setup { -  cmd = { DATA_PATH .. "/lspinstall/terraform/terraform-ls", "serve" }, -  on_attach = require("lsp").common_on_attach, -  filetypes = { "tf", "terraform", "hcl" }, -} +require("lsp").setup "terraform" diff --git a/ftplugin/thing.pp b/ftplugin/thing.pp new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ftplugin/thing.pp diff --git a/ftplugin/typescript.lua b/ftplugin/typescript.lua index f74b54e9..2f6219df 100644 --- a/ftplugin/typescript.lua +++ b/ftplugin/typescript.lua @@ -1,3 +1 @@ -require "lsp.tsserver-ls" - -vim.cmd "setl ts=2 sw=2" +require("lsp").setup "typescript" diff --git a/ftplugin/typescriptreact.lua b/ftplugin/typescriptreact.lua index f74b54e9..2f6219df 100644 --- a/ftplugin/typescriptreact.lua +++ b/ftplugin/typescriptreact.lua @@ -1,3 +1 @@ -require "lsp.tsserver-ls" - -vim.cmd "setl ts=2 sw=2" +require("lsp").setup "typescript" diff --git a/ftplugin/vim.lua b/ftplugin/vim.lua index 4a405698..88c00c1c 100644 --- a/ftplugin/vim.lua +++ b/ftplugin/vim.lua @@ -1,9 +1 @@ -if require("lv-utils").check_lsp_client_active "vimls" then -  return -end - --- npm install -g vim-language-server -require("lspconfig").vimls.setup { -  cmd = { DATA_PATH .. "/lspinstall/vim/node_modules/.bin/vim-language-server", "--stdio" }, -  on_attach = require("lsp").common_on_attach, -} +require("lsp").setup "vim" diff --git a/ftplugin/vue.lua b/ftplugin/vue.lua index 96048164..a174c9bf 100644 --- a/ftplugin/vue.lua +++ b/ftplugin/vue.lua @@ -1,10 +1 @@ -if require("lv-utils").check_lsp_client_active "vuels" then -  return -end - --- Vue language server configuration (vetur) -require("lspconfig").vuels.setup { -  cmd = { DATA_PATH .. "/lspinstall/vue/node_modules/.bin/vls", "--stdio" }, -  on_attach = require("lsp").common_on_attach, -  root_dir = require("lspconfig").util.root_pattern(".git", "vue.config.js", "package.json", "yarn.lock"), -} +require("lsp").setup "vue" diff --git a/ftplugin/yaml.lua b/ftplugin/yaml.lua index f1dfc5dc..d21f9785 100644 --- a/ftplugin/yaml.lua +++ b/ftplugin/yaml.lua @@ -1,24 +1 @@ -O.formatters.filetype["yaml"] = { -  function() -    return { -      exe = O.lang.yaml.formatter.exe, -      args = O.lang.yaml.formatter.args, -      stdin = not (O.lang.yaml.formatter.stdin ~= nil), -    } -  end, -} - -require("formatter.config").set_defaults { -  logging = false, -  filetype = O.formatters.filetype, -} -if require("lv-utils").check_lsp_client_active "yamlls" then -  return -end - --- npm install -g yaml-language-server -require("lspconfig").yamlls.setup { -  cmd = { DATA_PATH .. "/lspinstall/yaml/node_modules/.bin/yaml-language-server", "--stdio" }, -  on_attach = require("lsp").common_on_attach, -} -vim.cmd "setl ts=2 sw=2 ts=2 ai et" +require("lsp").setup "yaml" diff --git a/ftplugin/zig.lua b/ftplugin/zig.lua index 55707d85..ef3d64d4 100644 --- a/ftplugin/zig.lua +++ b/ftplugin/zig.lua @@ -1,17 +1 @@ -if not require("lv-utils").check_lsp_client_active "zls" then -  -- Because lspinstall don't support zig yet, -  -- So we need zls preset in global lib -  -- Further custom install zls in -  -- https://github.com/zigtools/zls/wiki/Downloading-and-Building-ZLS -  require("lspconfig").zls.setup { -    root_dir = require("lspconfig").util.root_pattern(".git", "build.zig", "zls.json"), -    on_attach = require("lsp").common_on_attach, -  } -end - -require("lv-utils").define_augroups { -  _zig_autoformat = { -    { "BufEnter", "*.zig", ':lua vim.api.nvim_buf_set_option(0, "commentstring", "// %s")' }, -  }, -} -vim.cmd "setl expandtab tabstop=8 softtabstop=4 shiftwidth=4" +require("lsp").setup "zig" diff --git a/ftplugin/zsh.lua b/ftplugin/zsh.lua index 750e8ede..4f18fbca 100644 --- a/ftplugin/zsh.lua +++ b/ftplugin/zsh.lua @@ -1,36 +1 @@ -if not require("lv-utils").check_lsp_client_active "bashls" then -  -- npm i -g bash-language-server -  require("lspconfig").bashls.setup { -    cmd = { DATA_PATH .. "/lspinstall/bash/node_modules/.bin/bash-language-server", "start" }, -    on_attach = require("lsp").common_on_attach, -    filetypes = { "sh", "zsh" }, -  } -end - --- sh -local sh_arguments = {} - -local shellcheck = { -  LintCommand = "shellcheck -f gcc -x", -  lintFormats = { "%f:%l:%c: %trror: %m", "%f:%l:%c: %tarning: %m", "%f:%l:%c: %tote: %m" }, -} - -if O.lang.sh.linter == "shellcheck" then -  table.insert(sh_arguments, shellcheck) -end - -if not require("lv-utils").check_lsp_client_active "efm" then -  require("lspconfig").efm.setup { -    -- init_options = {initializationOptions}, -    cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" }, -    init_options = { documentFormatting = true, codeAction = false }, -    root_dir = require("lspconfig").util.root_pattern ".git/", -    filetypes = { "zsh" }, -    settings = { -      rootMarkers = { ".git/" }, -      languages = { -        sh = sh_arguments, -      }, -    }, -  } -end +require("lsp").setup "sh" @@ -1,18 +1,58 @@ +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 +  set runtimepath^=~/.local/share/lunarvim/lvim/after +]] +-- vim.opt.rtp:append() instead of vim.cmd ?  require "default-config" -require "keymappings" -local status_ok, _ = pcall(vim.cmd, "luafile " .. CONFIG_PATH .. "/lv-config.lua") +require("settings").load_options() +local status_ok, error = pcall(vim.cmd, "luafile ~/.config/lvim/lv-config.lua")  if not status_ok then    print "something is wrong with your lv-config" +  print(error) +end +require("settings").load_commands() +require("core.autocmds").define_augroups(lvim.autocommands) + +require "keymappings" +require("lsp").setup_default_bindings() + +local plugins = require "plugins" +local plugin_loader = require("plugin-loader").init() +plugin_loader:load { plugins, lvim.plugins } +vim.g.colors_name = lvim.colorscheme -- Colorscheme must get called after plugins are loaded or it will break new installs. +vim.cmd("colorscheme " .. lvim.colorscheme) + +local utils = require "utils" +utils.toggle_autoformat() +local commands = require "core.commands" +commands.load(commands.defaults) + +require("lsp").setup_handlers() + +local null_status_ok, null_ls = pcall(require, "null-ls") +if null_status_ok then +  null_ls.config {} +  require("lspconfig")["null-ls"].setup {} +end + +local lsp_settings_status_ok, lsp_settings = pcall(require, "nlspsettings") +if lsp_settings_status_ok then +  lsp_settings.setup { +    config_home = os.getenv "HOME" .. "/.config/lvim/lsp-settings", +  }  end -require "plugins" -vim.g.colors_name = O.colorscheme -- Colorscheme must get called after plugins are loaded or it will break new installs. -require "settings" -require "lv-utils"  -- TODO: these guys need to be in language files --- require "lsp" --- if O.lang.emmet.active then +-- if lvim.lang.emmet.active then  --   require "lsp.emmet-ls"  -- end --- if O.lang.tailwindcss.active then +-- if lvim.lang.tailwindcss.active then  --   require "lsp.tailwind diff --git a/lua/lv-utils/init.lua b/lua/core/autocmds.lua index d2d23cfb..9280da9e 100644 --- a/lua/lv-utils/init.lua +++ b/lua/core/autocmds.lua @@ -1,54 +1,6 @@ -local lv_utils = {} - -function lv_utils.reload_lv_config() -  vim.cmd "source ~/.config/nvim/lv-config.lua" -  vim.cmd "source ~/.config/nvim/lua/plugins.lua" -  vim.cmd "source ~/.config/nvim/lua/settings.lua" -  vim.cmd "source ~/.config/nvim/lua/core/formatter.lua" -  vim.cmd ":PackerCompile" -  vim.cmd ":PackerInstall" -  -- vim.cmd ":PackerClean" -end - -function lv_utils.check_lsp_client_active(name) -  local clients = vim.lsp.get_active_clients() -  for _, client in pairs(clients) do -    if client.name == name then -      return true -    end -  end -  return false -end - -function lv_utils.define_augroups(definitions) -- {{{1 -  -- Create autocommand groups based on the passed definitions -  -- -  -- The key will be the name of the group, and each definition -  -- within the group should have: -  --    1. Trigger -  --    2. Pattern -  --    3. Text -  -- just like how they would normally be defined from Vim itself -  for group_name, definition in pairs(definitions) do -    vim.cmd("augroup " .. group_name) -    vim.cmd "autocmd!" - -    for _, def in pairs(definition) do -      local command = table.concat(vim.tbl_flatten { "autocmd", def }, " ") -      vim.cmd(command) -    end - -    vim.cmd "augroup END" -  end -end - -function lv_utils.unrequire(m) -  package.loaded[m] = nil -  _G[m] = nil -end - -lv_utils.define_augroups { +local autocommands = {} +lvim.autocommands = {    _general_settings = {      {        "TextYankPost", @@ -75,13 +27,21 @@ lv_utils.define_augroups {        "*",        "setlocal formatoptions-=c formatoptions-=r formatoptions-=o",      }, -    { "BufWritePost", "lv-config.lua", "lua require('lv-utils').reload_lv_config()" }, +    { "BufWritePost", "lv-config.lua", "lua require('utils').reload_lv_config()" }, +    { +      "FileType", +      "qf", +      "set nobuflisted", +    },      -- { "VimLeavePre", "*", "set title set titleold=" },    }, -  _solidity = { +  _filetypechanges = {      { "BufWinEnter", ".tf", "setlocal filetype=hcl" },      { "BufRead", "*.tf", "setlocal filetype=hcl" },      { "BufNewFile", "*.tf", "setlocal filetype=hcl" }, +    { "BufWinEnter", ".zsh", "setlocal filetype=sh" }, +    { "BufRead", "*.zsh", "setlocal filetype=sh" }, +    { "BufNewFile", "*.zsh", "setlocal filetype=sh" },    },    -- _solidity = {    --     {'BufWinEnter', '.sol', 'setlocal filetype=solidity'}, {'BufRead', '*.sol', 'setlocal filetype=solidity'}, @@ -95,6 +55,9 @@ lv_utils.define_augroups {      { "FileType", "markdown", "setlocal wrap" },      { "FileType", "markdown", "setlocal spell" },    }, +  _tab_bindings = { +    { "FileType", "*", "lua require'core.compe'.set_tab_keybindings()" }, +  },    _buffer_bindings = {      { "FileType", "floaterm", "nnoremap <silent> <buffer> q :q<CR>" },    }, @@ -118,19 +81,29 @@ lv_utils.define_augroups {    --   {'InsertEnter', '*', 'if &cursorline | let g:ms_cursorlineoff = 1 | setlocal nocursorline | endif'},    --   {'InsertLeave', '*', 'if exists("g:ms_cursorlineoff") | setlocal cursorline | endif'},    -- }, -  _user_autocommands = O.user_autocommands, +  custom_groups = {},  } -vim.cmd [[ -  function! QuickFixToggle() -    if empty(filter(getwininfo(), 'v:val.quickfix')) -      copen -    else -      cclose -    endif -endfunction -]] +function autocommands.define_augroups(definitions) -- {{{1 +  -- Create autocommand groups based on the passed definitions +  -- +  -- The key will be the name of the group, and each definition +  -- within the group should have: +  --    1. Trigger +  --    2. Pattern +  --    3. Text +  -- just like how they would normally be defined from Vim itself +  for group_name, definition in pairs(definitions) do +    vim.cmd("augroup " .. group_name) +    vim.cmd "autocmd!" + +    for _, def in pairs(definition) do +      local command = table.concat(vim.tbl_flatten { "autocmd", def }, " ") +      vim.cmd(command) +    end -return lv_utils +    vim.cmd "augroup END" +  end +end --- TODO: find a new home for these autocommands +return autocommands diff --git a/lua/core/autopairs.lua b/lua/core/autopairs.lua index b8dad5f3..f0111db6 100644 --- a/lua/core/autopairs.lua +++ b/lua/core/autopairs.lua @@ -1,7 +1,7 @@  -- if not package.loaded['nvim-autopairs'] then  --   return  -- end -local status_ok, autopairs = pcall(require, "nvim-autopairs") +local status_ok, _ = pcall(require, "nvim-autopairs")  if not status_ok then    return  end diff --git a/lua/core/bufferline.lua b/lua/core/bufferline.lua index d4e4b4fe..c5677580 100644 --- a/lua/core/bufferline.lua +++ b/lua/core/bufferline.lua @@ -1,28 +1,2 @@ -vim.api.nvim_set_keymap("n", "<S-x>", ":BufferClose<CR>", { noremap = true, silent = true })  vim.api.nvim_set_keymap("n", "<S-l>", ":BufferNext<CR>", { noremap = true, silent = true })  vim.api.nvim_set_keymap("n", "<S-h>", ":BufferPrevious<CR>", { noremap = true, silent = true }) -vim.api.nvim_set_keymap("n", "<leader>c", ":BufferClose<CR>", { noremap = true, silent = true }) - -O.plugin.which_key.mappings["b"] = { -  name = "Buffers", -  j = { "<cmd>BufferPick<cr>", "jump to buffer" }, -  f = { "<cmd>Telescope buffers<cr>", "Find buffer" }, -  w = { "<cmd>BufferWipeout<cr>", "wipeout buffer" }, -  e = { -    "<cmd>BufferCloseAllButCurrent<cr>", -    "close all but current buffer", -  }, -  h = { "<cmd>BufferCloseBuffersLeft<cr>", "close all buffers to the left" }, -  l = { -    "<cmd>BufferCloseBuffersRight<cr>", -    "close all BufferLines to the right", -  }, -  D = { -    "<cmd>BufferOrderByDirectory<cr>", -    "sort BufferLines automatically by directory", -  }, -  L = { -    "<cmd>BufferOrderByLanguage<cr>", -    "sort BufferLines automatically by language", -  }, -} diff --git a/lua/core/commands.lua b/lua/core/commands.lua new file mode 100644 index 00000000..c42b385d --- /dev/null +++ b/lua/core/commands.lua @@ -0,0 +1,21 @@ +local M = {} + +M.defaults = { +  [[ +  function! QuickFixToggle() +    if empty(filter(getwininfo(), 'v:val.quickfix')) +      copen +    else +      cclose +    endif +  endfunction +  ]], +} + +M.load = function(commands) +  for _, command in ipairs(commands) do +    vim.cmd(command) +  end +end + +return M diff --git a/lua/core/compe.lua b/lua/core/compe.lua index c8152ad1..801e2dd8 100644 --- a/lua/core/compe.lua +++ b/lua/core/compe.lua @@ -1,6 +1,6 @@  local M = {}  M.config = function() -  O.completion = { +  lvim.builtin.compe = {      enabled = true,      autocomplete = true,      debug = false, @@ -30,18 +30,20 @@ M.config = function()        emoji = { kind = " ﲃ  (Emoji)", filetypes = { "markdown", "text" } },        -- for emoji press : (idk if that in compe tho)      }, +    -- FileTypes in this list won't trigger auto-complete when TAB is pressed.  Hitting TAB will insert a tab character +    exclude_filetypes = { "md", "markdown", "mdown", "mkd", "mkdn", "mdwn", "text", "txt" },    }  end  M.setup = function() -  vim.g.vsnip_snippet_dir = O.vsnip_dir +  vim.g.vsnip_snippet_dir = lvim.vsnip_dir    local status_ok, compe = pcall(require, "compe")    if not status_ok then      return    end -  compe.setup(O.completion) +  compe.setup(lvim.builtin.compe)    local t = function(str)      return vim.api.nvim_replace_termcodes(str, true, true, true) @@ -81,16 +83,29 @@ M.setup = function()      end    end -  vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", { expr = true }) -  vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", { expr = true }) -  vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", { expr = true }) -  vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", { expr = true }) -    vim.api.nvim_set_keymap("i", "<C-Space>", "compe#complete()", { noremap = true, silent = true, expr = true }) -  vim.api.nvim_set_keymap("i", "<CR>", "compe#confirm('<CR>')", { noremap = true, silent = true, expr = true }) +  -- vim.api.nvim_set_keymap("i", "<CR>", "compe#confirm('<CR>')", { noremap = true, silent = true, expr = true })    vim.api.nvim_set_keymap("i", "<C-e>", "compe#close('<C-e>')", { noremap = true, silent = true, expr = true })    vim.api.nvim_set_keymap("i", "<C-f>", "compe#scroll({ 'delta': +4 })", { noremap = true, silent = true, expr = true })    vim.api.nvim_set_keymap("i", "<C-d>", "compe#scroll({ 'delta': -4 })", { noremap = true, silent = true, expr = true })  end +local is_excluded = function(file_type) +  for _, type in ipairs(lvim.builtin.compe.exclude_filetypes) do +    if type == file_type then +      return true +    end +  end +  return false +end + +M.set_tab_keybindings = function() +  local file_type = vim.fn.expand "%:e" +  if is_excluded(file_type) == false then +    vim.api.nvim_buf_set_keymap(0, "i", "<Tab>", "v:lua.tab_complete()", { expr = true }) +    vim.api.nvim_buf_set_keymap(0, "s", "<Tab>", "v:lua.tab_complete()", { expr = true }) +    vim.api.nvim_buf_set_keymap(0, "i", "<S-Tab>", "v:lua.s_tab_complete()", { expr = true }) +    vim.api.nvim_buf_set_keymap(0, "s", "<S-Tab>", "v:lua.s_tab_complete()", { expr = true }) +  end +end  return M diff --git a/lua/core/dap.lua b/lua/core/dap.lua index bc76e221..30e3aef9 100644 --- a/lua/core/dap.lua +++ b/lua/core/dap.lua @@ -1,6 +1,6 @@  local M = {}  M.config = function() -  O.plugin.dap = { +  lvim.builtin.dap = {      active = false,      breakpoint = {        text = "", @@ -17,10 +17,10 @@ M.setup = function()      return    end -  vim.fn.sign_define("DapBreakpoint", O.plugin.dap.breakpoint) +  vim.fn.sign_define("DapBreakpoint", lvim.builtin.dap.breakpoint)    dap.defaults.fallback.terminal_win_cmd = "50vsplit new" -  O.user_which_key["d"] = { +  lvim.builtin.which_key.mappings["d"] = {      name = "Debug",      t = { "<cmd>lua require'dap'.toggle_breakpoint()<cr>", "Toggle Breakpoint" },      b = { "<cmd>lua require'dap'.step_back()<cr>", "Step Back" }, @@ -38,4 +38,21 @@ M.setup = function()    }  end +-- TODO put this up there ^^^ call in ftplugin + +-- M.dap = function() +--   if lvim.plugin.dap.active then +--     local dap_install = require "dap-install" +--     dap_install.config("python_dbg", {}) +--   end +-- end +-- +-- M.dap = function() +--   -- gem install readapt ruby-debug-ide +--   if lvim.plugin.dap.active then +--     local dap_install = require "dap-install" +--     dap_install.config("ruby_vsc_dbg", {}) +--   end +-- end +  return M diff --git a/lua/core/dashboard.lua b/lua/core/dashboard.lua index e58b6f06..8d196458 100644 --- a/lua/core/dashboard.lua +++ b/lua/core/dashboard.lua @@ -1,6 +1,6 @@  local M = {}  M.config = function() -  O.plugin.dashboard = { +  lvim.builtin.dashboard = {      active = false,      search_handler = "telescope",      custom_header = { @@ -43,7 +43,8 @@ M.config = function()        },        d = {          description = { "  Settings           " }, -        command = ":e " .. CONFIG_PATH .. "/lv-config.lua", +        -- command = ":e " .. CONFIG_PATH .. "/lv-config.lua", +        command = ":e ~/.config/lvim/lv-config.lua",        },      }, @@ -54,23 +55,25 @@ end  M.setup = function()    vim.g.dashboard_disable_at_vimenter = 0 -  vim.g.dashboard_custom_header = O.plugin.dashboard.custom_header +  vim.g.dashboard_custom_header = lvim.builtin.dashboard.custom_header -  vim.g.dashboard_default_executive = O.plugin.dashboard.search_handler +  vim.g.dashboard_default_executive = lvim.builtin.dashboard.search_handler -  vim.g.dashboard_custom_section = O.plugin.dashboard.custom_section +  vim.g.dashboard_custom_section = lvim.builtin.dashboard.custom_section + +  lvim.builtin.which_key.mappings[";"] = { "<cmd>Dashboard<CR>", "Dashboard" }    -- f = {    --   description = { "  Neovim Config Files" },    --   command = "Telescope find_files cwd=" .. CONFIG_PATH,    -- },    -- e = {description = {'  Marks              '}, command = 'Telescope marks'} -  vim.cmd "let g:dashboard_session_directory = $HOME..'/.config/nvim/.sessions'" -  vim.cmd "let packages = len(globpath('~/.local/share/nvim/site/pack/packer/start', '*', 0, 1))" +  vim.cmd 'let g:dashboard_session_directory = "~/.config/lvim/.sessions"' +  vim.cmd "let packages = len(globpath('~/.local/share/lunarvim/site/pack/packer/start', '*', 0, 1))"    vim.api.nvim_exec(      [[ -    let g:dashboard_custom_footer = ['LuaJIT loaded '..packages..' plugins'] +    let g:dashboard_custom_footer = ['LunarVim loaded '..packages..' plugins ']  ]],      false    ) @@ -78,8 +81,9 @@ M.setup = function()    -- file_browser = {description = {' File Browser'}, command = 'Telescope find_files'},    -- vim.g.dashboard_session_directory = CACHE_PATH..'/session' -  -- vim.g.dashboard_custom_footer = O.dashboard.footer -  require("lv-utils").define_augroups { +  -- vim.g.dashboard_custom_footer = lvim.dashboard.footer + +  require("core.autocmds").define_augroups {      _dashboard = {        -- seems to be nobuflisted that makes my stuff disapear will do more testing        { @@ -90,7 +94,7 @@ M.setup = function()        {          "FileType",          "dashboard", -        "set showtabline=0 | autocmd BufLeave <buffer> set showtabline=2", +        "set showtabline=0 | autocmd BufLeave <buffer> set showtabline=" .. vim.opt.showtabline._value,        },        { "FileType", "dashboard", "nnoremap <silent> <buffer> q :q<CR>" },      }, diff --git a/lua/core/floatterm.lua b/lua/core/floatterm.lua deleted file mode 100644 index 3d7e0e6e..00000000 --- a/lua/core/floatterm.lua +++ /dev/null @@ -1,76 +0,0 @@ -local M = {} -M.config = function() -  O.plugin.floatterm = { -    active = false, -    dimensions = { -      height = 0.9, -      width = 0.9, -      x = 0.5, -      y = 0.3, -    }, -    border = "single", -- or 'double' -  } -end - -M.setup = function() -  local status_ok, fterm = pcall(require, "FTerm") -  if not status_ok then -    return -  end - -  fterm.setup(O.plugin.floatterm) - -  -- Create LazyGit Terminal -  local term = require "FTerm.terminal" -  local lazy = term:new():setup { -    cmd = "lazygit", -    dimensions = O.plugin.floatterm.dimensions, -  } - -  local function is_installed(exe) -    return vim.fn.executable(exe) == 1 -  end - -  -- Use this to toggle gitui in a floating terminal -  function _G.__fterm_lazygit() -    if is_installed "lazygit" ~= true then -      print "Please install lazygit. Check documentation for more information" -      return -    end -    lazy:toggle() -  end - -  -- Map esc to exit inside lazygit -  --   vim.api.nvim_exec( -  --     [[ -  --   function LazyGitNativation() -  --     echom &filetype -  --     if &filetype ==# 'FTerm' -  --       tnoremap <Esc> q -  --       tnoremap <C-v><Esc> <Esc> -  --     endif -  --   endfunction -  --   ]], -  --     false -  --   ) - -  O.plugin.which_key.mappings["gg"] = "LazyGit" -  vim.api.nvim_set_keymap("n", "<A-i>", "<CMD>lua require('FTerm').toggle()<CR>", { noremap = true, silent = true }) -  vim.api.nvim_set_keymap("n", "<leader>gg", "<CMD>lua _G.__fterm_lazygit()<CR>", { noremap = true, silent = true }) - -  vim.api.nvim_set_keymap( -    "t", -    "<A-i>", -    "<C-\\><C-n><CMD>lua require('FTerm').toggle()<CR>", -    { noremap = true, silent = true } -  ) -  vim.api.nvim_set_keymap("n", "<A-l>", "<CMD>lua _G.__fterm_lazygit()<CR>", { noremap = true, silent = true }) -  vim.api.nvim_set_keymap( -    "t", -    "<A-l>", -    "<C-\\><C-n><CMD>lua _G.__fterm_lazygit()<CR>", -    { noremap = true, silent = true } -  ) -end - -return M diff --git a/lua/core/formatter.lua b/lua/core/formatter.lua deleted file mode 100644 index 05de74ab..00000000 --- a/lua/core/formatter.lua +++ /dev/null @@ -1,60 +0,0 @@ --- autoformat -if O.format_on_save then -  require("lv-utils").define_augroups { -    autoformat = { -      { -        "BufWritePost", -        "*", -        ":silent FormatWrite", -      }, -    }, -  } -end - --- -- check if formatter has been defined for the language or not --- local function formatter_exists(lang_formatter) ---   if lang_formatter == nil then ---     return false ---   end ---   if lang_formatter.exe == nil or lang_formatter.args == nil then ---     return false ---   end ---   return true --- end - --- returns default formatter for given language --- local function formatter_return(lang_formatter) ---   return { ---     exe = lang_formatter.exe, ---     args = lang_formatter.args, ---     stdin = not (lang_formatter.stdin ~= nil), ---   } --- end - --- fill a table like this -> {rust: {exe:"sth",args:{"a","b"},stdin=true},go: {}...} --- local formatter_filetypes = {} --- for k, v in pairs(O.lang) do ---   if formatter_exists(v.formatter) then ---     local keys = v.filetypes ---     if keys == nil then ---       keys = { k } ---     end ---     for _, l in pairs(keys) do ---       formatter_filetypes[l] = { ---         function() ---           return formatter_return(v.formatter) ---         end, ---       } ---     end ---   end --- end -local status_ok, formatter = pcall(require, "formatter") -if not status_ok then -  return -end - -if not O.format_on_save then -  vim.cmd [[if exists('#autoformat#BufWritePost') -	:autocmd! autoformat -	endif]] -end diff --git a/lua/core/galaxyline.lua b/lua/core/galaxyline.lua index 281202a8..abc7c369 100644 --- a/lua/core/galaxyline.lua +++ b/lua/core/galaxyline.lua @@ -7,9 +7,9 @@ if not status_ok then  end  -- NOTE: if someone defines colors but doesn't have them then this will break -local palette_status_ok, colors = pcall(require, O.colorscheme .. ".palette") +local palette_status_ok, colors = pcall(require, lvim.colorscheme .. ".palette")  if not palette_status_ok then -  colors = O.plugin.galaxyline.colors +  colors = lvim.builtin.galaxyline.colors  end  local condition = require "galaxyline.condition" @@ -266,7 +266,11 @@ table.insert(gls.right, {  table.insert(gls.right, {    Tabstop = {      provider = function() -      return "Spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth") .. " " +      local label = "Spaces: " +      if not vim.api.nvim_buf_get_option(0, "expandtab") then +        label = "Tab size: " +      end +      return label .. vim.api.nvim_buf_get_option(0, "shiftwidth") .. " "      end,      condition = condition.hide_in_width,      separator = " ", @@ -311,7 +315,7 @@ table.insert(gls.short_line_left, {      provider = "FileTypeName",      separator = " ",      separator_highlight = { "NONE", colors.alt_bg }, -    highlight = { colors.grey, colors.alt_bg }, +    highlight = { colors.alt_bg, colors.alt_bg },    },  }) @@ -319,7 +323,7 @@ table.insert(gls.short_line_left, {    SFileName = {      provider = "SFileName",      condition = condition.buffer_not_empty, -    highlight = { colors.grey, colors.alt_bg }, +    highlight = { colors.alt_bg, colors.alt_bg },    },  }) diff --git a/lua/core/gitsigns.lua b/lua/core/gitsigns.lua index bc310ad6..2a5060be 100644 --- a/lua/core/gitsigns.lua +++ b/lua/core/gitsigns.lua @@ -1,6 +1,6 @@  local M = {}  M.config = function() -  O.plugin.gitsigns = { +  lvim.builtin.gitsigns = {      signs = {        add = {          hl = "GitSignsAdd", @@ -53,7 +53,7 @@ M.setup = function()    if not status_ok then      return    end -  gitsigns.setup(O.plugin.gitsigns) +  gitsigns.setup(lvim.builtin.gitsigns)  end  return M diff --git a/lua/core/nvimtree.lua b/lua/core/nvimtree.lua index cb3eacea..dd1f4f36 100644 --- a/lua/core/nvimtree.lua +++ b/lua/core/nvimtree.lua @@ -1,86 +1,87 @@ --- --if not package.loaded['nvim-tree.view'] then --- --  return --- --end ---  local M = {} -local status_ok, nvim_tree_config = pcall(require, "nvim-tree.config") -if not status_ok then -  return +-- +M.config = function() +  lvim.builtin.nvimtree = { +    side = "left", +    show_icons = { +      git = 1, +      folders = 1, +      files = 1, +      folder_arrows = 1, +      tree_width = 30, +    }, +    ignore = { ".git", "node_modules", ".cache" }, +    auto_open = 1, +    auto_close = 1, +    quit_on_open = 0, +    follow = 1, +    hide_dotfiles = 1, +    git_hl = 1, +    root_folder_modifier = ":t", +    tab_open = 0, +    allow_resize = 1, +    lsp_diagnostics = 1, +    auto_ignore_ft = { "startify", "dashboard" }, +    icons = { +      default = "", +      symlink = "", +      git = { +        unstaged = "", +        staged = "S", +        unmerged = "", +        renamed = "➜", +        deleted = "", +        untracked = "U", +        ignored = "◌", +      }, +      folder = { +        default = "", +        open = "", +        empty = "", +        empty_open = "", +        symlink = "", +      }, +    }, +  }  end  --  M.setup = function() +  local status_ok, nvim_tree_config = pcall(require, "nvim-tree.config") +  if not status_ok then +    return +  end    local g = vim.g -  vim.o.termguicolors = true - -  g.nvim_tree_side = "left" -  g.nvim_tree_width = 30 -  g.nvim_tree_ignore = { ".git", "node_modules", ".cache" } -  g.nvim_tree_auto_open = 1 -  g.nvim_tree_auto_close = 1 -  g.nvim_tree_quit_on_open = 0 -  g.nvim_tree_follow = 1 -  g.nvim_tree_indent_markers = 1 -  g.nvim_tree_hide_dotfiles = 1 -  g.nvim_tree_git_hl = 1 -  g.nvim_tree_root_folder_modifier = ":t" -  g.nvim_tree_tab_open = 0 -  g.nvim_tree_allow_resize = 1 -  g.nvim_tree_lsp_diagnostics = 1 -  g.nvim_tree_auto_ignore_ft = { "startify", "dashboard" } - -  g.nvim_tree_show_icons = { -    git = 1, -    folders = 1, -    files = 1, -    folder_arrows = 1, -  } +  for opt, val in pairs(lvim.builtin.nvimtree) do +    g["nvim_tree_" .. opt] = val +  end -  vim.g.nvim_tree_icons = { -    default = "", -    symlink = "", -    git = { -      unstaged = "", -      staged = "S", -      unmerged = "", -      renamed = "➜", -      deleted = "", -      untracked = "U", -      ignored = "◌", -    }, -    folder = { -      default = "", -      open = "", -      empty = "", -      empty_open = "", -      symlink = "", -    }, -  }    local tree_cb = nvim_tree_config.nvim_tree_callback -  vim.g.nvim_tree_bindings = { +  g.nvim_tree_bindings = {      { key = { "l", "<CR>", "o" }, cb = tree_cb "edit" },      { key = "h", cb = tree_cb "close_node" },      { key = "v", cb = tree_cb "vsplit" },    }  end - -local view_status_ok, view = pcall(require, "nvim-tree.view") -if not view_status_ok then -  return -end +-- +--  M.toggle_tree = function() +  local view_status_ok, view = pcall(require, "nvim-tree.view") +  if not view_status_ok then +    return +  end    if view.win_open() then      require("nvim-tree").close()      if package.loaded["bufferline.state"] then        require("bufferline.state").set_offset(0)      end    else -    if package.loaded["bufferline.state"] then +    if package.loaded["bufferline.state"] and lvim.builtin.nvimtree.side == "left" then        -- require'bufferline.state'.set_offset(31, 'File Explorer')        require("bufferline.state").set_offset(31, "")      end -    require("nvim-tree").find_file(true) +    require("nvim-tree").toggle()    end  end  -- diff --git a/lua/core/status_colors.lua b/lua/core/status_colors.lua index ddb4aa98..37e9d7c9 100644 --- a/lua/core/status_colors.lua +++ b/lua/core/status_colors.lua @@ -1,4 +1,4 @@ -O.plugin.galaxyline = { +lvim.builtin.galaxyline = {    active = true,    colors = {      alt_bg = "#2E2E2E", diff --git a/lua/core/telescope.lua b/lua/core/telescope.lua index 5a067d67..65760d6c 100644 --- a/lua/core/telescope.lua +++ b/lua/core/telescope.lua @@ -5,17 +5,9 @@ M.config = function()      return    end -  O.plugin.telescope = { +  lvim.builtin.telescope = {      active = false,      defaults = { -      find_command = { -        "rg", -        "--no-heading", -        "--with-filename", -        "--line-number", -        "--column", -        "--smart-case", -      },        prompt_prefix = " ",        selection_caret = " ",        entry_prefix = "  ", @@ -33,7 +25,7 @@ M.config = function()        file_sorter = require("telescope.sorters").get_fzy_sorter,        file_ignore_patterns = {},        generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, -      path_display = { "shorten" }, +      path_display = { shorten = 5 },        winblend = 0,        border = {},        borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, @@ -89,8 +81,7 @@ M.setup = function()    if not status_ok then      return    end -  telescope.setup(O.plugin.telescope) -  vim.api.nvim_set_keymap("n", "<Leader>f", ":Telescope find_files<CR>", { noremap = true, silent = true }) +  telescope.setup(lvim.builtin.telescope)  end  return M diff --git a/lua/core/terminal.lua b/lua/core/terminal.lua new file mode 100644 index 00000000..015341df --- /dev/null +++ b/lua/core/terminal.lua @@ -0,0 +1,91 @@ +local M = {} +M.config = function() +  lvim.builtin["terminal"] = { +    -- size can be a number or function which is passed the current terminal +    size = 5, +    -- open_mapping = [[<c-\>]], +    open_mapping = [[<c-t>]], +    hide_numbers = true, -- hide the number column in toggleterm buffers +    shade_filetypes = {}, +    shade_terminals = true, +    shading_factor = 2, -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light +    start_in_insert = true, +    insert_mappings = true, -- whether or not the open mapping applies in insert mode +    persist_size = true, +    -- direction = 'vertical' | 'horizontal' | 'window' | 'float', +    direction = "float", +    close_on_exit = true, -- close the terminal window when the process exits +    shell = vim.o.shell, -- change the default shell +    -- This field is only relevant if direction is set to 'float' +    float_opts = { +      -- The border key is *almost* the same as 'nvim_win_open' +      -- see :h nvim_win_open for details on borders however +      -- the 'curved' border is a custom border type +      -- not natively supported but implemented in this plugin. +      -- border = 'single' | 'double' | 'shadow' | 'curved' | ... other options supported by win open +      border = "curved", +      -- width = <value>, +      -- height = <value>, +      winblend = 0, +      highlights = { +        border = "Normal", +        background = "Normal", +      }, +    }, +    -- Add executables on the lv-config file +    -- { exec, keymap, name} +    -- lvim.builtin.terminal.execs = {{}} to overwrite +    -- lvim.builtin.terminal.execs[#lvim.builtin.terminal.execs+1] = {"gdb", "tg", "GNU Debugger"} +    execs = { { "lazygit", "gg", "LazyGit" } }, +  } +end + +M.setup = function() +  local status_ok, terminal = pcall(require, "toggleterm") +  if not status_ok then +    print(terminal) +    return +  end +  for _, exec in pairs(lvim.builtin.terminal.execs) do +    require("core.terminal").add_exec(exec[1], exec[2], exec[3]) +  end +  terminal.setup(lvim.builtin.terminal) +end + +local function is_installed(exe) +  return vim.fn.executable(exe) == 1 +end + +M.add_exec = function(exec, keymap, name) +  vim.api.nvim_set_keymap( +    "n", +    "<leader>" .. keymap, +    "<cmd>lua require('core.terminal')._exec_toggle('" .. exec .. "')<CR>", +    { noremap = true, silent = true } +  ) +  lvim.builtin.which_key.mappings[keymap] = name +end + +M._split = function(inputstr, sep) +  if sep == nil then +    sep = "%s" +  end +  local t = {} +  for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do +    table.insert(t, str) +  end +  return t +end + +M._exec_toggle = function(exec) +  local binary = M._split(exec)[1] +  if is_installed(binary) ~= true then +    print("Please install executable " .. binary .. ". Check documentation for more information") +    return +  end +  local Terminal = require("toggleterm.terminal").Terminal +  local exec_term = Terminal:new { cmd = exec, hidden = true } +  exec_term:toggle() +end + +return M diff --git a/lua/core/treesitter.lua b/lua/core/treesitter.lua index 2b7a2d54..cfc58bb7 100644 --- a/lua/core/treesitter.lua +++ b/lua/core/treesitter.lua @@ -1,6 +1,6 @@  local M = {}  M.config = function() -  O.treesitter = { +  lvim.builtin.treesitter = {      ensure_installed = {}, -- one of "all", "maintained" (parsers with maintainers), or a list of languages      ignore_install = {},      matchup = { @@ -18,7 +18,7 @@ M.config = function()      },      -- indent = {enable = true, disable = {"python", "html", "javascript"}},      -- TODO seems to be broken -    indent = { enable = { "javascriptreact" } }, +    indent = { enable = true, disable = { "yaml" } },      autotag = { enable = false },      textobjects = {        swap = { @@ -59,129 +59,15 @@ M.config = function()        max_file_lines = 1000, -- Do not enable for files with more than 1000 lines, int      },    } - -  -- -- TODO refactor treesitter -  -- -- @usage pass a table with your desired languages -  -- treesitter = { -  --   ensure_installed = "all", -  --   ignore_install = { "haskell" }, -  --   highlight = { enabled = true }, -  --   -- The below are for treesitter-textobjects plugin -  --   textobj_prefixes = { -  --     goto_next = "]", -- Go to next -  --     goto_previous = "[", -- Go to previous -  --     inner = "i", -- Select inside -  --     outer = "a", -- Selct around -  --     swap = "<leader>a", -- Swap with next -  --   }, -  --   textobj_suffixes = { -  --     -- Start and End respectively for the goto keys -  --     -- for other keys it only uses the first -  --     ["function"] = { "f", "F" }, -  --     ["class"] = { "m", "M" }, -  --     ["parameter"] = { "a", "A" }, -  --     ["block"] = { "k", "K" }, -  --     ["conditional"] = { "i", "I" }, -  --     ["call"] = { "c", "C" }, -  --     ["loop"] = { "l", "L" }, -  --     ["statement"] = { "s", "S" }, -  --     ["comment"] = { "/", "?" }, -  --   }, -  --   -- The below is for treesitter hint textobjects plugin -  --   hint_labels = { "h", "j", "f", "d", "n", "v", "s", "l", "a" }, -  -- },  end  M.setup = function() -  -- TODO: refacor this whole file and treesitter in general -  -- if not package.loaded['nvim-treesitter'] then return end -  -- -  -- Custom parsers -  -- local parser_config = require("nvim-treesitter.parsers").get_parser_configs() -  -- parser_config.make = { -  --     install_info = { -  --         url = "https://github.com/alemuller/tree-sitter-make", -- local path or git repo -  --         files = {"src/parser.c"}, -  --         requires_generate_from_grammar = true -  --     } -  -- } -  -- parser_config.just = { -  --     install_info = { -  --         url = "~/dev/tree-sitter-just", -- local path or git repo -  --         files = {"src/parser.c"} -  --     } -  --     -- filetype = "just", -- if filetype does not agrees with parser name -  --     -- used_by = {"bar", "baz"} -- additional filetypes that use this parser -  -- } -  -- Custom text objects -  -- local textobj_prefixes = O.treesitter.textobj_prefixes -  -- local textobj_suffixes = O.treesitter.textobj_suffixes -  -- local textobj_sel_keymaps = {} -  -- local textobj_swap_keymaps = {} -  -- local textobj_move_keymaps = { -  --   enable = O.plugin.ts_textobjects, -  --   set_jumps = true, -- whether to set jumps in the jumplist -  --   goto_next_start = {}, -  --   goto_next_end = {}, -  --   goto_previous_start = {}, -  --   goto_previous_end = {}, -  -- } -  -- for obj, suffix in pairs(textobj_suffixes) do -  --   if textobj_prefixes["goto_next"] ~= nil then -  --     textobj_move_keymaps["goto_next_start"][textobj_prefixes["goto_next"] .. suffix[1]] = "@" .. obj .. ".outer" -  --     textobj_move_keymaps["goto_next_end"][textobj_prefixes["goto_next"] .. suffix[2]] = "@" .. obj .. ".outer" -  --   end -  --   if textobj_prefixes["goto_previous"] ~= nil then -  --     textobj_move_keymaps["goto_previous_start"][textobj_prefixes["goto_previous"] .. suffix[2]] = "@" .. obj .. ".outer" -  --     textobj_move_keymaps["goto_previous_end"][textobj_prefixes["goto_previous"] .. suffix[1]] = "@" .. obj .. ".outer" -  --   end -  -- -  --   if textobj_prefixes["inner"] ~= nil then -  --     textobj_sel_keymaps[textobj_prefixes["inner"] .. suffix[1]] = "@" .. obj .. ".inner" -  --   end -  --   if textobj_prefixes["outer"] ~= nil then -  --     textobj_sel_keymaps[textobj_prefixes["outer"] .. suffix[1]] = "@" .. obj .. ".outer" -  --   end -  -- -  --   if textobj_prefixes["swap"] ~= nil then -  --     textobj_swap_keymaps[textobj_prefixes["swap"] .. suffix[1]] = "@" .. obj .. ".outer" -  --   end -  -- end -  -- vim.g.ts_hint_textobject_keys = O.treesitter.hint_labels -- Requires https://github.com/mfussenegger/nvim-ts-hint-textobject/pull/2 -  -- -  -- -- Add which key menu entries -  -- local status, wk = pcall(require, "which-key") -  -- if status then -  --   local normal = { -  --     mode = "n", -- Normal mode -  --   } -  --   local operators = { -  --     mode = "o", -- Operator mode -  --   } -  --   wk.register(textobj_sel_keymaps, operators) -  --   wk.register({ -  --     ["m"] = "Hint Objects", -  --     ["."] = "Textsubject", -  --     [";"] = "Textsubject-big", -  --   }, operators) -  --   wk.register(textobj_swap_keymaps, normal) -  --   wk.register({ -  --     [textobj_prefixes["swap"]] = "Swap", -  --     -- [textobj_prefixes["goto_next"]] = "Jump [", -  --     -- [textobj_prefixes["goto_previous"]] = "Jump ]" -  --   }, normal) -  --   wk.register(textobj_move_keymaps["goto_next_start"], normal) -  --   wk.register(textobj_move_keymaps["goto_next_end"], normal) -  --   wk.register(textobj_move_keymaps["goto_previous_start"], normal) -  --   wk.register(textobj_move_keymaps["goto_previous_end"], normal) -  -- end -    local status_ok, treesitter_configs = pcall(require, "nvim-treesitter.configs")    if not status_ok then      return    end -  treesitter_configs.setup(O.treesitter) +  treesitter_configs.setup(lvim.builtin.treesitter)  end  return M diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index c3255705..9d4e7744 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -1,6 +1,6 @@  local M = {}  M.config = function() -  O.plugin.which_key = { +  lvim.builtin.which_key = {      active = false,      setup = {        plugins = { @@ -64,16 +64,38 @@ M.config = function()        ["w"] = { "<cmd>w!<CR>", "Save" },        ["q"] = { "<cmd>q!<CR>", "Quit" },        ["/"] = { "<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" },        ["f"] = { "<cmd>Telescope find_files<CR>", "Find File" },        ["h"] = { '<cmd>let @/=""<CR>', "No Highlight" }, -      [";"] = { "<cmd>Dashboard<CR>", "Dashboard" }, +      b = { +        name = "Buffers", +        j = { "<cmd>BufferPick<cr>", "jump to buffer" }, +        f = { "<cmd>Telescope buffers<cr>", "Find buffer" }, +        w = { "<cmd>BufferWipeout<cr>", "wipeout buffer" }, +        e = { +          "<cmd>BufferCloseAllButCurrent<cr>", +          "close all but current buffer", +        }, +        h = { "<cmd>BufferCloseBuffersLeft<cr>", "close all buffers to the left" }, +        l = { +          "<cmd>BufferCloseBuffersRight<cr>", +          "close all BufferLines to the right", +        }, +        D = { +          "<cmd>BufferOrderByDirectory<cr>", +          "sort BufferLines automatically by directory", +        }, +        L = { +          "<cmd>BufferOrderByLanguage<cr>", +          "sort BufferLines automatically by language", +        }, +      },        p = {          name = "Packer",          c = { "<cmd>PackerCompile<cr>", "Compile" },          i = { "<cmd>PackerInstall<cr>", "Install" }, -        r = { "<cmd>lua require('lv-utils').reload_lv_config()<cr>", "Reload" }, +        r = { "<cmd>lua require('utils').reload_lv_config()<cr>", "Reload" },          s = { "<cmd>PackerSync<cr>", "Sync" },          u = { "<cmd>PackerUpdate<cr>", "Update" },        }, @@ -118,19 +140,21 @@ M.config = function()            "<cmd>Telescope lsp_workspace_diagnostics<cr>",            "Workspace Diagnostics",          }, -        f = { "<cmd>silent FormatWrite<cr>", "Format" }, +        -- f = { "<cmd>silent FormatWrite<cr>", "Format" }, +        f = { "<cmd>lua vim.lsp.buf.formatting()<cr>", "Format" },          i = { "<cmd>LspInfo<cr>", "Info" },          j = { -          "<cmd>lua vim.lsp.diagnostic.goto_next({popup_opts = {border = O.lsp.popup_border}})<cr>", +          "<cmd>lua vim.lsp.diagnostic.goto_next({popup_opts = {border = lvim.lsp.popup_border}})<cr>",            "Next Diagnostic",          },          k = { -          "<cmd>lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = O.lsp.popup_border}})<cr>", +          "<cmd>lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = lvim.lsp.popup_border}})<cr>",            "Prev Diagnostic",          }, +        l = { "<cmd>silent lua require('lint').try_lint()<cr>", "Lint" },          q = { "<cmd>Telescope quickfix<cr>", "Quickfix" },          r = { "<cmd>lua vim.lsp.buf.rename()<cr>", "Rename" }, -        s = { "<cmd> Telescope lsp_document_symbols<cr>", "Document Symbols" }, +        s = { "<cmd>Telescope lsp_document_symbols<cr>", "Document Symbols" },          S = {            "<cmd>Telescope lsp_dynamic_workspace_symbols<cr>",            "Workspace Symbols", @@ -149,6 +173,10 @@ M.config = function()          t = { "<cmd>Telescope live_grep<cr>", "Text" },          k = { "<cmd>Telescope keymaps<cr>", "Keymaps" },          C = { "<cmd>Telescope commands<cr>", "Commands" }, +        p = { +          "<cmd>lua require('telescope.builtin.internal').colorscheme({enable_preview = true})<cr>", +          "Colorscheme with Preview", +        },        },        T = {          name = "Treesitter", @@ -167,29 +195,18 @@ M.setup = function()      return    end -  which_key.setup(O.plugin.which_key.setup) - -  local opts = O.plugin.which_key.opts -  local vopts = O.plugin.which_key.vopts +  which_key.setup(lvim.builtin.which_key.setup) -  local mappings = O.plugin.which_key.mappings -  local vmappings = O.plugin.which_key.vmappings +  local opts = lvim.builtin.which_key.opts +  local vopts = lvim.builtin.which_key.vopts -  -- if O.plugin.ts_playground.active then -  --   vim.api.nvim_set_keymap("n", "<leader>Th", ":TSHighlightCapturesUnderCursor<CR>", { noremap = true, silent = true }) -  --   mappings[""] = "Highlight Capture" -  -- end - -  if O.plugin.zen.active then -    vim.api.nvim_set_keymap("n", "<leader>z", ":ZenMode<CR>", { noremap = true, silent = true }) -    mappings["z"] = "Zen" -  end +  local mappings = lvim.builtin.which_key.mappings +  local vmappings = lvim.builtin.which_key.vmappings    local wk = require "which-key"    wk.register(mappings, opts)    wk.register(vmappings, vopts) -  wk.register(O.user_which_key, opts)  end  return M diff --git a/lua/core/zen.lua b/lua/core/zen.lua deleted file mode 100644 index 99a5d769..00000000 --- a/lua/core/zen.lua +++ /dev/null @@ -1,34 +0,0 @@ -local M = {} -M.config = function() -  O.plugin["zen"] = { -    window = { -      backdrop = 1, -      height = 0.85, -- height of the Zen window -      options = { -        signcolumn = "no", -- disable signcolumn -        number = false, -- disable number column -        relativenumber = false, -- disable relative numbers -        -- cursorline = false, -- disable cursorline -        -- cursorcolumn = false, -- disable cursor column -        -- foldcolumn = "0", -- disable fold column -        -- list = false, -- disable whitespace characters -      }, -    }, -    plugins = { -      gitsigns = { enabled = false }, -- disables git signs -      -- your configuration comes here -      -- or leave it empty to use the default settings -      -- refer to the configuration section below -    }, -  } -end - -M.setup = function() -  local status_ok, zen_mode = pcall(require, "zen-mode") -  if not status_ok then -    return -  end -  zen_mode.setup(O.plugin.zen) -end - -return M diff --git a/lua/default-config.lua b/lua/default-config.lua index b10c9590..77087fe5 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -1,305 +1,924 @@ -CONFIG_PATH = vim.fn.stdpath "config" +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" -O = { -  leader_key = "space", +lvim = { +  leader = "space",    colorscheme = "spacegray",    line_wrap_cursor_movement = true,    transparent_window = false,    format_on_save = true, -  vsnip_dir = vim.fn.stdpath "config" .. "/snippets", +  vsnip_dir = os.getenv "HOME" .. "/.config/snippets", +  database = { save_location = "~/.config/lunarvim_db", auto_execute = 1 }, +  keys = {}, -  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 -    guifont = "monospace:h17", -- the font used in graphical neovim applications -    hidden = true, -- required to keep multiple buffers and open multiple buffers -    hlsearch = false, -- 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 persisten 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 +  -- TODO why do we need this? +  builtin = { +    lspinstall = {}, +    telescope = {}, +    compe = {}, +    autopairs = {}, +    treesitter = {}, +    nvimtree = {}, +    gitsigns = {}, +    which_key = {}, +    comment = {}, +    rooter = {}, +    galaxyline = {}, +    bufferline = {}, +    dap = {}, +    dashboard = {}, +    terminal = {},    }, -  plugin = {}, - -  -- TODO: refactor for tree -  auto_close_tree = 0, -  nvim_tree_disable_netrw = 0, -    lsp = { +    diagnostics = { +      virtual_text = { +        prefix = "", +        spacing = 0, +      }, +      signs = true, +      underline = true, +    }, +    override = {},      document_highlight = true,      popup_border = "single", +    default_keybinds = true, +    on_attach_callback = nil,    }, -  database = { save_location = "~/.config/lunarvim_db", auto_execute = 1 }, - -  -- TODO: just using mappings (leader mappings) -  user_which_key = {}, - -  user_plugins = { +  plugins = {      -- use lv-config.lua for this not put here    }, -  user_autocommands = { -    { "FileType", "qf", "set nobuflisted" }, -  }, +  autocommands = {}, +} + +local schemas = nil +local common_on_attach = require("lsp").common_on_attach +local common_capabilities = require("lsp").common_capabilities() +local status_ok, jsonls_settings = pcall(require, "nlspsettings.jsonls") +if status_ok then +  schemas = jsonls_settings.get_default_schemas() +end -  formatters = { -    filetype = {}, +-- TODO move all of this into lang specific files, only require when using +lvim.lang = { +  c = { +    formatter = { +      exe = "clang_format", +      args = {}, +      stdin = true, +    }, +    linters = { +      "clangtidy", +    }, +    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-*", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  cpp = { +    formatter = { +      exe = "clang_format", +      args = {}, +      stdin = true, +    }, +    linters = { +      "cppcheck", +      "clangtidy", +    }, +    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-*", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  cs = { +    formatter = { +      exe = "", +      args = {}, +    }, +    linters = {}, +    lsp = { +      provider = "omnisharp", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/csharp/omnisharp/run", +          "--languageserver", +          "--hostPID", +          tostring(vim.fn.getpid()), +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  cmake = { +    formatter = { +      exe = "clang_format", +      args = {}, +    }, +    linters = {}, +    lsp = { +      provider = "cmake", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/cmake/venv/bin/cmake-language-server", +          "--stdio", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  clojure = { +    formatter = { +      exe = "", +      args = {}, +    }, +    linters = {}, +    lsp = { +      provider = "clojure_lsp", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/clojure/clojure-lsp", +          "--stdio", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  css = { +    formatter = { +      exe = "prettier", +      args = {}, +    }, +    linters = {}, +    lsp = { +      provider = "cssls", +      setup = { +        cmd = { +          "node", +          DATA_PATH .. "/lspinstall/css/vscode-css/css-language-features/server/dist/node/cssServerMain.js", +          "--stdio", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  dart = { +    formatter = { +      exe = "dart", +      args = { "format" }, +      stdin = true, +    }, +    linters = {}, +    lsp = { +      provider = "dartls", +      setup = { +        cmd = { +          "dart", +          "/usr/lib/dart/bin/snapshots/analysis_server.dart.snapshot", +          "--lsp", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  docker = { +    formatter = { +      exe = "", +      args = {}, +    }, +    linters = {}, +    lsp = { +      provider = "dockerls", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/dockerfile/node_modules/.bin/docker-langserver", +          "--stdio", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  elixir = { +    formatter = { +      exe = "mix", +      args = { "format" }, +      stdin = true, +    }, +    linters = {}, +    lsp = { +      provider = "elixirls", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/elixir/elixir-ls/language_server.sh", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  elm = { +    formatter = { +      exe = "", +      args = {}, +      stdin = true, +    }, +    linters = {}, +    lsp = { +      provider = "elmls", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/elm/node_modules/.bin/elm-language-server", +        }, +        on_attach = common_on_attach, +        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 = { +    formatter = { +      exe = "", +      args = {}, +    }, +    linters = {}, +    lsp = { +      provider = "erlangls", +      setup = { +        cmd = { +          "erlang_ls", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  emmet = { active = false }, +  fish = { +    formatter = { +      exe = "", +      args = {}, +    }, +    linters = {}, +    lsp = { +      provider = "", +      setup = { +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  go = { +    formatter = { +      exe = "gofmt", +      args = {}, +      stdin = true, +    }, +    linters = { +      "golangcilint", +      "revive", +    }, +    lsp = { +      provider = "gopls", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/go/gopls", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  graphql = { +    formatter = { +      exe = "", +      args = {}, +    }, +    linters = {}, +    lsp = { +      provider = "graphql", +      setup = { +        cmd = { +          "graphql-lsp", +          "server", +          "-m", +          "stream", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  html = { +    formatter = { +      exe = "prettier", +      args = {}, +    }, +    linters = { +      "tidy", +      -- https://docs.errata.ai/vale/scoping#html +      "vale", +    }, +    lsp = { +      provider = "html", +      setup = { +        cmd = { +          "node", +          DATA_PATH .. "/lspinstall/html/vscode-html/html-language-features/server/dist/node/htmlServerMain.js", +          "--stdio", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  java = { +    formatter = { +      exe = "prettier", +      args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0) }, +    }, +    linters = {}, +    lsp = { +      provider = "jdtls", +      setup = { +        cmd = { DATA_PATH .. "/lspinstall/java/jdtls.sh" }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  json = { +    formatter = { +      exe = "python", +      args = { "-m", "json.tool" }, +      stdin = true, +    }, +    linters = {}, +    lsp = { +      provider = "jsonls", +      setup = { +        cmd = { +          "node", +          DATA_PATH .. "/lspinstall/json/vscode-json/json-language-features/server/dist/node/jsonServerMain.js", +          "--stdio", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +        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 = { +    formatter = { +      exe = "", +      args = {}, +    }, +    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", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    },    }, +  kotlin = { +    formatter = { +      exe = "", +      args = {}, +    }, +    linters = {}, +    lsp = { +      provider = "kotlin_language_server", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/kotlin/server/bin/kotlin-language-server", +        }, +        on_attach = common_on_attach, +        root_dir = function(fname) +          local util = require "lspconfig/util" -  -- TODO move all of this into lang specific files, only require when using -  lang = { -    cmake = { -      formatter = { -        exe = "clang-format", -        args = {}, -      }, -    }, -    clang = { -      diagnostics = { -        virtual_text = { spacing = 0, prefix = "" }, -        signs = true, -        underline = true, -      }, -      cross_file_rename = true, -      header_insertion = "never", -      filetypes = { "c", "cpp", "objc" }, -      formatter = { -        exe = "clang-format", -        args = {}, +          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,        },      }, -    css = { -      virtual_text = true, -    }, -    dart = { -      sdk_path = "/usr/lib/dart/bin/snapshots/analysis_server.dart.snapshot", -      formatter = { -        exe = "dart", -        args = { "format" }, -      }, -    }, -    docker = {}, -    efm = {}, -    elm = {}, -    emmet = { active = false }, -    elixir = {}, -    graphql = {}, -    go = { -      formatter = { -        exe = "gofmt", -        args = {}, -      }, -    }, -    html = {}, -    java = { -      java_tools = { -        active = false, -      }, -      formatter = { -        exe = "prettier", -        args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0), "--single-quote" }, -      }, -    }, -    json = { -      diagnostics = { -        virtual_text = { spacing = 0, prefix = "" }, -        signs = true, -        underline = true, -      }, -      formatter = { -        exe = "python", -        args = { "-m", "json.tool" }, -      }, -    }, -    kotlin = {}, -    latex = { -      auto_save = false, -      ignore_errors = {}, -    }, -    lua = { -      diagnostics = { -        virtual_text = { spacing = 0, prefix = "" }, -        signs = true, -        underline = true, -      }, -      formatter = { -        exe = "stylua", -        args = {}, -        stdin = false, -      }, -    }, -    php = { -      format = { -        format = { -          default = "psr12", -        }, -      }, -      environment = { -        php_version = "7.4", -      }, -      diagnostics = { -        virtual_text = { spacing = 0, prefix = "" }, -        signs = true, -        underline = true, -      }, -      filetypes = { "php", "phtml" }, -      formatter = { -        exe = "phpcbf", -        args = { "--standard=PSR12", vim.api.nvim_buf_get_name(0) }, -        stdin = false, -      }, -    }, -    python = { -      -- @usage can be flake8 or yapf -      linter = "", -      isort = false, -      diagnostics = { -        virtual_text = { spacing = 0, prefix = "" }, -        signs = true, -        underline = true, -      }, -      analysis = { -        type_checking = "basic", -        auto_search_paths = true, -        use_library_code_types = true, -      }, -      formatter = { -        exe = "yapf", -        args = {}, +  }, +  lua = { +    formatter = { +      exe = "stylua", +      args = {}, +    }, +    linters = { "luacheck" }, +    lsp = { +      provider = "sumneko_lua", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/lua/sumneko-lua-language-server", +          "-E", +          DATA_PATH .. "/lspinstall/lua/main.lua", +        }, +        on_attach = common_on_attach, +        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, +            }, +          }, +        },        },      }, -    ruby = { -      diagnostics = { -        virtualtext = { spacing = 0, prefix = "" }, -        signs = true, -        underline = true, -      }, -      filetypes = { "rb", "erb", "rakefile", "ruby" }, -      formatter = { -        exe = "rufo", -        args = { "-x" }, -      }, -    }, -    rust = { -      rust_tools = { -        active = false, -        parameter_hints_prefix = "<-", -        other_hints_prefix = "=>", -- prefix for all the other hints (type, chaining) +  }, +  php = { +    formatter = { +      exe = "phpcbf", +      args = { "--standard=PSR12", vim.api.nvim_buf_get_name(0) }, +    }, +    linters = {}, +    lsp = { +      provider = "intelephense", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/php/node_modules/.bin/intelephense", +          "--stdio", +        }, +        on_attach = common_on_attach, +        filetypes = { "php", "phtml" }, +        settings = { +          intelephense = { +            environment = { +              phpVersion = "7.4", +            }, +          }, +        },        }, -      -- @usage can be clippy -      formatter = { -        exe = "rustfmt", -        args = { "--emit=stdout", "--edition=2018" }, -      }, -      linter = "", -      diagnostics = { -        virtual_text = { spacing = 0, prefix = "" }, -        signs = true, -        underline = true, +    }, +  }, +  puppet = { +    formatter = { +      exe = "", +      args = {}, +    }, +    linters = {}, +    lsp = { +      provider = "puppet", +      setup = { +        on_attach = require("lsp").common_on_attach, +        capabilities = require("lsp").common_capabilities(),        },      }, -    sh = { -      -- @usage can be 'shellcheck' -      linter = "", -      -- @usage can be 'shfmt' -      diagnostics = { -        virtual_text = { spacing = 0, prefix = "" }, -        signs = true, -        underline = true, -      }, -      formatter = { -        exe = "shfmt", -        args = { "-w" }, -        stdin = false, -      }, -    }, -    svelte = {}, -    tailwindcss = { -      active = false, -      filetypes = { -        "html", -        "css", -        "scss", -        "javascript", -        "javascriptreact", -        "typescript", -        "typescriptreact", +  }, +  javascript = { +    -- @usage can be prettier or eslint +    formatter = { +      exe = "prettier", +      args = {}, +    }, +    linters = { +      "eslint", +    }, +    lsp = { +      provider = "tsserver", +      setup = { +        cmd = { +          -- TODO: +          DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server", +          "--stdio", +        }, +        on_attach = require("lsp").common_on_attach, +        capabilities = require("lsp").common_capabilities(),        },      }, -    terraform = { -      formatter = { -        exe = "terraform", -        args = { "fmt" }, -        stdin = false, +  }, +  javascriptreact = { +    -- @usage can be prettier or eslint +    formatter = { +      exe = "prettier", +      args = {}, +    }, +    linters = { +      "eslint", +    }, +    lsp = { +      provider = "tsserver", +      setup = { +        cmd = { +          -- TODO: +          DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server", +          "--stdio", +        }, +        on_attach = require("lsp").common_on_attach, +        capabilities = require("lsp").common_capabilities(),        },      }, -    tsserver = { -      -- @usage can be 'eslint' or 'eslint_d' -      linter = "", -      diagnostics = { -        virtual_text = { spacing = 0, prefix = "" }, -        signs = true, -        underline = true, -      }, -      formatter = { -        exe = "prettier", -        args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0), "--single-quote" }, -      }, -    }, -    vim = {}, -    yaml = { -      formatter = { -        exe = "prettier", -        args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0), "--single-quote" }, +  }, +  python = { +    -- @usage can be flake8 or yapf +    formatter = { +      exe = "black", +      args = {}, +    }, +    linters = { +      "flake8", +      "pylint", +      "mypy", +    }, +    lsp = { +      provider = "pyright", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/python/node_modules/.bin/pyright-langserver", +          "--stdio", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  -- 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 = { +    formatter = { +      exe = "", +      args = {}, +    }, +    linters = {}, +    lsp = { +      provider = "r_language_server", +      setup = { +        cmd = { +          "R", +          "--slave", +          "-e", +          "languageserver::run()", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  ruby = { +    formatter = { +      exe = "rufo", +      args = {}, +    }, +    linters = { "ruby" }, +    lsp = { +      provider = "solargraph", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/ruby/solargraph/solargraph", +          "stdio", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  rust = { +    formatter = { +      exe = "", +      args = {}, +    }, +    linters = {}, +    lsp = { +      provider = "rust_analyzer", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/rust/rust-analyzer", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  scala = { +    formatter = { +      exe = "", +      args = {}, +    }, +    linters = { "" }, +    lsp = { +      provider = "metals", +      setup = { +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  sh = { +    -- @usage can be 'shfmt' +    formatter = { +      exe = "shfmt", +      args = {}, +    }, +    -- @usage can be 'shellcheck' +    linters = { "shellcheck" }, +    lsp = { +      provider = "bashls", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/bash/node_modules/.bin/bash-language-server", +          "start", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  svelte = { +    formatter = { +      exe = "", +      args = {}, +    }, +    linters = {}, +    lsp = { +      provider = "svelte", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/svelte/node_modules/.bin/svelteserver", +          "--stdio", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  swift = { +    formatter = { +      exe = "swiftformat", +      args = {}, +    }, +    linters = {}, +    lsp = { +      provider = "sourcekit", +      setup = { +        cmd = { +          "xcrun", +          "sourcekit-lsp", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  tailwindcss = { +    active = false, +    filetypes = { +      "html", +      "css", +      "scss", +      "javascript", +      "javascriptreact", +      "typescript", +      "typescriptreact", +    }, +  }, +  terraform = { +    formatter = { +      exe = "", +      args = {}, +      stdin = false, +    }, +    linters = {}, +    lsp = { +      provider = "terraformls", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/terraform/terraform-ls", +          "serve", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  tex = { +    formatter = { +      exe = "latexindent", +      args = {}, +      stdin = false, +    }, +    linters = { "chktex" }, +    lsp = { +      provider = "texlab", +      setup = { +        cmd = { DATA_PATH .. "/lspinstall/latex/texlab" }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  typescript = { +    -- @usage can be prettier or eslint +    formatter = { +      exe = "prettier", +      args = {}, +    }, +    linters = { +      "eslint", +    }, +    lsp = { +      provider = "tsserver", +      setup = { +        cmd = { +          -- TODO: +          DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server", +          "--stdio", +        }, +        on_attach = require("lsp").common_on_attach, +        capabilities = require("lsp").common_capabilities(), +      }, +    }, +  }, +  typescriptreact = { +    -- @usage can be prettier or eslint +    formatter = { +      exe = "prettier", +      args = {}, +    }, +    linters = { +      "eslint", +    }, +    lsp = { +      provider = "tsserver", +      setup = { +        cmd = { +          -- TODO: +          DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server", +          "--stdio", +        }, +        on_attach = require("lsp").common_on_attach, +        capabilities = require("lsp").common_capabilities(), +      }, +    }, +  }, +  vim = { +    formatter = { +      exe = "", +      args = {}, +    }, +    linters = { "" }, +    lsp = { +      provider = "vimls", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/vim/node_modules/.bin/vim-language-server", +          "--stdio", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  vue = { +    formatter = { +      exe = "prettier", +      args = {}, +    }, +    linters = {}, +    lsp = { +      provider = "vetur", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/vue/node_modules/.bin/vls", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  yaml = { +    formatter = { +      exe = "prettier", +      args = {}, +    }, +    linters = {}, +    lsp = { +      provider = "yamlls", +      setup = { +        cmd = { +          DATA_PATH .. "/lspinstall/yaml/node_modules/.bin/yaml-language-server", +          "--stdio", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities, +      }, +    }, +  }, +  zig = { +    formatter = { +      exe = "", +      args = {}, +      stdin = false, +    }, +    linters = {}, +    lsp = { +      provider = "zls", +      setup = { +        cmd = { +          "zls", +        }, +        on_attach = common_on_attach, +        capabilities = common_capabilities,        },      },    },  } +require("core.which-key").config()  require "core.status_colors"  require("core.gitsigns").config()  require("core.compe").config()  require("core.dashboard").config()  require("core.dap").config() -require("core.floatterm").config() -require("core.zen").config() +require("core.terminal").config()  require("core.telescope").config()  require("core.treesitter").config() -require("core.which-key").config() +require("core.nvimtree").config() diff --git a/lua/keymappings.lua b/lua/keymappings.lua index fed362aa..c791418e 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -1,42 +1,41 @@ -local function register_mappings(mappings, default_options) -  for mode, mode_mappings in pairs(mappings) do -    for _, mapping in pairs(mode_mappings) do -      local options = #mapping == 3 and table.remove(mapping) or default_options -      local prefix, cmd = unpack(mapping) -      pcall(vim.api.nvim_set_keymap, mode, prefix, cmd, options) -    end -  end -end +local utils = require "utils" + +local opts = { +  nnoremap = { noremap = true, silent = true }, +  inoremap = { noremap = true, silent = true }, +  vnoremap = { noremap = true, silent = true }, +  xnoremap = { noremap = true, silent = true }, +  generic = { silent = true }, +} -local mappings = { -  i = { -- Insert mode +local default_keys = { +  insert_mode = {      -- I hate escape      { "jk", "<ESC>" },      { "kj", "<ESC>" },      { "jj", "<ESC>" }, -      -- Move current line / block with Alt-j/k ala vscode.      { "<A-j>", "<Esc>:m .+1<CR>==gi" },      { "<A-k>", "<Esc>:m .-2<CR>==gi" }, - -    -- Terminal window navigation -    { "<C-h>", "<C-\\><C-N><C-w>h" }, -    { "<C-j>", "<C-\\><C-N><C-w>j" }, -    { "<C-k>", "<C-\\><C-N><C-w>k" }, -    { "<C-l>", "<C-\\><C-N><C-w>l" }, +    -- navigation +    { "<A-Up>", "<C-\\><C-N><C-w>h" }, +    { "<A-Down>", "<C-\\><C-N><C-w>j" }, +    { "<A-Left>", "<C-\\><C-N><C-w>k" }, +    { "<A-Right>", "<C-\\><C-N><C-w>l" },    }, -  n = { -- Normal mode + +  normal_mode = {      -- Better window movement -    { "<C-h>", "<C-w>h", { silent = true } }, -    { "<C-j>", "<C-w>j", { silent = true } }, -    { "<C-k>", "<C-w>k", { silent = true } }, -    { "<C-l>", "<C-w>l", { silent = true } }, +    { "<C-h>", "<C-w>h" }, +    { "<C-j>", "<C-w>j" }, +    { "<C-k>", "<C-w>k" }, +    { "<C-l>", "<C-w>l" },      -- Resize with arrows -    { "<C-Up>", ":resize -2<CR>", { silent = true } }, -    { "<C-Down>", ":resize +2<CR>", { silent = true } }, -    { "<C-Left>", ":vertical resize -2<CR>", { silent = true } }, -    { "<C-Right>", ":vertical resize +2<CR>", { silent = true } }, +    { "<C-Up>", ":resize -2<CR>" }, +    { "<C-Down>", ":resize +2<CR>" }, +    { "<C-Left>", ":vertical resize -2<CR>" }, +    { "<C-Right>", ":vertical resize +2<CR>" },      -- Tab switch buffer      -- { "<TAB>", ":bnext<CR>" }, @@ -49,17 +48,20 @@ local mappings = {      -- QuickFix      { "]q", ":cnext<CR>" },      { "[q", ":cprev<CR>" }, +    { "<C-q>", ":call QuickFixToggle()<CR>" },      -- {'<C-TAB>', 'compe#complete()', {noremap = true, silent = true, expr = true}},    }, -  t = { -- Terminal mode + +  term_mode = {      -- Terminal window navigation      { "<C-h>", "<C-\\><C-N><C-w>h" },      { "<C-j>", "<C-\\><C-N><C-w>j" },      { "<C-k>", "<C-\\><C-N><C-w>k" },      { "<C-l>", "<C-\\><C-N><C-w>l" },    }, -  v = { -- Visual/Select mode + +  visual_mode = {      -- Better indenting      { "<", "<gv" },      { ">", ">gv" }, @@ -67,7 +69,8 @@ local mappings = {      -- { "p", '"0p', { silent = true } },      -- { "P", '"0P', { silent = true } },    }, -  x = { -- Visual mode + +  visual_block_mode = {      -- Move selected line / block of text in visual mode      { "K", ":move '<-2<CR>gv-gv" },      { "J", ":move '>+1<CR>gv-gv" }, @@ -76,31 +79,37 @@ local mappings = {      { "<A-j>", ":m '>+1<CR>gv-gv" },      { "<A-k>", ":m '<-2<CR>gv-gv" },    }, -  [""] = { -    -- Toggle the QuickFix window -    { "<C-q>", ":call QuickFixToggle()<CR>" }, -  },  } --- TODO: fix this  if vim.fn.has "mac" == 1 then -  mappings["n"][5][1] = "<A-Up>" -  mappings["n"][6][1] = "<A-Down>" -  mappings["n"][7][1] = "<A-Left>" -  mappings["n"][8][1] = "<A-Right>" +  -- TODO: fix this +  default_keys.normal_mode[5][1] = "<A-Up>" +  default_keys.normal_mode[6][1] = "<A-Down>" +  default_keys.normal_mode[7][1] = "<A-Left>" +  default_keys.normal_mode[8][1] = "<A-Right>"  end -register_mappings(mappings, { silent = true, noremap = true }) +if lvim.leader == " " or lvim.leader == "space" then +  vim.g.mapleader = " " +else +  vim.g.mapleader = lvim.leader +end -vim.cmd 'inoremap <expr> <c-j> ("\\<C-n>")' -vim.cmd 'inoremap <expr> <c-k> ("\\<C-p>")' +local function get_user_keys(mode) +  if lvim.keys[mode] == nil then +    return default_keys[mode] +  else +    return lvim.keys[mode] +  end +end --- vim.cmd('inoremap <expr> <TAB> (\"\\<C-n>\")') --- vim.cmd('inoremap <expr> <S-TAB> (\"\\<C-p>\")') +utils.add_keymap_normal_mode(opts.nnoremap, get_user_keys "normal_mode") +utils.add_keymap_insert_mode(opts.inoremap, get_user_keys "insert_mode") +utils.add_keymap_visual_mode(opts.vnoremap, get_user_keys "visual_mode") +utils.add_keymap_visual_block_mode(opts.xnoremap, get_user_keys "visual_block_mode") +utils.add_keymap_term_mode(opts.generic, get_user_keys "term_mode") --- vim.cmd([[ --- map p <Plug>(miniyank-autoput) --- map P <Plug>(miniyank-autoPut) --- map <leader>n <Plug>(miniyank-cycle) --- map <leader>N <Plug>(miniyank-cycleback) --- ]]) +-- navigate tab completion with <c-j> and <c-k> +-- runs conditionally +vim.cmd 'inoremap <expr> <C-j> pumvisible() ? "\\<C-n>" : "\\<C-j>"' +vim.cmd 'inoremap <expr> <C-k> pumvisible() ? "\\<C-p>" : "\\<C-k>"' diff --git a/lua/lsp/angular-ls.lua b/lua/lsp/angular-ls.lua deleted file mode 100644 index 818faf38..00000000 --- a/lua/lsp/angular-ls.lua +++ /dev/null @@ -1,6 +0,0 @@ --- TODO: find correct root filetype --- :LspInstall angular -require("lspconfig").angularls.setup { -  cmd = { DATA_PATH .. "/lspinstall/angular/node_modules/@angular/language-server/bin/ngserver", "--stdio" }, -  on_attach = require("lsp").common_on_attach, -} diff --git a/lua/lsp/emmet-ls.lua b/lua/lsp/emmet-ls.lua deleted file mode 100644 index e38747ac..00000000 --- a/lua/lsp/emmet-ls.lua +++ /dev/null @@ -1,23 +0,0 @@ --- if not package.loaded['lspconfig'] then ---   return --- end - -local nvim_lsp = require "lspconfig" -local configs = require "lspconfig/configs" -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities.textDocument.completion.completionItem.snippetSupport = true - -configs.emmet_ls = { -  default_config = { -    cmd = { "emmet-ls", "--stdio" }, -    filetypes = { "html", "css", "javascript", "typescript", "vue" }, -    root_dir = function() -      return vim.loop.cwd() -    end, -    settings = {}, -  }, -} - -nvim_lsp.emmet_ls.setup { -  -- on_attach = on_attach; -} diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index 01f82737..5a0d6c1e 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -1,4 +1,5 @@ --- TODO: figure out why this don't work +local lsp_config = {} +  vim.fn.sign_define(    "LspDiagnosticsSignError",    { texthl = "LspDiagnosticsSignError", text = "", numhl = "LspDiagnosticsSignError" } @@ -16,37 +17,68 @@ vim.fn.sign_define(    { texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation" }  ) -vim.cmd "nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>" -vim.cmd "nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>" -vim.cmd "nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>" -vim.cmd "nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>" -vim.cmd "nnoremap <silent> gp <cmd>lua require'lsp'.PeekDefinition()<CR>" -vim.cmd "nnoremap <silent> K :lua vim.lsp.buf.hover()<CR>" --- vim.cmd('nnoremap <silent> <C-k> <cmd>lua vim.lsp.buf.signature_help()<CR>') -vim.cmd "nnoremap <silent> <C-p> :lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = O.lsp.popup_border}})<CR>" -vim.cmd "nnoremap <silent> <C-n> :lua vim.lsp.diagnostic.goto_next({popup_opts = {border = O.lsp.popup_border}})<CR>" --- scroll down hover doc or scroll in definition preview --- scroll up hover doc -vim.cmd 'command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()' +-- local opts = { border = "single" } +-- TODO revisit this +-- local border = { +--   { "🭽", "FloatBorder" }, +--   { "▔", "FloatBorder" }, +--   { "🭾", "FloatBorder" }, +--   { "▕", "FloatBorder" }, +--   { "🭿", "FloatBorder" }, +--   { "▁", "FloatBorder" }, +--   { "🭼", "FloatBorder" }, +--   { "▏", "FloatBorder" }, +-- } + +-- My font didn't like this :/ +-- vim.api.nvim_set_keymap( +--   "n", +--   "gl", +--   '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics({ show_header = false, border = { { "🭽", "FloatBorder" }, { "▔", "FloatBorder" }, { "🭾", "FloatBorder" }, { "▕", "FloatBorder" }, { "🭿", "FloatBorder" }, { "▁", "FloatBorder" }, { "🭼", "FloatBorder" }, { "▏", "FloatBorder" }, } })<CR>', +--   { noremap = true, silent = true } +-- ) + +function lsp_config.setup_default_bindings() +  if lvim.lsp.default_keybinds then +    vim.cmd "nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>" +    vim.cmd "nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>" +    vim.cmd "nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>" +    vim.cmd "nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>" +    vim.api.nvim_set_keymap( +      "n", +      "gl", +      '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics({ show_header = false, border = "single" })<CR>', +      { noremap = true, silent = true } +    ) + +    vim.cmd "nnoremap <silent> gp <cmd>lua require'lsp'.PeekDefinition()<CR>" +    vim.cmd "nnoremap <silent> K :lua vim.lsp.buf.hover()<CR>" +    vim.cmd "nnoremap <silent> <C-p> :lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = lvim.lsp.popup_border}})<CR>" +    vim.cmd "nnoremap <silent> <C-n> :lua vim.lsp.diagnostic.goto_next({popup_opts = {border = lvim.lsp.popup_border}})<CR>" +    -- vim.cmd "nnoremap <silent> <tab> <cmd>lua vim.lsp.buf.signature_help()<CR>" +    -- scroll down hover doc or scroll in definition preview +    -- scroll up hover doc +    vim.cmd 'command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()' +  end +end  -- Set Default Prefix.  -- Note: You can set a prefix per lsp server in the lv-globals.lua file -vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { -  virtual_text = { -    prefix = "", -    spacing = 0, -  }, -  signs = true, -  underline = true, -}) +function lsp_config.setup_handlers() +  vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { +    virtual_text = lvim.lsp.diagnostics.virtual_text, +    signs = lvim.lsp.diagnostics.signs, +    underline = lvim.lsp.document_highlight, +  }) -vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { -  border = O.lsp.popup_border, -}) +  vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { +    border = lvim.lsp.popup_border, +  }) -vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { -  border = O.lsp.popup_border, -}) +  vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { +    border = lvim.lsp.popup_border, +  }) +end  -- symbols for autocomplete  vim.lsp.protocol.CompletionItemKind = { @@ -84,7 +116,10 @@ autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 100) ]]  -- Java  -- autocmd FileType java nnoremap ca <Cmd>lua require('jdtls').code_action()<CR> -local function documentHighlight(client, bufnr) +local function lsp_highlight_document(client) +  if lvim.lsp.document_highlight == false then +    return -- we don't need further +  end    -- Set autocommands conditional on server_capabilities    if client.resolved_capabilities.document_highlight then      vim.api.nvim_exec( @@ -102,7 +137,6 @@ local function documentHighlight(client, bufnr)      )    end  end -local lsp_config = {}  -- Taken from https://www.reddit.com/r/neovim/comments/gyb077/nvimlsp_peek_defination_javascript_ttserver/  function lsp_config.preview_location(location, context, before_context) @@ -126,7 +160,7 @@ function lsp_config.preview_location(location, context, before_context)      false    )    local filetype = vim.api.nvim_buf_get_option(bufnr, "filetype") -  return vim.lsp.util.open_floating_preview(contents, filetype, { border = O.lsp.popup_border }) +  return vim.lsp.util.open_floating_preview(contents, filetype, { border = lvim.lsp.popup_border })  end  function lsp_config.preview_location_callback(_, method, result) @@ -169,65 +203,102 @@ function lsp_config.PeekImplementation()    end  end -if O.lsp.document_highlight then -  function lsp_config.common_on_attach(client, bufnr) -    documentHighlight(client, bufnr) +function lsp_config.common_on_attach(client, bufnr) +  if lvim.lsp.on_attach_callback then +    lvim.lsp.on_attach_callback(client, bufnr)    end +  lsp_highlight_document(client)  end -function lsp_config.tsserver_on_attach(client, bufnr) -  -- lsp_config.common_on_attach(client, bufnr) +local function no_formatter_on_attach(client, bufnr) +  if lvim.lsp.on_attach_callback then +    lvim.lsp.on_attach_callback(client, bufnr) +  end +  lsp_highlight_document(client)    client.resolved_capabilities.document_formatting = false +end -  local ts_utils = require "nvim-lsp-ts-utils" - -  -- defaults -  ts_utils.setup { -    debug = false, -    disable_commands = false, -    enable_import_on_completion = false, -    import_all_timeout = 5000, -- ms - -    -- eslint -    eslint_enable_code_actions = true, -    eslint_enable_disable_comments = true, -    eslint_bin = O.lang.tsserver.linter, -    eslint_config_fallback = nil, -    eslint_enable_diagnostics = true, - -    -- formatting -    enable_formatting = O.lang.tsserver.autoformat, -    formatter = O.lang.tsserver.formatter.exe, -    formatter_config_fallback = nil, - -    -- parentheses completion -    complete_parens = false, -    signature_help_in_parens = false, - -    -- update imports on file move -    update_imports_on_move = false, -    require_confirmation_on_move = false, -    watch_dir = nil, +function lsp_config.common_capabilities() +  local capabilities = vim.lsp.protocol.make_client_capabilities() +  capabilities.textDocument.completion.completionItem.snippetSupport = true +  capabilities.textDocument.completion.completionItem.resolveSupport = { +    properties = { +      "documentation", +      "detail", +      "additionalTextEdits", +    },    } - -  -- required to fix code action ranges -  ts_utils.setup_client(client) - -  -- TODO: keymap these? -  -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gs", ":TSLspOrganize<CR>", {silent = true}) -  -- vim.api.nvim_buf_set_keymap(bufnr, "n", "qq", ":TSLspFixCurrent<CR>", {silent = true}) -  -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", ":TSLspRenameFile<CR>", {silent = true}) -  -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", ":TSLspImportAll<CR>", {silent = true}) +  return capabilities  end -require("lv-utils").define_augroups { +require("core.autocmds").define_augroups {    _general_lsp = {      { "FileType", "lspinfo", "nnoremap <silent> <buffer> q :q<CR>" },    },  } --- Use a loop to conveniently both setup defined servers --- and map buffer local keybindings when the language server attaches --- local servers = {"pyright", "tsserver"} --- for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup {on_attach = on_attach} end +local function is_table(t) +  return type(t) == "table" +end + +local function is_string(t) +  return type(t) == "string" +end + +local function has_value(tab, val) +  for _, value in ipairs(tab) do +    if value == val then +      return true +    end +  end + +  return false +end + +function lsp_config.setup(lang) +  local lang_server = lvim.lang[lang].lsp +  local provider = lang_server.provider +  if require("utils").check_lsp_client_active(provider) then +    return +  end + +  local overrides = lvim.lsp.override + +  if is_table(overrides) then +    if has_value(overrides, lang) then +      return +    end +  end + +  if is_string(overrides) then +    if overrides == lang then +      return +    end +  end +  local sources = require("lsp.null-ls").setup(lang) + +  for _, source in pairs(sources) do +    local method = source.method +    local format_method = "NULL_LS_FORMATTING" + +    if is_table(method) then +      if has_value(method, format_method) then +        lang_server.setup.on_attach = no_formatter_on_attach +      end +    end + +    if is_string(method) then +      if method == format_method then +        lang_server.setup.on_attach = no_formatter_on_attach +      end +    end +  end + +  if provider == "" or provider == nil then +    return +  end + +  require("lspconfig")[provider].setup(lang_server.setup) +end +  return lsp_config diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua new file mode 100644 index 00000000..48924be5 --- /dev/null +++ b/lua/lsp/null-ls.lua @@ -0,0 +1,83 @@ +local M = {} + +local null_ls = require "null-ls" +local sources = {} + +local local_executables = { "prettier", "prettierd", "prettier_d_slim", "eslint_d", "eslint" } + +local function is_table(t) +  return type(t) == "table" +end + +local function is_string(t) +  return type(t) == "string" +end + +local function has_value(tab, val) +  for _, value in ipairs(tab) do +    if value == val then +      return true +    end +  end + +  return false +end + +local find_local_exe = function(exe) +  vim.cmd "let root_dir = FindRootDirectory()" +  local root_dir = vim.api.nvim_get_var "root_dir" +  local local_exe = root_dir .. "/node_modules/.bin/" .. exe +  return local_exe +end + +local function setup_ls(exe, type) +  if has_value(local_executables, exe) then +    local smart_executable = null_ls.builtins[type][exe] +    local local_executable = find_local_exe(exe) +    if vim.fn.executable(local_executable) == 1 then +      smart_executable._opts.command = local_executable +      table.insert(sources, smart_executable) +    else +      if vim.fn.executable(exe) == 1 then +        table.insert(sources, smart_executable) +      end +    end +  else +    if vim.fn.executable(exe) == 1 then +      table.insert(sources, null_ls.builtins[type][exe]) +    end +  end +  null_ls.register { sources = sources } +end + +-- TODO: for linters and formatters with spaces and '-' replace with '_' +local function setup(filetype, type) +  local executables = nil +  if type == "diagnostics" then +    executables = lvim.lang[filetype].linters +  end +  if type == "formatting" then +    executables = lvim.lang[filetype].formatter.exe +  end + +  if is_table(executables) then +    for _, exe in pairs(executables) do +      if exe ~= "" then +        setup_ls(exe, type) +      end +    end +  end +  if is_string(executables) and executables ~= "" then +    setup_ls(executables, type) +  end +end + +-- TODO: return the formatter if one was registered, then turn off the builtin formatter +function M.setup(filetype) +  setup(filetype, "formatting") +  setup(filetype, "diagnostics") +  lvim.sources = sources +  return sources +end + +return M diff --git a/lua/lsp/svelte-ls.lua b/lua/lsp/svelte-ls.lua deleted file mode 100644 index e5ddb3b3..00000000 --- a/lua/lsp/svelte-ls.lua +++ /dev/null @@ -1,5 +0,0 @@ --- TODO: what is a svelte filetype -require("lspconfig").svelte.setup { -  cmd = { DATA_PATH .. "/lspinstall/svelte/node_modules/.bin/svelteserver", "--stdio" }, -  on_attach = require("lsp").common_on_attach, -} diff --git a/lua/lsp/tailwindcss-ls.lua b/lua/lsp/tailwindcss-ls.lua deleted file mode 100644 index 38c1e7cc..00000000 --- a/lua/lsp/tailwindcss-ls.lua +++ /dev/null @@ -1,13 +0,0 @@ --- TODO: what is a tailwindcss filetype -local lspconfig = require "lspconfig" - -lspconfig.tailwindcss.setup { -  cmd = { -    "node", -    DATA_PATH .. "/lspinstall/tailwindcss/tailwindcss-intellisense/extension/dist/server/tailwindServer.js", -    "--stdio", -  }, -  filetypes = O.lang.tailwindcss.filetypes, -  root_dir = require("lspconfig/util").root_pattern("tailwind.config.js", "postcss.config.ts", ".postcssrc"), -  on_attach = require("lsp").common_on_attach, -} diff --git a/lua/lsp/ts-fmt-lint.lua b/lua/lsp/ts-fmt-lint.lua deleted file mode 100644 index a73b817e..00000000 --- a/lua/lsp/ts-fmt-lint.lua +++ /dev/null @@ -1,49 +0,0 @@ --- Example configuations here: https://github.com/mattn/efm-langserver --- You can look for project scope Prettier and Eslint with e.g. vim.fn.glob("node_modules/.bin/prettier") etc. If it is not found revert to global Prettier where needed. -local M = {} - -M.setup = function() -  local tsserver_args = {} - -  if O.lang.tsserver.linter == "eslint" or O.lang.tsserver.linter == "eslint_d" then -    local eslint = { -      lintCommand = O.lang.tsserver.linter .. " -f unix --stdin --stdin-filename   {INPUT}", -      lintStdin = true, -      lintFormats = { "%f:%l:%c: %m" }, -      lintIgnoreExitCode = true, -      formatCommand = O.lang.tsserver.linter .. " --fix-to-stdout --stdin  --stdin-filename=${INPUT}", -      formatStdin = true, -    } -    table.insert(tsserver_args, eslint) -  end - -  require("lspconfig").efm.setup { -    -- init_options = {initializationOptions}, -    cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" }, -    init_options = { documentFormatting = true, codeAction = false }, -    root_dir = require("lspconfig").util.root_pattern(".git/", "package.json"), -    filetypes = { -      "vue", -      "javascript", -      "javascriptreact", -      "typescript", -      "typescriptreact", -      "javascript.jsx", -      "typescript.tsx", -    }, -    settings = { -      rootMarkers = { ".git/", "package.json" }, -      languages = { -        vue = tsserver_args, -        javascript = tsserver_args, -        javascriptreact = tsserver_args, -        ["javascript.jsx"] = tsserver_args, -        typescript = tsserver_args, -        ["typescript.tsx"] = tsserver_args, -        typescriptreact = tsserver_args, -      }, -    }, -  } -end - -return M diff --git a/lua/lsp/tsserver-ls.lua b/lua/lsp/tsserver-ls.lua deleted file mode 100644 index 8ed801e8..00000000 --- a/lua/lsp/tsserver-ls.lua +++ /dev/null @@ -1,67 +0,0 @@ -vim.cmd "let proj = FindRootDirectory()" -local root_dir = vim.api.nvim_get_var "proj" - --- use the global prettier if you didn't find the local one -local prettier_instance = root_dir .. "/node_modules/.bin/prettier" -if vim.fn.executable(prettier_instance) ~= 1 then -  prettier_instance = O.lang.tsserver.formatter.exe -end - -O.formatters.filetype["javascriptreact"] = { -  function() -    return { -      exe = prettier_instance, -      -- TODO: allow user to override this -      args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0), "--single-quote" }, -      stdin = true, -    } -  end, -} -O.formatters.filetype["javascript"] = O.formatters.filetype["javascriptreact"] - -require("formatter.config").set_defaults { -  logging = false, -  filetype = O.formatters.filetype, -} - -if require("lv-utils").check_lsp_client_active "tsserver" then -  return -end - --- npm install -g typescript typescript-language-server --- require'snippets'.use_suggested_mappings() --- local capabilities = vim.lsp.protocol.make_client_capabilities() --- capabilities.textDocument.completion.completionItem.snippetSupport = true; --- local on_attach_common = function(client) --- print("LSP Initialized") --- require'completion'.on_attach(client) --- require'illuminate'.on_attach(client) --- end -require("lspconfig").tsserver.setup { -  cmd = { -    DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server", -    "--stdio", -  }, -  filetypes = { -    "javascript", -    "javascriptreact", -    "javascript.jsx", -    "typescript", -    "typescriptreact", -    "typescript.tsx", -  }, -  on_attach = require("lsp").tsserver_on_attach, -  -- This makes sure tsserver is not used for formatting (I prefer prettier) -  -- on_attach = require'lsp'.common_on_attach, -  root_dir = require("lspconfig/util").root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"), -  settings = { documentFormatting = false }, -  handlers = { -    ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { -      virtual_text = O.lang.tsserver.diagnostics.virtual_text, -      signs = O.lang.tsserver.diagnostics.signs, -      underline = O.lang.tsserver.diagnostics.underline, -      update_in_insert = true, -    }), -  }, -} -require("lsp.ts-fmt-lint").setup() diff --git a/lua/lv-user/README.md b/lua/lv-user/README.md deleted file mode 100644 index 789001a2..00000000 --- a/lua/lv-user/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# User Config - -If you have found this directory then you are probably advanced enough to add your own config. All `lua` files you create here will be available in lv-config. - -**NOTE** I may update this readme in the future so I recommend not changing anything in this file specifically diff --git a/lua/plugin-loader.lua b/lua/plugin-loader.lua new file mode 100644 index 00000000..b7e68a1e --- /dev/null +++ b/lua/plugin-loader.lua @@ -0,0 +1,49 @@ +local plugin_loader = {} + +function plugin_loader:init() +  local execute = vim.api.nvim_command +  local fn = vim.fn + +  local install_path = "~/.local/share/lunarvim/site/pack/packer/start/packer.nvim" +  if fn.empty(fn.glob(install_path)) > 0 then +    execute("!git clone https://github.com/wbthomason/packer.nvim " .. install_path) +    execute "packadd packer.nvim" +  end + +  local packer_ok, packer = pcall(require, "packer") +  if not packer_ok then +    return +  end + +  local util = require "packer.util" + +  packer.init { +    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 }, +    display = { +      open_fn = function() +        return util.float { border = "single" } +      end, +    }, +  } + +  self.packer = packer +  return self +end + +function plugin_loader:load(configurations) +  return self.packer.startup(function(use) +    for _, plugins in ipairs(configurations) do +      for _, plugin in ipairs(plugins) do +        use(plugin) +      end +    end +  end) +end + +return { +  init = function() +    return plugin_loader:init() +  end, +} diff --git a/lua/plugins.lua b/lua/plugins.lua index 129bc91d..0fd477de 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,123 +1,126 @@ -local execute = vim.api.nvim_command -local fn = vim.fn - -local install_path = fn.stdpath "data" .. "/site/pack/packer/start/packer.nvim" - -if fn.empty(fn.glob(install_path)) > 0 then -  execute("!git clone https://github.com/wbthomason/packer.nvim " .. install_path) -  execute "packadd packer.nvim" -end - -local packer_ok, packer = pcall(require, "packer") -if not packer_ok then -  return -end - -packer.init { -  -- package_root = require("packer.util").join_paths(vim.fn.stdpath "data", "lvim", "pack"), -  git = { clone_timeout = 300 }, -  display = { -    open_fn = function() -      return require("packer.util").float { border = "single" } -    end, -  }, -} - -return require("packer").startup(function(use) +return {    -- Packer can manage itself as an optional plugin -  use "wbthomason/packer.nvim" - -  -- TODO: refactor all of this (for now it works, but yes I know it could be wrapped in a simpler function) -  use { "neovim/nvim-lspconfig" } -  use { +  { "wbthomason/packer.nvim" }, +  { "neovim/nvim-lspconfig" }, +  { "tamago324/nlsp-settings.nvim" }, +  { "jose-elias-alvarez/null-ls.nvim" }, +  {      "kabouzeid/nvim-lspinstall",      event = "VimEnter",      config = function() -      require("lspinstall").setup() +      local lspinstall = require "lspinstall" +      lspinstall.setup() +      if lvim.builtin.lspinstall.on_config_done then +        lvim.builtin.lspinstall.on_config_done(lspinstall) +      end      end, -  } +  }, -  use { "nvim-lua/popup.nvim" } -  use { "nvim-lua/plenary.nvim" } -  use { "tjdevries/astronauta.nvim" } +  { "nvim-lua/popup.nvim" }, +  { "nvim-lua/plenary.nvim" }, +  { "tjdevries/astronauta.nvim" },    -- Telescope -  use { +  {      "nvim-telescope/telescope.nvim", -    config = [[require('core.telescope').setup()]], -  } +    config = function() +      require("core.telescope").setup() +      if lvim.builtin.telescope.on_config_done then +        lvim.builtin.telescope.on_config_done(require "telescope") +      end +    end, +  }, -  -- Autocomplete -  use { +  -- Completion & Snippets +  {      "hrsh7th/nvim-compe", -    -- event = "InsertEnter", +    event = "InsertEnter",      config = function()        require("core.compe").setup() +      if lvim.builtin.compe.on_config_done then +        lvim.builtin.compe.on_config_done(require "compe") +      end      end, -  } +    wants = "vim-vsnip", +    requires = { +      { +        "hrsh7th/vim-vsnip", +        wants = "friendly-snippets", +        event = "InsertCharPre", +      }, +      { +        "rafamadriz/friendly-snippets", +        event = "InsertCharPre", +      }, +    }, +  },    -- Autopairs -  use { +  {      "windwp/nvim-autopairs",      -- event = "InsertEnter", -    after = { "telescope.nvim" }, +    after = "nvim-compe",      config = function()        require "core.autopairs" +      if lvim.builtin.autopairs.on_config_done then +        lvim.builtin.autopairs.on_config_done(require "nvim-autopairs") +      end      end, -  } - -  -- Snippets - -  use { "hrsh7th/vim-vsnip", event = "InsertEnter" } -  use { "rafamadriz/friendly-snippets", event = "InsertEnter" } +  },    -- Treesitter -  use { +  {      "nvim-treesitter/nvim-treesitter", +    branch = "0.5-compat", +    -- run = ":TSUpdate",      config = function()        require("core.treesitter").setup() +      if lvim.builtin.treesitter.on_config_done then +        lvim.builtin.treesitter.on_config_done(require "nvim-treesitter.configs") +      end      end, -  } - -  -- Formatter.nvim -  use { -    "mhartington/formatter.nvim", -    config = function() -      require "core.formatter" -    end, -  } +  },    -- NvimTree -  use { +  {      "kyazdani42/nvim-tree.lua",      -- event = "BufWinOpen",      -- cmd = "NvimTreeToggle", -    commit = "fd7f60e242205ea9efc9649101c81a07d5f458bb", +    -- commit = "fd7f60e242205ea9efc9649101c81a07d5f458bb",      config = function()        require("core.nvimtree").setup() +      if lvim.builtin.nvimtree.on_config_done then +        lvim.builtin.nvimtree.on_config_done(require "nvim-tree.config") +      end      end, -  } +  }, -  use { +  {      "lewis6991/gitsigns.nvim",      config = function()        require("core.gitsigns").setup() +      if lvim.builtin.gitsigns.on_config_done then +        lvim.builtin.gitsigns.on_config_done(require "gitsigns") +      end      end,      event = "BufRead", -  } +  }, -  -- whichkey -  use { +  -- Whichkey +  {      "folke/which-key.nvim",      config = function()        require("core.which-key").setup() +      if lvim.builtin.which_key.on_config_done then +        lvim.builtin.which_key.on_config_done(require "which-key") +      end      end,      event = "BufWinEnter", -  } +  },    -- Comments -  use { +  {      "terrortylor/nvim-comment",      event = "BufRead",      config = function() @@ -126,129 +129,104 @@ return require("packer").startup(function(use)          return        end        nvim_comment.setup() +      if lvim.builtin.comment.on_config_done then +        lvim.builtin.comment.on_config_done(nvim_comment) +      end      end, -  } +  },    -- vim-rooter -  use { +  {      "airblade/vim-rooter",      config = function()        vim.g.rooter_silent_chdir = 1 +      vim.g.rooter_patterns = { +        ".git", +        "_darcs", +        ".hg", +        ".bzr", +        ".svn", +        "Makefile", +        "package.json", +        "package-lock.json", +      } +      if lvim.builtin.rooter.on_config_done then +        lvim.builtin.rooter.on_config_done() +      end      end, -  } +  },    -- Icons -  use { "kyazdani42/nvim-web-devicons" } +  { "kyazdani42/nvim-web-devicons" },    -- Status Line and Bufferline -  use { +  {      "glepnir/galaxyline.nvim",      config = function()        require "core.galaxyline" +      if lvim.builtin.galaxyline.on_config_done then +        lvim.builtin.galaxyline.on_config_done(require "galaxyline") +      end      end,      event = "BufWinEnter", -    disable = not O.plugin.galaxyline.active, -  } +    disable = not lvim.builtin.galaxyline.active, +  }, -  use { +  {      "romgrk/barbar.nvim",      config = function()        require "core.bufferline" +      if lvim.builtin.bufferline.on_config_done then +        lvim.builtin.bufferline.on_config_done() +      end      end,      event = "BufWinEnter", -  } +  },    -- Debugging -  use { +  {      "mfussenegger/nvim-dap",      -- event = "BufWinEnter",      config = function()        require("core.dap").setup() +      if lvim.builtin.dap.on_config_done then +        lvim.builtin.dap.on_config_done(require "dap") +      end      end, -    disable = not O.plugin.dap.active, -  } +    disable = not lvim.builtin.dap.active, +  },    -- Debugger management -  use { +  {      "Pocco81/DAPInstall.nvim",      -- event = "BufWinEnter",      -- event = "BufRead", -    disable = not O.plugin.dap.active, -  } - -  -- Builtins, these do not load by default +    disable = not lvim.builtin.dap.active, +  },    -- Dashboard -  use { +  {      "ChristianChiarulli/dashboard-nvim",      event = "BufWinEnter",      config = function()        require("core.dashboard").setup() +      if lvim.builtin.dashboard.on_config_done then +        lvim.builtin.dashboard.on_config_done(require "dashboard") +      end      end, -    disable = not O.plugin.dashboard.active, -  } +    disable = not lvim.builtin.dashboard.active, +  }, -  -- TODO: remove in favor of akinsho/nvim-toggleterm.lua -  -- Floating terminal -  use { -    "numToStr/FTerm.nvim", +  -- Terminal +  { +    "akinsho/nvim-toggleterm.lua",      event = "BufWinEnter",      config = function() -      require("core.floatterm").setup() -    end, -    disable = not O.plugin.floatterm.active, -  } - -  -- Zen Mode -  use { -    "folke/zen-mode.nvim", -    cmd = "ZenMode", -    event = "BufRead", -    config = function() -      require("core.zen").setup() +      require("core.terminal").setup() +      if lvim.builtin.terminal.on_config_done then +        lvim.builtin.terminal.on_config_done(require "toggleterm") +      end      end, -    disable = not O.plugin.zen.active, -  } - -  --------------------------------------------------------------------------------- - -  -- LANGUAGE SPECIFIC GOES HERE -  use { -    "lervag/vimtex", -    ft = "tex", -  } - -  -- Rust tools -  -- TODO: use lazy loading maybe? -  use { -    "simrat39/rust-tools.nvim", -    disable = not O.lang.rust.rust_tools.active, -  } - -  -- Elixir -  use { "elixir-editors/vim-elixir", ft = { "elixir", "eelixir", "euphoria3" } } - -  -- Javascript / Typescript -  use { -    "jose-elias-alvarez/nvim-lsp-ts-utils", -    ft = { -      "javascript", -      "javascriptreact", -      "javascript.jsx", -      "typescript", -      "typescriptreact", -      "typescript.tsx", -    }, -  } - -  use { -    "mfussenegger/nvim-jdtls", -    -- ft = { "java" }, -    disable = not O.lang.java.java_tools.active, -  } - -  -- Install user plugins -  for _, plugin in pairs(O.user_plugins) do -    packer.use(plugin) -  end -end) +    disable = not lvim.builtin.terminal.active, +  }, +} diff --git a/lua/settings.lua b/lua/settings.lua index e4ee9e24..d96c1338 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -1,60 +1,78 @@ ----  HELPERS  --- +local M = {} -local cmd = vim.cmd -local opt = vim.opt +M.load_options = function() +  local opt = vim.opt ----  VIM ONLY COMMANDS  --- +  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+=-" -cmd "filetype plugin on" -cmd('let &titleold="' .. TERMINAL .. '"') -cmd "set inccommand=split" -cmd "set iskeyword+=-" +  ---  SETTINGS  --- -if O.line_wrap_cursor_movement then -  cmd "set whichwrap+=<,>,[,],h,l" -end +  opt.shortmess:append "c" -if O.transparent_window then -  cmd "au ColorScheme * hi Normal ctermbg=none guibg=none" -  cmd "au ColorScheme * hi SignColumn ctermbg=none guibg=none" -  cmd "let &fcs='eob: '" +  for k, v in pairs(default_options) do +    vim.opt[k] = v +  end  end ----  SETTINGS  --- - -opt.shortmess:append "c" - -local disabled_built_ins = { -  "netrw", -  "netrwPlugin", -  "netrwSettings", -  "netrwFileHandlers", -  "gzip", -  "zip", -  "zipPlugin", -  "tar", -  "tarPlugin", -- 'man', -  "getscript", -  "getscriptPlugin", -  "vimball", -  "vimballPlugin", -  "2html_plugin", -  "logipat", -  "rrhelper", -  "spellfile_plugin", -  -- 'matchit', 'matchparen', 'shada_plugin', -} - -if O.leader_key == " " or O.leader_key == "space" then -  vim.g.mapleader = ' ' -else -  vim.g.mapleader = O.leader_key -end +M.load_commands = function() +  local cmd = vim.cmd +  if lvim.line_wrap_cursor_movement then +    cmd "set whichwrap+=<,>,[,],h,l" +  end -for _, plugin in pairs(disabled_built_ins) do -  vim.g["loaded_" .. plugin] = 1 +  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 -for k, v in pairs(O.default_options) do -  vim.opt[k] = v -end +return M diff --git a/lua/spacegray/Git.lua b/lua/spacegray/Git.lua index f1a2ed39..b47ccf23 100644 --- a/lua/spacegray/Git.lua +++ b/lua/spacegray/Git.lua @@ -1,10 +1,10 @@  local Git = { -		SignAdd = {fg = C.sign_add, }, -		SignChange = {fg = C.sign_change, }, -		SignDelete = {fg = C.sign_delete, }, -		GitSignsAdd = {fg = C.sign_add, }, -		GitSignsChange = {fg = C.sign_change, }, -		GitSignsDelete = {fg = C.sign_delete, }, +  SignAdd = { fg = C.sign_add }, +  SignChange = { fg = C.sign_change }, +  SignDelete = { fg = C.sign_delete }, +  GitSignsAdd = { fg = C.sign_add }, +  GitSignsChange = { fg = C.sign_change }, +  GitSignsDelete = { fg = C.sign_delete },  } -return Git
\ No newline at end of file +return Git diff --git a/lua/spacegray/LSP.lua b/lua/spacegray/LSP.lua index eb674175..2dfa07ff 100644 --- a/lua/spacegray/LSP.lua +++ b/lua/spacegray/LSP.lua @@ -1,92 +1,92 @@  local LSP = { -		LspDiagnosticsDefaultError = {fg = C.error_red, }, -		LspDiagnosticsDefaultWarning = {fg = C.warning_orange, }, -		LspDiagnosticsDefaultInformation = {fg = C.info_yellow, }, -		LspDiagnosticsDefaultHint = {fg = C.hint_blue, }, -		LspDiagnosticsVirtualTextError = {fg = C.error_red, }, -		LspDiagnosticsVirtualTextWarning = {fg = C.warning_orange, }, -		LspDiagnosticsVirtualTextInformation = {fg = C.info_yellow, }, -		LspDiagnosticsVirtualTextHint = {fg = C.hint_blue, }, -		LspDiagnosticsFloatingError = {fg = C.error_red, }, -		LspDiagnosticsFloatingWarning = {fg = C.warning_orange, }, -		LspDiagnosticsFloatingInformation = {fg = C.info_yellow, }, -		LspDiagnosticsFloatingHint = {fg = C.hint_blue, }, -		LspDiagnosticsSignError = {fg = C.error_red, }, -		LspDiagnosticsSignWarning = {fg = C.warning_orange, }, -		LspDiagnosticsSignInformation = {fg = C.info_yellow, }, -		LspDiagnosticsSignHint = {fg = C.hint_blue, }, -		LspDiagnosticsError = {fg = C.error_red, }, -		LspDiagnosticsWarning = {fg = C.warning_orange, }, -		LspDiagnosticsInformation = {fg = C.info_yellow, }, -		LspDiagnosticsHint = {fg = C.hint_blue, }, -		LspDiagnosticsUnderlineError = {fg = C.error_red, }, -		LspDiagnosticsUnderlineWarning = {fg = C.warning_orange, }, -		LspDiagnosticsUnderlineInformation = {fg = C.info_yellow, }, -		LspDiagnosticsUnderlineHint = {fg = C.hint_blue, }, -		QuickScopePrimary = {fg = C.cyan_test, style = "underline", }, -		QuickScopeSecondary = {fg = C.purple_test, style = "underline", }, -		TelescopeSelection = {fg = C.hint_blue, }, -		TelescopeMatching = {fg = C.info_yellow, style = "bold", }, -		TelescopeBorder = {fg = C.cyan, bg = C.bg, }, -		NvimTreeFolderIcon = {fg = C.blue, }, -		NvimTreeIndentMarker = {fg = C.gray, }, -		NvimTreeNormal = {fg = C.light_gray, bg = C.alt_bg, }, -		NvimTreeVertSplit = {fg = C.alt_bg, bg = C.alt_bg, }, -		NvimTreeFolderName = {fg = C.blue, }, -		NvimTreeOpenedFolderName = {fg = C.cyan, style = "italic", }, -		NvimTreeImageFile = {fg = C.purple, }, -		NvimTreeSpecialFile = {fg = C.orange, }, -		NvimTreeGitStaged = {fg = C.sign_add, }, -		NvimTreeGitNew = {fg = C.sign_add, }, -		NvimTreeGitDirty = {fg = C.sign_add, }, -		NvimTreeGitDeleted = {fg = C.sign_delete, }, -		NvimTreeGitMerge = {fg = C.sign_change, }, -		NvimTreeGitRenamed = {fg = C.sign_change, }, -		NvimTreeSymlink = {fg = C.cyan, }, -		NvimTreeRootFolder = {fg = C.fg, style = "bold", }, -		NvimTreeExecFile = {fg = C.green, }, -		BufferCurrent = {fg = C.fg, bg = C.bg, }, -		BufferCurrentIndex = {fg = C.fg, bg = C.bg, }, -		BufferCurrentMod = {fg = C.info_yellow, bg = C.bg, }, -		BufferCurrentSign = {fg = C.hint_blue, bg = C.bg, }, -		BufferCurrentTarget = {fg = C.red, bg = C.bg, style = "bold", }, -		BufferVisible = {fg = C.fg, bg = C.bg, }, -		BufferVisibleIndex = {fg = C.fg, bg = C.bg, }, -		BufferVisibleMod = {fg = C.info_yellow, bg = C.bg, }, -		BufferVisibleSign = {fg = C.hint_blue, bg = C.bg, }, -		BufferVisibleTarget = {fg = C.red, bg = C.bg, style = "bold", }, -		BufferInactive = {fg = C.gray, bg = C.alt_bg, }, -		BufferInactiveIndex = {fg = C.gray, bg = C.alt_bg, }, -		BufferInactiveMod = {fg = C.info_yellow, bg = C.alt_bg, }, -		BufferInactiveSign = {fg = C.gray, bg = C.alt_bg, }, -		BufferInactiveTarget = {fg = C.red, bg = C.alt_bg, style = "bold", }, -		StatusLine = {fg = C.alt_bg, }, -		StatusLineNC = {fg = C.alt_bg, }, -		StatusLineSeparator = {fg = C.alt_bg, }, -		StatusLineTerm = {fg = C.alt_bg, }, -		StatusLineTermNC = {fg = C.alt_bg, }, -		CodiVirtualText = {fg = C.pale_purple, }, -		IndentBlanklineContextChar = {fg = C.accent, }, -		DashboardHeader = {fg = C.blue, }, -		DashboardCenter = {fg = C.purple, }, -		DashboardFooter = {fg = C.cyan, }, -		CompeDocumentation = {bg = C.alt_bg, }, -		DiffViewNormal = {fg = C.gray, bg = C.alt_bg, }, -		DiffviewStatusAdded = {fg = C.sign_add, }, -		DiffviewStatusModified = {fg = C.sign_change, }, -		DiffviewStatusRenamed = {fg = C.sign_change, }, -		DiffviewStatusDeleted = {fg = C.sign_delete, }, -		DiffviewFilePanelInsertion = {fg = C.sign_add, }, -		DiffviewFilePanelDeletion = {fg = C.sign_delete, }, -		DiffviewVertSplit = {bg = C.bg, }, -		diffAdded = {fg = C.sign_add, }, -		diffRemoved = {fg = C.sign_delete, }, -		diffFileId = {fg = C.blue, style = "bold,reverse", }, -		diffFile = {fg = C.alt_bg, }, -		diffNewFile = {fg = C.green, }, -		diffOldFile = {fg = C.red, }, -		debugPc = {bg = C.cyan, }, -		debugBreakpoint = {fg = C.red, style = "reverse", }, +  LspDiagnosticsDefaultError = { fg = C.error_red }, +  LspDiagnosticsDefaultWarning = { fg = C.warning_orange }, +  LspDiagnosticsDefaultInformation = { fg = C.info_yellow }, +  LspDiagnosticsDefaultHint = { fg = C.hint_blue }, +  LspDiagnosticsVirtualTextError = { fg = C.error_red }, +  LspDiagnosticsVirtualTextWarning = { fg = C.warning_orange }, +  LspDiagnosticsVirtualTextInformation = { fg = C.info_yellow }, +  LspDiagnosticsVirtualTextHint = { fg = C.hint_blue }, +  LspDiagnosticsFloatingError = { fg = C.error_red }, +  LspDiagnosticsFloatingWarning = { fg = C.warning_orange }, +  LspDiagnosticsFloatingInformation = { fg = C.info_yellow }, +  LspDiagnosticsFloatingHint = { fg = C.hint_blue }, +  LspDiagnosticsSignError = { fg = C.error_red }, +  LspDiagnosticsSignWarning = { fg = C.warning_orange }, +  LspDiagnosticsSignInformation = { fg = C.info_yellow }, +  LspDiagnosticsSignHint = { fg = C.hint_blue }, +  LspDiagnosticsError = { fg = C.error_red }, +  LspDiagnosticsWarning = { fg = C.warning_orange }, +  LspDiagnosticsInformation = { fg = C.info_yellow }, +  LspDiagnosticsHint = { fg = C.hint_blue }, +  LspDiagnosticsUnderlineError = { fg = C.error_red }, +  LspDiagnosticsUnderlineWarning = { fg = C.warning_orange }, +  LspDiagnosticsUnderlineInformation = { fg = C.info_yellow }, +  LspDiagnosticsUnderlineHint = { fg = C.hint_blue }, +  QuickScopePrimary = { fg = C.cyan_test, style = "underline" }, +  QuickScopeSecondary = { fg = C.purple_test, style = "underline" }, +  TelescopeSelection = { fg = C.hint_blue }, +  TelescopeMatching = { fg = C.info_yellow, style = "bold" }, +  TelescopeBorder = { fg = C.cyan, bg = C.bg }, +  NvimTreeFolderIcon = { fg = C.blue }, +  NvimTreeIndentMarker = { fg = C.gray }, +  NvimTreeNormal = { fg = C.light_gray, bg = C.alt_bg }, +  NvimTreeVertSplit = { fg = C.alt_bg, bg = C.alt_bg }, +  NvimTreeFolderName = { fg = C.blue }, +  NvimTreeOpenedFolderName = { fg = C.cyan, style = "italic" }, +  NvimTreeImageFile = { fg = C.purple }, +  NvimTreeSpecialFile = { fg = C.orange }, +  NvimTreeGitStaged = { fg = C.sign_add }, +  NvimTreeGitNew = { fg = C.sign_add }, +  NvimTreeGitDirty = { fg = C.sign_add }, +  NvimTreeGitDeleted = { fg = C.sign_delete }, +  NvimTreeGitMerge = { fg = C.sign_change }, +  NvimTreeGitRenamed = { fg = C.sign_change }, +  NvimTreeSymlink = { fg = C.cyan }, +  NvimTreeRootFolder = { fg = C.fg, style = "bold" }, +  NvimTreeExecFile = { fg = C.green }, +  BufferCurrent = { fg = C.fg, bg = C.bg }, +  BufferCurrentIndex = { fg = C.fg, bg = C.bg }, +  BufferCurrentMod = { fg = C.info_yellow, bg = C.bg }, +  BufferCurrentSign = { fg = C.hint_blue, bg = C.bg }, +  BufferCurrentTarget = { fg = C.red, bg = C.bg, style = "bold" }, +  BufferVisible = { fg = C.fg, bg = C.bg }, +  BufferVisibleIndex = { fg = C.fg, bg = C.bg }, +  BufferVisibleMod = { fg = C.info_yellow, bg = C.bg }, +  BufferVisibleSign = { fg = C.hint_blue, bg = C.bg }, +  BufferVisibleTarget = { fg = C.red, bg = C.bg, style = "bold" }, +  BufferInactive = { fg = C.gray, bg = C.alt_bg }, +  BufferInactiveIndex = { fg = C.gray, bg = C.alt_bg }, +  BufferInactiveMod = { fg = C.info_yellow, bg = C.alt_bg }, +  BufferInactiveSign = { fg = C.gray, bg = C.alt_bg }, +  BufferInactiveTarget = { fg = C.red, bg = C.alt_bg, style = "bold" }, +  StatusLine = { fg = C.alt_bg }, +  StatusLineNC = { fg = C.alt_bg }, +  StatusLineSeparator = { fg = C.alt_bg }, +  StatusLineTerm = { fg = C.alt_bg }, +  StatusLineTermNC = { fg = C.alt_bg }, +  CodiVirtualText = { fg = C.pale_purple }, +  IndentBlanklineContextChar = { fg = C.accent }, +  DashboardHeader = { fg = C.blue }, +  DashboardCenter = { fg = C.purple }, +  DashboardFooter = { fg = C.cyan }, +  CompeDocumentation = { bg = C.alt_bg }, +  DiffViewNormal = { fg = C.gray, bg = C.alt_bg }, +  DiffviewStatusAdded = { fg = C.sign_add }, +  DiffviewStatusModified = { fg = C.sign_change }, +  DiffviewStatusRenamed = { fg = C.sign_change }, +  DiffviewStatusDeleted = { fg = C.sign_delete }, +  DiffviewFilePanelInsertion = { fg = C.sign_add }, +  DiffviewFilePanelDeletion = { fg = C.sign_delete }, +  DiffviewVertSplit = { bg = C.bg }, +  diffAdded = { fg = C.sign_add }, +  diffRemoved = { fg = C.sign_delete }, +  diffFileId = { fg = C.blue, style = "bold,reverse" }, +  diffFile = { fg = C.alt_bg }, +  diffNewFile = { fg = C.green }, +  diffOldFile = { fg = C.red }, +  debugPc = { bg = C.cyan }, +  debugBreakpoint = { fg = C.red, style = "reverse" },  } -return LSP
\ No newline at end of file +return LSP diff --git a/lua/spacegray/Treesitter.lua b/lua/spacegray/Treesitter.lua index 95348406..01dfacb5 100644 --- a/lua/spacegray/Treesitter.lua +++ b/lua/spacegray/Treesitter.lua @@ -1,56 +1,56 @@  local Treesitter = { -		TSComment = {fg = C.gray, }, -		TSAnnotation = {fg = C.purple, }, -		TSAttribute = {fg = C.cyan, }, -		TSConstructor = {fg = C.purple, }, -		TSType = {fg = C.purple, }, -		TSTypeBuiltin = {fg = C.purple, }, -		TSConditional = {fg = C.blue, }, -		TSException = {fg = C.blue, }, -		TSInclude = {fg = C.blue, }, -		TSKeyword = {fg = C.blue, }, -		TSKeywordFunction = {fg = C.blue, }, -		TSLabel = {fg = C.blue, }, -		TSNamespace = {fg = C.blue, }, -		TSRepeat = {fg = C.blue, }, -		TSConstant = {fg = C.orange, }, -		TSConstBuiltin = {fg = C.orange, }, -		TSFloat = {fg = C.red, }, -		TSNumber = {fg = C.red, }, -		TSBoolean = {fg = C.red, }, -		TSCharacter = {fg = C.light_green, }, -		TSError = {fg = C.error_red, }, -		TSFunction = {fg = C.yellow, }, -		TSFuncBuiltin = {fg = C.yellow, }, -		TSMethod = {fg = C.yellow, }, -		TSConstMacro = {fg = C.cyan, }, -		TSFuncMacro = {fg = C.cyan, }, -		TSVariable = {fg = C.white, }, -		TSVariableBuiltin = {fg = C.cyan, }, -		TSProperty = {fg = C.cyan, }, -		TSOperator = {fg = C.gray_blue, }, -		TSField = {fg = C.white, }, -		TSParameter = {fg = C.white, }, -		TSParameterReference = {fg = C.white, }, -		TSSymbol = {fg = C.white, }, -		TSText = {fg = C.fg, }, -		TSPunctDelimiter = {fg = C.gray, }, -		TSTagDelimiter = {fg = C.gray, }, -		TSPunctBracket = {fg = C.gray, }, -		TSPunctSpecial = {fg = C.gray, }, -		TSString = {fg = C.green, }, -		TSStringRegex = {fg = C.light_green, }, -		TSStringEscape = {fg = C.light_green, }, -		TSTag = {fg = C.blue, }, -		TSEmphasis = {style = "italic", }, -		TSUnderline = {style = "underline", }, -		TSTitle = {fg = C.blue, style = "bold", }, -		TSLiteral = {fg = C.green, }, -		TSURI = {fg = C.cyan, style = "underline", }, -		TSKeywordOperator = {fg = C.blue, }, -		TSStructure = {fg = C.purple_test, }, -		TSStrong = {fg = C.yellow, }, -		TSQueryLinterError = {fg = C.warning_orange, }, +  TSComment = { fg = C.gray }, +  TSAnnotation = { fg = C.purple }, +  TSAttribute = { fg = C.cyan }, +  TSConstructor = { fg = C.purple }, +  TSType = { fg = C.purple }, +  TSTypeBuiltin = { fg = C.purple }, +  TSConditional = { fg = C.blue }, +  TSException = { fg = C.blue }, +  TSInclude = { fg = C.blue }, +  TSKeyword = { fg = C.blue }, +  TSKeywordFunction = { fg = C.blue }, +  TSLabel = { fg = C.blue }, +  TSNamespace = { fg = C.blue }, +  TSRepeat = { fg = C.blue }, +  TSConstant = { fg = C.orange }, +  TSConstBuiltin = { fg = C.orange }, +  TSFloat = { fg = C.red }, +  TSNumber = { fg = C.red }, +  TSBoolean = { fg = C.red }, +  TSCharacter = { fg = C.light_green }, +  TSError = { fg = C.error_red }, +  TSFunction = { fg = C.yellow }, +  TSFuncBuiltin = { fg = C.yellow }, +  TSMethod = { fg = C.yellow }, +  TSConstMacro = { fg = C.cyan }, +  TSFuncMacro = { fg = C.cyan }, +  TSVariable = { fg = C.white }, +  TSVariableBuiltin = { fg = C.cyan }, +  TSProperty = { fg = C.cyan }, +  TSOperator = { fg = C.gray_blue }, +  TSField = { fg = C.white }, +  TSParameter = { fg = C.white }, +  TSParameterReference = { fg = C.white }, +  TSSymbol = { fg = C.white }, +  TSText = { fg = C.fg }, +  TSPunctDelimiter = { fg = C.gray }, +  TSTagDelimiter = { fg = C.gray }, +  TSPunctBracket = { fg = C.gray }, +  TSPunctSpecial = { fg = C.gray }, +  TSString = { fg = C.green }, +  TSStringRegex = { fg = C.light_green }, +  TSStringEscape = { fg = C.light_green }, +  TSTag = { fg = C.blue }, +  TSEmphasis = { style = "italic" }, +  TSUnderline = { style = "underline" }, +  TSTitle = { fg = C.blue, style = "bold" }, +  TSLiteral = { fg = C.green }, +  TSURI = { fg = C.cyan, style = "underline" }, +  TSKeywordOperator = { fg = C.blue }, +  TSStructure = { fg = C.purple_test }, +  TSStrong = { fg = C.yellow }, +  TSQueryLinterError = { fg = C.warning_orange },  } -return Treesitter
\ No newline at end of file +return Treesitter diff --git a/lua/spacegray/Whichkey.lua b/lua/spacegray/Whichkey.lua index 2c02f11b..f382d784 100644 --- a/lua/spacegray/Whichkey.lua +++ b/lua/spacegray/Whichkey.lua @@ -1,9 +1,9 @@  local Whichkey = { -		WhichKey = {fg = C.purple, }, -		WhichKeySeperator = {fg = C.green, }, -		WhichKeyGroup = {fg = C.blue, }, -		WhichKeyDesc = {fg = C.cyan, }, -		WhichKeyFloat = {bg = C.alt_bg, }, +  WhichKey = { fg = C.purple }, +  WhichKeySeperator = { fg = C.green }, +  WhichKeyGroup = { fg = C.blue }, +  WhichKeyDesc = { fg = C.cyan }, +  WhichKeyFloat = { bg = C.alt_bg },  } -return Whichkey
\ No newline at end of file +return Whichkey diff --git a/lua/spacegray/config.lua b/lua/spacegray/config.lua index f9c10951..ebac7109 100644 --- a/lua/spacegray/config.lua +++ b/lua/spacegray/config.lua @@ -3,21 +3,21 @@ local config  vim = vim or { g = {}, o = {} }  local function opt(key, default) -    if vim.g[key] == nil then -        return default -    end -    if vim.g[key] == 0 then -        return false -    end -    return vim.g[key] +  if vim.g[key] == nil then +    return default +  end +  if vim.g[key] == 0 then +    return false +  end +  return vim.g[key]  end  config = { -    transparent_background = opt("transparent_background", false), -    italic_comments = opt("italic_keywords", true) and "italic" or "NONE", -    italic_keywords = opt("italic_keywords", true) and "italic" or "NONE", -    italic_functions = opt("italic_function", false) and "italic" or "NONE", -    italic_variables = opt("italic_variables", true) and "italic" or "NONE", +  transparent_background = opt("transparent_background", false), +  italic_comments = opt("italic_keywords", true) and "italic" or "NONE", +  italic_keywords = opt("italic_keywords", true) and "italic" or "NONE", +  italic_functions = opt("italic_function", false) and "italic" or "NONE", +  italic_variables = opt("italic_variables", true) and "italic" or "NONE",  } -return config
\ No newline at end of file +return config diff --git a/lua/spacegray/highlights.lua b/lua/spacegray/highlights.lua index 9a20b46d..e8700d8f 100644 --- a/lua/spacegray/highlights.lua +++ b/lua/spacegray/highlights.lua @@ -1,99 +1,99 @@  local highlights = { -		Normal = {fg = C.fg, bg = Config.transparent_background and "NONE" or C.bg, }, -		SignColumn = {bg = C.bg, }, -		MsgArea = {fg = C.fg, bg = C.bg, }, -		ModeMsg = {fg = C.fg, bg = C.bg, }, -		MsgSeparator = {fg = C.fg, bg = C.bg, }, -		SpellBad = {fg = C.error_red, style = "underline", }, -		SpellCap = {fg = C.yellow, style = "underline", }, -		SpellLocal = {fg = C.green, style = "underline", }, -		SpellRare = {fg = C.purple, style = "underline", }, -		NormalNC = {fg = C.fg, bg = C.bg, }, -		Pmenu = {fg = C.white, bg = C.accent, }, -		PmenuSel = {fg = C.alt_bg, bg = C.blue, }, -		WildMenu = {fg = C.alt_bg, bg = C.blue, }, -		CursorLineNr = {fg = C.light_gray, style = "bold", }, -		Comment = {fg = C.gray, style = "italic", }, -		Folded = {fg = C.accent, bg = C.alt_bg, }, -		FoldColumn = {fg = C.accent, bg = C.alt_bg, }, -		LineNr = {fg = C.gray, }, -		FloatBoder = {fg = C.gray, bg = C.alt_bg, }, -		Whitespace = {fg = C.gray, }, -		VertSplit = {fg = C.bg, bg = C.accent, }, -		CursorLine = {bg = C.alt_bg, }, -		CursorColumn = {bg = C.alt_bg, }, -		ColorColumn = {bg = C.alt_bg, }, -		NormalFloat = {bg = C.alt_bg, }, -		Visual = {bg = C.alt_bg, }, -		VisualNOS = {bg = C.alt_bg, }, -		WarningMsg = {fg = C.error_red, bg = C.bg, }, -		DiffAdd = {fg = C.alt_bg, bg = C.sign_add, }, -		DiffChange = {fg = C.alt_bg, bg = C.sign_change, style = "underline", }, -		DiffDelete = {fg = C.alt_bg, bg = C.sign_delete, }, -		QuickFixLine = {bg = C.accent, }, -		PmenuSbar = {bg = C.alt_bg, }, -		PmenuThumb = {bg = C.white, }, -		MatchWord = {style = "underline", }, -		MatchParen = {fg = C.pale_purple, bg = C.bg, style = "underline", }, -		MatchWordCur = {style = "underline", }, -		MatchParenCur = {style = "underline", }, -		Cursor = {fg = C.cursor_fg, bg = C.cursor_bg, }, -		lCursor = {fg = C.cursor_fg, bg = C.cursor_bg, }, -		CursorIM = {fg = C.cursor_fg, bg = C.cursor_bg, }, -		TermCursor = {fg = C.cursor_fg, bg = C.cursor_bg, }, -		TermCursorNC = {fg = C.cursor_fg, bg = C.cursor_bg, }, -		Conceal = {fg = C.accent, }, -		Directory = {fg = C.blue, }, -		SpecialKey = {fg = C.blue, style = "bold", }, -		Title = {fg = C.blue, style = "bold", }, -		ErrorMsg = {fg = C.error_red, bg = C.bg, style = "bold", }, -		Search = {fg = C.hint_blue, bg = C.alt_bg, }, -		IncSearch = {fg = C.hint_blue, bg = C.alt_bg, }, -		Substitute = {fg = C.alt_bg, bg = C.gray_blue, }, -		MoreMsg = {fg = C.cyan, }, -		Question = {fg = C.cyan, }, -		EndOfBuffer = {fg = C.bg, }, -		NonText = {fg = C.bg, }, -		Variable = {fg = C.white, }, -		String = {fg = C.green, }, -		Character = {fg = C.light_green, }, -		Constant = {fg = C.orange, }, -		Number = {fg = C.red, }, -		Boolean = {fg = C.red, }, -		Float = {fg = C.red, }, -		Identifier = {fg = C.white, }, -		Function = {fg = C.yellow, }, -		Operator = {fg = C.gray_blue, }, -		Type = {fg = C.purple, }, -		StorageClass = {fg = C.purple, }, -		Structure = {fg = C.purple, }, -		Typedef = {fg = C.purple, }, -		Keyword = {fg = C.blue, }, -		Statement = {fg = C.blue, }, -		Conditional = {fg = C.blue, }, -		Repeat = {fg = C.blue, }, -		Label = {fg = C.blue, }, -		Exception = {fg = C.blue, }, -		Include = {fg = C.blue, }, -		PreProc = {fg = C.cyan, }, -		Define = {fg = C.cyan, }, -		Macro = {fg = C.cyan, }, -		PreCondit = {fg = C.cyan, }, -		Special = {fg = C.orange, }, -		SpecialChar = {fg = C.orange, }, -		Tag = {fg = C.blue, }, -		Debug = {fg = C.red, }, -		Delimiter = {fg = C.gray, }, -		SpecialComment = {fg = C.gray, }, -		Underlined = {style = "underline", }, -		Bold = {style = "bold", }, -		Italic = {style = "italic", }, -		Ignore = {fg = C.cyan, bg = C.bg, style = "bold", }, -		Todo = {fg = C.red, bg = C.bg, style = "bold", }, -		Error = {fg = C.error_red, bg = C.bg, style = "bold", }, -		TabLine = {fg = C.white, bg = C.alt_bg, }, -		TabLineSel = {fg = C.white, bg = C.alt_bg, }, -		TabLineFill = {fg = C.white, bg = C.alt_bg, }, +  Normal = { fg = C.fg, bg = Config.transparent_background and "NONE" or C.bg }, +  SignColumn = { bg = C.bg }, +  MsgArea = { fg = C.fg, bg = C.bg }, +  ModeMsg = { fg = C.fg, bg = C.bg }, +  MsgSeparator = { fg = C.fg, bg = C.bg }, +  SpellBad = { fg = C.error_red, style = "underline" }, +  SpellCap = { fg = C.yellow, style = "underline" }, +  SpellLocal = { fg = C.green, style = "underline" }, +  SpellRare = { fg = C.purple, style = "underline" }, +  NormalNC = { fg = C.fg, bg = C.bg }, +  Pmenu = { fg = C.white, bg = C.accent }, +  PmenuSel = { fg = C.alt_bg, bg = C.blue }, +  WildMenu = { fg = C.alt_bg, bg = C.blue }, +  CursorLineNr = { fg = C.light_gray, style = "bold" }, +  Comment = { fg = C.gray, style = "italic" }, +  Folded = { fg = C.accent, bg = C.alt_bg }, +  FoldColumn = { fg = C.accent, bg = C.alt_bg }, +  LineNr = { fg = C.gray }, +  FloatBorder = { fg = C.gray, bg = C.alt_bg }, +  Whitespace = { fg = C.gray }, +  VertSplit = { fg = C.bg, bg = C.accent }, +  CursorLine = { bg = C.alt_bg }, +  CursorColumn = { bg = C.alt_bg }, +  ColorColumn = { bg = C.alt_bg }, +  NormalFloat = { bg = C.alt_bg }, +  Visual = { bg = C.alt_bg }, +  VisualNOS = { bg = C.alt_bg }, +  WarningMsg = { fg = C.warning_orange, bg = C.bg }, +  DiffAdd = { fg = C.alt_bg, bg = C.sign_add }, +  DiffChange = { fg = C.alt_bg, bg = C.sign_change, style = "underline" }, +  DiffDelete = { fg = C.alt_bg, bg = C.sign_delete }, +  QuickFixLine = { bg = C.accent }, +  PmenuSbar = { bg = C.alt_bg }, +  PmenuThumb = { bg = C.white }, +  MatchWord = { style = "underline" }, +  MatchParen = { fg = C.pale_purple, bg = C.bg, style = "underline" }, +  MatchWordCur = { style = "underline" }, +  MatchParenCur = { style = "underline" }, +  Cursor = { fg = C.cursor_fg, bg = C.cursor_bg }, +  lCursor = { fg = C.cursor_fg, bg = C.cursor_bg }, +  CursorIM = { fg = C.cursor_fg, bg = C.cursor_bg }, +  TermCursor = { fg = C.cursor_fg, bg = C.cursor_bg }, +  TermCursorNC = { fg = C.cursor_fg, bg = C.cursor_bg }, +  Conceal = { fg = C.accent }, +  Directory = { fg = C.blue }, +  SpecialKey = { fg = C.blue, style = "bold" }, +  Title = { fg = C.blue, style = "bold" }, +  ErrorMsg = { fg = C.error_red, bg = C.bg, style = "bold" }, +  Search = { fg = C.hint_blue, bg = C.alt_bg }, +  IncSearch = { fg = C.hint_blue, bg = C.alt_bg }, +  Substitute = { fg = C.alt_bg, bg = C.gray_blue }, +  MoreMsg = { fg = C.cyan }, +  Question = { fg = C.cyan }, +  EndOfBuffer = { fg = C.bg }, +  NonText = { fg = C.bg }, +  Variable = { fg = C.white }, +  String = { fg = C.green }, +  Character = { fg = C.light_green }, +  Constant = { fg = C.orange }, +  Number = { fg = C.red }, +  Boolean = { fg = C.red }, +  Float = { fg = C.red }, +  Identifier = { fg = C.white }, +  Function = { fg = C.yellow }, +  Operator = { fg = C.gray_blue }, +  Type = { fg = C.purple }, +  StorageClass = { fg = C.purple }, +  Structure = { fg = C.purple }, +  Typedef = { fg = C.purple }, +  Keyword = { fg = C.blue }, +  Statement = { fg = C.blue }, +  Conditional = { fg = C.blue }, +  Repeat = { fg = C.blue }, +  Label = { fg = C.blue }, +  Exception = { fg = C.blue }, +  Include = { fg = C.blue }, +  PreProc = { fg = C.cyan }, +  Define = { fg = C.cyan }, +  Macro = { fg = C.cyan }, +  PreCondit = { fg = C.cyan }, +  Special = { fg = C.orange }, +  SpecialChar = { fg = C.orange }, +  Tag = { fg = C.blue }, +  Debug = { fg = C.red }, +  Delimiter = { fg = C.gray }, +  SpecialComment = { fg = C.gray }, +  Underlined = { style = "underline" }, +  Bold = { style = "bold" }, +  Italic = { style = "italic" }, +  Ignore = { fg = C.cyan, bg = C.bg, style = "bold" }, +  Todo = { fg = C.red, bg = C.bg, style = "bold" }, +  Error = { fg = C.error_red, bg = C.bg, style = "bold" }, +  TabLine = { fg = C.white, bg = C.alt_bg }, +  TabLineSel = { fg = C.white, bg = C.alt_bg }, +  TabLineFill = { fg = C.white, bg = C.alt_bg },  } -return highlights
\ No newline at end of file +return highlights diff --git a/lua/spacegray/init.lua b/lua/spacegray/init.lua index 0a8e748e..8da13a06 100644 --- a/lua/spacegray/init.lua +++ b/lua/spacegray/init.lua @@ -1,26 +1,30 @@ -vim.api.nvim_command("hi clear") -if vim.fn.exists("syntax_on") then -    vim.api.nvim_command("syntax reset") +vim.api.nvim_command "hi clear" +if vim.fn.exists "syntax_on" then +  vim.api.nvim_command "syntax reset"  end  vim.o.background = "dark"  vim.o.termguicolors = true  vim.g.colors_name = "spacegray" -local util = require("spacegray.util") -Config = require("spacegray.config") -C = require("spacegray.palette") -local highlights = require("spacegray.highlights") -local Treesitter = require("spacegray.Treesitter") -local markdown = require("spacegray.markdown") -local Whichkey = require("spacegray.Whichkey") -local Git = require("spacegray.Git") -local LSP = require("spacegray.LSP") - +local util = require "spacegray.util" +Config = require "spacegray.config" +C = require "spacegray.palette" +local highlights = require "spacegray.highlights" +local Treesitter = require "spacegray.Treesitter" +local markdown = require "spacegray.markdown" +local Whichkey = require "spacegray.Whichkey" +local Git = require "spacegray.Git" +local LSP = require "spacegray.LSP"  local skeletons = { -    highlights, Treesitter, markdown, Whichkey, Git, LSP +  highlights, +  Treesitter, +  markdown, +  Whichkey, +  Git, +  LSP,  }  for _, skeleton in ipairs(skeletons) do -    util.initialise(skeleton) -end
\ No newline at end of file +  util.initialise(skeleton) +end diff --git a/lua/spacegray/markdown.lua b/lua/spacegray/markdown.lua index 19863dc8..2b83e056 100644 --- a/lua/spacegray/markdown.lua +++ b/lua/spacegray/markdown.lua @@ -1,27 +1,27 @@  local markdown = { -		markdownBlockquote = {fg = C.accent, }, -		markdownBold = {fg = C.yellow, style = "bold", }, -		markdownCode = {fg = C.green, }, -		markdownCodeBlock = {fg = C.green, }, -		markdownCodeDelimiter = {fg = C.green, }, -		markdownH1 = {fg = C.blue, }, -		markdownH2 = {fg = C.blue, }, -		markdownH3 = {fg = C.blue, }, -		markdownH4 = {fg = C.blue, }, -		markdownH5 = {fg = C.blue, }, -		markdownH6 = {fg = C.blue, }, -		markdownHeadingDelimiter = {fg = C.red, }, -		markdownHeadingRule = {fg = C.accent, }, -		markdownId = {fg = C.purple, }, -		markdownIdDeclaration = {fg = C.blue, }, -		markdownIdDelimiter = {fg = C.light_gray, }, -		markdownLinkDelimiter = {fg = C.light_gray, }, -		markdownItalic = {style = "italic", }, -		markdownLinkText = {fg = C.blue, }, -		markdownListMarker = {fg = C.red, }, -		markdownOrderedListMarker = {fg = C.red, }, -		markdownRule = {fg = C.accent, }, -		markdownUrl = {fg = C.cyan, style = "underline", }, +  markdownBlockquote = { fg = C.accent }, +  markdownBold = { fg = C.yellow, style = "bold" }, +  markdownCode = { fg = C.green }, +  markdownCodeBlock = { fg = C.green }, +  markdownCodeDelimiter = { fg = C.green }, +  markdownH1 = { fg = C.blue }, +  markdownH2 = { fg = C.blue }, +  markdownH3 = { fg = C.blue }, +  markdownH4 = { fg = C.blue }, +  markdownH5 = { fg = C.blue }, +  markdownH6 = { fg = C.blue }, +  markdownHeadingDelimiter = { fg = C.red }, +  markdownHeadingRule = { fg = C.accent }, +  markdownId = { fg = C.purple }, +  markdownIdDeclaration = { fg = C.blue }, +  markdownIdDelimiter = { fg = C.light_gray }, +  markdownLinkDelimiter = { fg = C.light_gray }, +  markdownItalic = { style = "italic" }, +  markdownLinkText = { fg = C.blue }, +  markdownListMarker = { fg = C.red }, +  markdownOrderedListMarker = { fg = C.red }, +  markdownRule = { fg = C.accent }, +  markdownUrl = { fg = C.cyan, style = "underline" },  } -return markdown
\ No newline at end of file +return markdown diff --git a/lua/spacegray/util.lua b/lua/spacegray/util.lua index 1cc5a009..dbac18a2 100644 --- a/lua/spacegray/util.lua +++ b/lua/spacegray/util.lua @@ -1,22 +1,25 @@  local M = {}  local function highlight(group, properties) -    local bg = properties.bg == nil and "" or "guibg=" .. properties.bg -    local fg = properties.fg == nil and "" or "guifg=" .. properties.fg -    local style = properties.style == nil and "" or "gui=" .. properties.style +  local bg = properties.bg == nil and "" or "guibg=" .. properties.bg +  local fg = properties.fg == nil and "" or "guifg=" .. properties.fg +  local style = properties.style == nil and "" or "gui=" .. properties.style -    local cmd = table.concat({ -        "highlight", group, bg, fg, style -    }, " ") +  local cmd = table.concat({ +    "highlight", +    group, +    bg, +    fg, +    style, +  }, " ") -    vim.api.nvim_command(cmd) +  vim.api.nvim_command(cmd)  end -  function M.initialise(skeleton) -    for group, properties in pairs(skeleton) do -        highlight(group, properties) -    end +  for group, properties in pairs(skeleton) do +    highlight(group, properties) +  end  end -return M
\ No newline at end of file +return M diff --git a/lua/utils/init.lua b/lua/utils/init.lua new file mode 100644 index 00000000..94058487 --- /dev/null +++ b/lua/utils/init.lua @@ -0,0 +1,149 @@ +local utils = {} + +-- recursive Print (structure, limit, separator) +local function r_inspect_settings(structure, limit, separator) +  limit = limit or 100 -- default item limit +  separator = separator or "." -- indent string +  if limit < 1 then +    print "ERROR: Item limit reached." +    return limit - 1 +  end +  if structure == nil then +    io.write("-- O", separator:sub(2), " = nil\n") +    return limit - 1 +  end +  local ts = type(structure) + +  if ts == "table" then +    for k, v in pairs(structure) do +      -- replace non alpha keys wih ["key"] +      if tostring(k):match "[^%a_]" then +        k = '["' .. tostring(k) .. '"]' +      end +      limit = r_inspect_settings(v, limit, separator .. "." .. tostring(k)) +      if limit < 0 then +        break +      end +    end +    return limit +  end + +  if ts == "string" then +    -- escape sequences +    structure = string.format("%q", structure) +  end +  separator = separator:gsub("%.%[", "%[") +  if type(structure) == "function" then +    -- don't print functions +    io.write("-- lvim", separator:sub(2), " = function ()\n") +  else +    io.write("lvim", separator:sub(2), " = ", tostring(structure), "\n") +  end +  return limit - 1 +end + +function utils.generate_settings() +  -- Opens a file in append mode +  local file = io.open("lv-settings.lua", "w") + +  -- sets the default output file as test.lua +  io.output(file) + +  -- write all `lvim` related settings to `lv-settings.lua` file +  r_inspect_settings(lvim, 10000, ".") + +  -- closes the open file +  io.close(file) +end + +-- autoformat +function utils.toggle_autoformat() +  if lvim.format_on_save then +    require("core.autocmds").define_augroups { +      autoformat = { +        { +          "BufWritePre", +          "*", +          ":silent lua vim.lsp.buf.formatting_sync()", +        }, +      }, +    } +  end + +  if not lvim.format_on_save then +    vim.cmd [[ +      if exists('#autoformat#BufWritePre') +        :autocmd! autoformat +      endif +    ]] +  end +end + +function utils.reload_lv_config() +  vim.cmd "source ~/.local/share/lunarvim/lvim/lua/settings.lua" +  vim.cmd "source ~/.config/lvim/lv-config.lua" +  vim.cmd "source ~/.local/share/lunarvim/lvim/lua/plugins.lua" +  local plugins = require "plugins" +  local plugin_loader = require("plugin-loader").init() +  utils.toggle_autoformat() +  plugin_loader:load { plugins, lvim.plugins } +  vim.cmd ":PackerCompile" +  vim.cmd ":PackerInstall" +  -- vim.cmd ":PackerClean" +end + +function utils.check_lsp_client_active(name) +  local clients = vim.lsp.get_active_clients() +  for _, client in pairs(clients) do +    if client.name == name then +      return true +    end +  end +  return false +end + +function utils.add_keymap(mode, opts, keymaps) +  for _, keymap in ipairs(keymaps) do +    vim.api.nvim_set_keymap(mode, keymap[1], keymap[2], opts) +  end +end + +function utils.add_keymap_normal_mode(opts, keymaps) +  utils.add_keymap("n", opts, keymaps) +end + +function utils.add_keymap_visual_mode(opts, keymaps) +  utils.add_keymap("v", opts, keymaps) +end + +function utils.add_keymap_visual_block_mode(opts, keymaps) +  utils.add_keymap("x", opts, keymaps) +end + +function utils.add_keymap_insert_mode(opts, keymaps) +  utils.add_keymap("i", opts, keymaps) +end + +function utils.add_keymap_term_mode(opts, keymaps) +  utils.add_keymap("t", opts, keymaps) +end + +function utils.unrequire(m) +  package.loaded[m] = nil +  _G[m] = nil +end + +function utils.gsub_args(args) +  if args == nil or type(args) ~= "table" then +    return args +  end +  local buffer_filepath = vim.fn.fnameescape(vim.api.nvim_buf_get_name(0)) +  for i = 1, #args do +    args[i] = string.gsub(args[i], "${FILEPATH}", buffer_filepath) +  end +  return args +end + +return utils + +-- TODO: find a new home for these autocommands diff --git a/utils/bin/jdtls b/utils/bin/jdtls index cc73e59f..adfd5e20 100755 --- a/utils/bin/jdtls +++ b/utils/bin/jdtls @@ -8,32 +8,31 @@  # to point to the `config_mac' or `config_win` folders depending on your system.  case Darwin in -  Linux) -    CONFIG="$HOME/.local/share/nvim/lspinstall/java/config_linux" -    ;; -  Darwin) -    CONFIG="$HOME/.local/share/nvim/lspinstall/java/config_mac" -    ;; +Linux) +	CONFIG="$HOME/.local/share/nvim/lspinstall/java/config_linux" +	;; +Darwin) +	CONFIG="$HOME/.local/share/nvim/lspinstall/java/config_mac" +	;;  esac -  # Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then -    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then -        # IBM's JDK on AIX uses strange locations for the executables -        JAVACMD="$JAVA_HOME/jre/sh/java" -    else -        JAVACMD="$JAVA_HOME/bin/java" -    fi -    if [ ! -x "$JAVACMD" ] ; then -        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME +if [ -n "$JAVA_HOME" ]; then +	if [ -x "$JAVA_HOME/jre/sh/java" ]; then +		# IBM's JDK on AIX uses strange locations for the executables +		JAVACMD="$JAVA_HOME/jre/sh/java" +	else +		JAVACMD="$JAVA_HOME/bin/java" +	fi +	if [ ! -x "$JAVACMD" ]; then +		die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME  Please set the JAVA_HOME variable in your environment to match the  location of your Java installation." -    fi +	fi  else -    JAVACMD="java" -    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +	JAVACMD="java" +	which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.  Please set the JAVA_HOME variable in your environment to match the  location of your Java installation." @@ -42,22 +41,22 @@ 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/.local/share/nvim/lspinstall/java/plugins/org.eclipse.equinox.launcher_*.jar"  GRADLE_HOME=$HOME/gradle "$JAVACMD" \ -  -Declipse.application=org.eclipse.jdt.ls.core.id1 \ -  -Dosgi.bundles.defaultStartLevel=4 \ -  -Declipse.product=org.eclipse.jdt.ls.core.product \ -  -Dlog.protocol=true \ -  -Dlog.level=ALL \ -  -javaagent:$HOME/.local/share/nvim/lspinstall/java/lombok.jar \ -  -Xms1g \ -  -Xmx2G \ -  -jar $(echo "$JAR") \ -  -configuration "$CONFIG" \ -  -data "${1:-$HOME/workspace}" \ -  --add-modules=ALL-SYSTEM \ -  --add-opens java.base/java.util=ALL-UNNAMED \ -  --add-opens java.base/java.lang=ALL-UNNAMED - -  # for older java versions if you wanna use lombok -  # -Xbootclasspath/a:/usr/local/share/lombok/lombok.jar \ - -  # -javaagent:/usr/local/share/lombok/lombok.jar \ +	-Declipse.application=org.eclipse.jdt.ls.core.id1 \ +	-Dosgi.bundles.defaultStartLevel=4 \ +	-Declipse.product=org.eclipse.jdt.ls.core.product \ +	-Dlog.protocol=true \ +	-Dlog.level=ALL \ +	-javaagent:$HOME/.local/share/nvim/lspinstall/java/lombok.jar \ +	-Xms1g \ +	-Xmx2G \ +	-jar $(echo "$JAR") \ +	-configuration "$CONFIG" \ +	-data "${1:-$HOME/workspace}" \ +	--add-modules=ALL-SYSTEM \ +	--add-opens java.base/java.util=ALL-UNNAMED \ +	--add-opens java.base/java.lang=ALL-UNNAMED + +# for older java versions if you wanna use lombok +# -Xbootclasspath/a:/usr/local/share/lombok/lombok.jar \ + +# -javaagent:/usr/local/share/lombok/lombok.jar \ diff --git a/utils/bin/lvim b/utils/bin/lvim new file mode 100755 index 00000000..0ef96a90 --- /dev/null +++ b/utils/bin/lvim @@ -0,0 +1,3 @@ +#!/bin/sh + +nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" "$@" diff --git a/utils/desktop/lvim.desktop b/utils/desktop/lvim.desktop new file mode 100644 index 00000000..f4a51b10 --- /dev/null +++ b/utils/desktop/lvim.desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +Name=LunarVim +GenericName=Text Editor +Comment=An IDE layer for Neovim with sane defaults. Completely free and community driven. +TryExec=lvim +Exec=lvim %F +Terminal=false +Type=Application +Keywords=Text;editor; +Icon=nvim +Categories=Utility;TextEditor; +StartupNotify=false +MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++; diff --git a/utils/installer/install.sh b/utils/installer/install.sh index 0473bbab..5778fb3a 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -5,219 +5,235 @@ set -o nounset # error when referencing undefined variable  set -o errexit # exit when command fails  installnodemac() { -    brew install lua -    brew install node -    brew install yarn +	brew install lua +	brew install node +	brew install yarn  }  installnodeubuntu() { -    sudo apt install nodejs -    sudo apt install npm +	sudo apt install nodejs +	sudo apt install npm  } -moveoldnvim() { -    echo "Not installing LunarVim" -    echo "Please move your ~/.config/nvim folder before installing" -    exit +moveoldlvim() { +	echo "Not installing LunarVim" +	echo "Please move your ~/.local/share/lunarvim folder before installing" +	exit  }  installnodearch() { -    sudo pacman -S nodejs -    sudo pacman -S npm +	sudo pacman -S nodejs +	sudo pacman -S npm  }  installnodefedora() { -    sudo dnf install -y nodejs -    sudo dnf install -y npm +	sudo dnf install -y nodejs +	sudo dnf install -y npm  }  installnodegentoo() { -    echo "Printing current node status..." -    emerge -pqv net-libs/nodejs -    echo "Make sure the npm USE flag is enabled for net-libs/nodejs" -    echo "If it isn't enabled, would you like to enable it with flaggie? (Y/N)" -    read answer -    [ "$answer" != "${answer#[Yy]}" ] && sudo flaggie net-libs/nodejs +npm -    sudo emerge -avnN net-libs/nodejs +	echo "Printing current node status..." +	emerge -pqv net-libs/nodejs +	echo "Make sure the npm USE flag is enabled for net-libs/nodejs" +	echo "If it isn't enabled, would you like to enable it with flaggie? (Y/N)" +	read -r answer +	[ "$answer" != "${answer#[Yy]}" ] && sudo flaggie net-libs/nodejs +npm +	sudo emerge -avnN net-libs/nodejs  }  installnode() { -    echo "Installing node..." -    [ "$(uname)" == "Darwin" ] && installnodemac -    [ -n "$(cat /etc/os-release | grep Ubuntu)" ] && installnodeubuntu -    [ -f "/etc/arch-release" ] && installnodearch -    [ -f "/etc/artix-release" ] && installnodearch -    [ -f "/etc/fedora-release" ] && installnodefedora -    [ -f "/etc/gentoo-release" ] && installnodegentoo -    [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ] && echo "Windows not currently supported" -    sudo npm i -g neovim +	echo "Installing node..." +	[ "$(uname)" = "Darwin" ] && installnodemac +	grep -q Ubuntu /etc/os-release && installnodeubuntu +	[ -f "/etc/arch-release" ] && installnodearch +	[ -f "/etc/artix-release" ] && installnodearch +	[ -f "/etc/fedora-release" ] && installnodefedora +	[ -f "/etc/gentoo-release" ] && installnodegentoo +	[ "$(uname -s | cut -c 1-10)" = "MINGW64_NT" ] && echo "Windows not currently supported" +	sudo npm i -g neovim  }  installpiponmac() { -    sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py -    python3 get-pip.py -    rm get-pip.py +	sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py +	python3 get-pip.py +	rm get-pip.py  }  installpiponubuntu() { -    sudo apt install python3-pip >/dev/null +	sudo apt install python3-pip >/dev/null  }  installpiponarch() { -    sudo pacman -S python-pip +	sudo pacman -S python-pip  }  installpiponfedora() { -    sudo dnf install -y pip >/dev/nul +	sudo dnf install -y pip >/dev/null  }  installpipongentoo() { -    sudo emerge -avn dev-python/pip +	sudo emerge -avn dev-python/pip  }  installpip() { -    echo "Installing pip..." -    [ "$(uname)" == "Darwin" ] && installpiponmac -    [ -n "$(cat /etc/os-release | grep Ubuntu)" ] && installpiponubuntu -    [ -f "/etc/arch-release" ] && installpiponarch -    [ -f "/etc/fedora-release" ] && installpiponfedora -    [ -f "/etc/gentoo-release" ] && installpipongentoo -    [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ] && echo "Windows not currently supported" +	echo "Installing pip..." +	[ "$(uname)" = "Darwin" ] && installpiponmac +	grep -q Ubuntu /etc/os-release && installpiponubuntu +	[ -f "/etc/arch-release" ] && installpiponarch +	[ -f "/etc/fedora-release" ] && installpiponfedora +	[ -f "/etc/gentoo-release" ] && installpipongentoo +	[ "$(uname -s | cut -c 1-10)" = "MINGW64_NT" ] && echo "Windows not currently supported"  }  installpynvim() { -    echo "Installing pynvim..." -    if [ -f "/etc/gentoo-release" ]; then -        echo "Installing using Portage" -        sudo emerge -avn dev-python/pynvim -    else -        pip3 install pynvim --user -    fi +	echo "Installing pynvim..." +	if [ -f "/etc/gentoo-release" ]; then +		echo "Installing using Portage" +		sudo emerge -avn dev-python/pynvim +	else +		pip3 install pynvim --user +	fi  }  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() { -    echo "Cloning LunarVim configuration" -    git clone --branch $LVBRANCH https://github.com/ChristianChiarulli/lunarvim.git ~/.config/nvim -    cp $HOME/.config/nvim/utils/installer/lv-config.example-no-ts.lua $HOME/.config/nvim/lv-config.lua -    nvim --headless \ -        +'autocmd User PackerComplete sleep 100m | qall' \ -        +PackerInstall +	echo "Cloning LunarVim configuration" +	mkdir -p ~/.local/share/lunarvim +	case "$@" in -    nvim --headless \ -        +'autocmd User PackerComplete sleep 100m | qall' \ -        +PackerSync +	*--testing*) +		cp -r "$(pwd)" ~/.local/share/lunarvim/lvim +		;; +	*) +		git clone --branch "$LVBRANCH" https://github.com/ChristianChiarulli/lunarvim.git ~/.local/share/lunarvim/lvim +		;; +	esac +	mkdir -p "$HOME/.config/lvim" +	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' \ +		+PackerInstall + +	nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" --headless \ +		+'autocmd User PackerComplete sleep 100m | qall' \ +		+PackerSync + +	printf "\nCompile Complete\n" + +	if [ -e "$HOME/.local/share/lunarvim/lvim/init.lua" ]; then +		echo 'lv-config already present' +	else +		cp "$HOME/.local/share/lunarvim/lvim/utils/installer/lv-config.example.lua" "$HOME/.config/lvim/lv-config.lua" +	fi -    echo -e "\nCompile Complete" -    rm $HOME/.config/nvim/lv-config.lua -    cp $HOME/.config/nvim/utils/installer/lv-config.example.lua $HOME/.config/nvim/lv-config.lua -    # nvim --headless -cq ':silent TSUpdate' -cq ':qall' >/dev/null 2>&1  }  asktoinstallnode() { -    echo "node not found" -    echo -n "Would you like to install node now (y/n)? " -    read answer -    [ "$answer" != "${answer#[Yy]}" ] && installnode +	echo "node not found" +	printf "Would you like to install node now (y/n)? " +	read -r answer +	[ "$answer" != "${answer#[Yy]}" ] && installnode  }  asktoinstallpip() { -    # echo "pip not found" -    # echo -n "Would you like to install pip now (y/n)? " -    # read answer -    # [ "$answer" != "${answer#[Yy]}" ] && installpip -    echo "Please install pip3 before continuing with install" -    exit +	# echo "pip not found" +	# echo -n "Would you like to install pip now (y/n)? " +	# read answer +	# [ "$answer" != "${answer#[Yy]}" ] && installpip +	echo "Please install pip3 before continuing with install" +	exit  }  installonmac() { -    brew install ripgrep fzf ranger -    npm install -g tree-sitter-cli -} - -pipinstallueberzug() { -    which pip3 >/dev/null && pip3 install ueberzug || echo "Not installing ueberzug pip not found" +	brew install ripgrep fzf +	npm install -g tree-sitter-cli  }  installonubuntu() { -    sudo apt install ripgrep fzf ranger -    sudo apt install libjpeg8-dev zlib1g-dev python-dev python3-dev libxtst-dev -    pip3 install ueberzug -    pip3 install neovim-remote -    npm install -g tree-sitter-cli +	sudo apt install ripgrep fzf +	sudo apt install libjpeg8-dev zlib1g-dev python-dev python3-dev libxtst-dev +	pip3 install neovim-remote +	npm install -g tree-sitter-cli  }  installonarch() { -    sudo pacman -S ripgrep fzf ranger -    which yay >/dev/null && yay -S python-ueberzug-git || pipinstallueberzug -    pip3 install neovim-remote -    npm install -g tree-sitter-cli +	sudo pacman -S ripgrep fzf +	pip3 install neovim-remote +	npm install -g tree-sitter-cli  }  installonfedora() { -    sudo dnf groupinstall "X Software Development" -    sudo dnf install -y fzf ripgrep ranger -    pip3 install wheel ueberzug +	sudo dnf groupinstall "X Software Development" +	sudo dnf install -y fzf ripgrep  }  installongentoo() { -    sudo emerge -avn sys-apps/ripgrep app-shells/fzf app-misc/ranger dev-python/neovim-remote virtual/jpeg sys-libs/zlib -    pipinstallueberzug -    npm install -g tree-sitter-cli +	sudo emerge -avn sys-apps/ripgrep app-shells/fzf dev-python/neovim-remote virtual/jpeg sys-libs/zlib +	npm install -g tree-sitter-cli  }  installextrapackages() { -    [ "$(uname)" == "Darwin" ] && installonmac -    [ -n "$(cat /etc/os-release | grep Ubuntu)" ] && installonubuntu -    [ -f "/etc/arch-release" ] && installonarch -    [ -f "/etc/artix-release" ] && installonarch -    [ -f "/etc/fedora-release" ] && installonfedora -    [ -f "/etc/gentoo-release" ] && installongentoo -    [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ] && echo "Windows not currently supported" +	[ "$(uname)" = "Darwin" ] && installonmac +	grep -q Ubuntu /etc/os-release && installonubuntu +	[ -f "/etc/arch-release" ] && installonarch +	[ -f "/etc/artix-release" ] && installonarch +	[ -f "/etc/fedora-release" ] && installonfedora +	[ -f "/etc/gentoo-release" ] && installongentoo +	[ "$(uname -s | cut -c 1-10)" = "MINGW64_NT" ] && echo "Windows not currently supported"  }  # Welcome  echo 'Installing LunarVim' -if [[ $* == *--overwrite* ]]; then -  echo '!!Warning!! -> Removing all nvim related config because of the --overwrite flag' -  rm -rf "$HOME/.config/nvim" -  rm -rf "$HOME/.cache/nvim" -  rm -rf "$HOME/.local/share/nvim/site/pack/packer" -fi +case "$@" in +*--overwrite*) +	echo '!!Warning!! -> Removing all lunarvim related config because of the --overwrite flag' +	rm -rf "$HOME/.local/share/lunarvim" +	rm -rf "$HOME/.cache/nvim" +	rm -rf "$HOME/.config/lvim" +	;; +esac -# move old nvim directory if it exists -[ -d "$HOME/.config/nvim" ] && moveoldnvim +# move old lvim directory if it exists +[ -d "$HOME/.local/share/lunarvim" ] && moveoldlvim  # install pip -which pip3 >/dev/null && echo "pip installed, moving on..." || asktoinstallpip +(command -v pip3 >/dev/null && echo "pip installed, moving on...") || asktoinstallpip  # install node and neovim support -which node >/dev/null && echo "node installed, moving on..." || asktoinstallnode +(command -v node >/dev/null && echo "node installed, moving on...") || asktoinstallnode  # 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 -    echo 'packer already installed' +if [ -e "$HOME/.local/share/lunarvim/site/pack/packer/start/packer.nvim" ]; then +	echo 'packer already installed'  else -    installpacker +	installpacker  fi -if [ -e "$HOME/.config/nvim/init.lua" ]; then -    echo 'LunarVim already installed' +if [ -e "$HOME/.local/share/lunarvim/lvim/init.lua" ]; then +	echo 'LunarVim already installed'  else -    # clone config down -    cloneconfig -    # echo 'export PATH=$HOME/.config/nvim/utils/bin:$PATH' >>~/.zshrc -    # echo 'export PATH=$HOME/.config/lunarvim/utils/bin:$PATH' >>~/.bashrc +	# clone config down +	cloneconfig "$@" +	# echo 'export PATH=$HOME/.config/nvim/utils/bin:$PATH' >>~/.zshrc +	# echo 'export PATH=$HOME/.config/lunarvim/utils/bin:$PATH' >>~/.bashrc  fi -echo "I recommend you also install and activate a font from here: https://github.com/ryanoasis/nerd-fonts" - -# echo "I also recommend you add 'set preview_images_method ueberzug' to ~/.config/ranger/rc.conf" +if [ "$(uname)" != "Darwin" ]; then +	if [ -e "$HOME/.local/share/applications/lvim.desktop" ]; then +		echo 'Desktop file already available' +	else +		mkdir -p "$HOME/.local/share/applications" +		cp "$HOME/.local/share/lunarvim/lvim/utils/desktop/lvim.desktop" "$HOME/.local/share/applications/lvim.desktop" +	fi +fi +echo "I recommend you also install and activate a font from here: https://github.com/ryanoasis/nerd-fonts"  # echo 'export PATH=/home/$USER/.config/lunarvim/utils/bin:$PATH appending to zshrc/bashrc' diff --git a/utils/installer/install_stylua.sh b/utils/installer/install_stylua.sh new file mode 100755 index 00000000..cd8b3942 --- /dev/null +++ b/utils/installer/install_stylua.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +set -eu pipefall + +declare -r INSTALL_DIR="$PWD/utils" +declare -r RELEASE="0.10.0" +declare -r OS="linux" +# declare -r OS="$(uname -s)" +declare -r FILENAME="stylua-$RELEASE-$OS" + +declare -a __deps=("curl" "unzip") + +function check_deps() { +	for dep in "${__deps[@]}"; do +		if ! command -v "$dep" >/dev/null; then +			echo "Missing depdendecy!" +			echo "The \"$dep\" command was not found!. Please install and try again." +		fi +	done +} + +function download_stylua() { +	local DOWNLOAD_DIR +	local URL="https://github.com/JohnnyMorganz/StyLua/releases/download/v$RELEASE/$FILENAME.zip" + +	DOWNLOAD_DIR="$(mktemp -d)" +	echo "Initiating download for Stylua v$RELEASE" +	if ! curl --progress-bar --fail -L "$URL" -o "$DOWNLOAD_DIR/$FILENAME.zip"; then +		echo "Download failed.  Check that the release/filename are correct." +		exit 1 +	fi + +	echo "Installtion in progress.." +	unzip -q "$DOWNLOAD_DIR/$FILENAME.zip" -d "$DOWNLOAD_DIR" + +	if [ -f "$DOWNLOAD_DIR/stylua" ]; then +		mv "$DOWNLOAD_DIR/stylua" "$INSTALL_DIR/stylua" +	else +		mv "$DOWNLOAD_DIR/$FILENAME/stylua" "$INSTALL_DIR/." +	fi + +	chmod u+x "$INSTALL_DIR/stylua" +} + +function verify_install() { +	echo "Verifying installtion.." +	local DOWNLOADED_VER +	DOWNLOADED_VER="$("$INSTALL_DIR/stylua" -V | awk '{ print $2 }')" +	if [ "$DOWNLOADED_VER" != "$RELEASE" ]; then +		echo "Mismatched version!" +		echo "Expected: v$RELEASE but got v$DOWNLOADED_VER" +		exit 1 +	fi +	echo "Verification complete!" +} + +function main() { +	check_deps +	download_stylua +	verify_install +} + +main "$@" diff --git a/utils/installer/lv-config.example-no-ts.lua b/utils/installer/lv-config.example-no-ts.lua index 33d9f433..ab12309d 100644 --- a/utils/installer/lv-config.example-no-ts.lua +++ b/utils/installer/lv-config.example-no-ts.lua @@ -1,58 +1,55 @@ ---[[ -O is the global options object - -Linters should be -filled in as strings with either -a global executable or a path to -an executable -]]  -- THESE ARE EXAMPLE CONFIGS FEEL FREE TO CHANGE TO WHATEVER YOU WANT  -- general +lvim.format_on_save = true +lvim.lint_on_save = true +lvim.colorscheme = "spacegray" -O.format_on_save = true -O.completion.autocomplete = true -O.colorscheme = "spacegray" -O.auto_close_tree = 0 -O.default_options.wrap = true -O.default_options.timeoutlen = 100 -O.leader_key = " " +-- keymappings +lvim.leader = "space" +-- overwrite the key-mappings provided by LunarVim for any mode, or leave it empty to keep them +-- lvim.keys.normal_mode = { +--   Page down/up +--   {'[d', '<PageUp>'}, +--   {']d', '<PageDown>'}, +-- +--   Navigate buffers +--   {'<Tab>', ':bnext<CR>'}, +--   {'<S-Tab>', ':bprevious<CR>'}, +-- } +-- if you just want to augment the existing ones then use the utility function +-- require("utils").add_keymap_insert_mode({ silent = true }, { +-- { "<C-s>", ":w<cr>" }, +-- { "<C-c>", "<ESC>" }, +-- }) +-- you can also use the native vim way directly +-- vim.api.nvim_set_keymap("i", "<C-Space>", "compe#complete()", { noremap = true, silent = true, expr = true })  -- TODO: User Config for predefined plugins  -- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile -O.plugin.dashboard.active = true -O.plugin.floatterm.active = true -O.plugin.zen.active = false -O.plugin.zen.window.height = 0.90 +lvim.builtin.dashboard.active = true +lvim.builtin.terminal.active = true +lvim.builtin.nvimtree.side = "left" +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 -O.treesitter.ensure_installed = {} -O.treesitter.ignore_install = { "haskell" } -O.treesitter.highlight.enabled = true - --- python --- O.python.linter = 'flake8' -O.lang.python.isort = true -O.lang.python.diagnostics.virtual_text = true -O.lang.python.analysis.use_library_code_types = true --- to change default formatter from yapf to black --- O.lang.python.formatter.exe = "black" --- O.lang.python.formatter.args = {"-"} - --- go --- to change default formatter from gofmt to goimports --- O.lang.formatter.go.exe = "goimports" - --- javascript -O.lang.tsserver.linter = nil - --- latex --- O.lang.latex.auto_save = false --- O.lang.latex.ignore_errors = { } +lvim.builtin.treesitter.ensure_installed = {} +lvim.builtin.treesitter.ignore_install = { "haskell" } +lvim.builtin.treesitter.highlight.enabled = true +-- generic LSP settings +-- 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  -- Additional Plugins --- O.user_plugins = { +-- lvim.plugins = {  --     {"folke/tokyonight.nvim"}, {  --         "ray-x/lsp_signature.nvim",  --         config = function() require"lsp_signature".on_attach() end, @@ -61,13 +58,8 @@ O.lang.tsserver.linter = nil  -- }  -- Autocommands (https://neovim.io/doc/user/autocmd.html) --- O.user_autocommands = {{ "BufWinEnter", "*", "echo \"hi again\""}} +-- lvim.autocommands.custom_groups = { +--   { "BufWinEnter", "*.lua", "setlocal ts=8 sw=8" }, +-- }  -- Additional Leader bindings for WhichKey --- O.user_which_key = { ---   A = { ---     name = "+Custom Leader Keys", ---     a = { "<cmd>echo 'first custom command'<cr>", "Description for a" }, ---     b = { "<cmd>echo 'second custom command'<cr>", "Description for b" }, ---   }, --- } diff --git a/utils/installer/lv-config.example.lua b/utils/installer/lv-config.example.lua index 7072c60c..681f5f65 100644 --- a/utils/installer/lv-config.example.lua +++ b/utils/installer/lv-config.example.lua @@ -1,5 +1,5 @@  --[[ -O is the global options object +lvim is the global options object  Linters should be  filled in as strings with either @@ -10,54 +10,56 @@ an executable  -- general -O.format_on_save = true -O.completion.autocomplete = true -O.colorscheme = "spacegray" -O.auto_close_tree = 0 -O.default_options.wrap = true -O.default_options.timeoutlen = 100 -O.leader_key = " " +lvim.format_on_save = true +lvim.lint_on_save = true +lvim.colorscheme = "spacegray" +-- keymappings +lvim.leader = "space" +-- overwrite the key-mappings provided by LunarVim for any mode, or leave it empty to keep them +-- lvim.keys.normal_mode = { +--   Page down/up +--   {'[d', '<PageUp>'}, +--   {']d', '<PageDown>'}, +-- +--   Navigate buffers +--   {'<Tab>', ':bnext<CR>'}, +--   {'<S-Tab>', ':bprevious<CR>'}, +-- } +-- if you just want to augment the existing ones then use the utility function +-- require("utils").add_keymap_insert_mode({ silent = true }, { +-- { "<C-s>", ":w<cr>" }, +-- { "<C-c>", "<ESC>" }, +-- }) +-- you can also use the native vim way directly +-- vim.api.nvim_set_keymap("i", "<C-Space>", "compe#complete()", { noremap = true, silent = true, expr = true })  -- TODO: User Config for predefined plugins  -- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile -O.plugin.dashboard.active = true -O.plugin.floatterm.active = true -O.plugin.zen.active = false -O.plugin.zen.window.height = 0.90 +lvim.builtin.dashboard.active = true +lvim.builtin.terminal.active = true +lvim.builtin.nvimtree.side = "left" +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 -O.treesitter.ensure_installed = "maintained" -O.treesitter.ignore_install = { "haskell" } -O.treesitter.highlight.enabled = true - --- python --- O.lang.python.linter = 'flake8' -O.lang.python.isort = true -O.lang.python.diagnostics.virtual_text = true -O.lang.python.analysis.use_library_code_types = true --- to change default formatter from yapf to black --- O.lang.python.formatter.exe = "black" --- O.lang.python.formatter.args = {"-"} - --- go --- to change default formatter from gofmt to goimports --- O.lang.formatter.go.exe = "goimports" +lvim.builtin.treesitter.ensure_installed = "maintained" +lvim.builtin.treesitter.ignore_install = { "haskell" } +lvim.builtin.treesitter.highlight.enabled = true --- javascript -O.lang.tsserver.linter = nil +-- generic LSP settings +-- 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 --- rust --- O.lang.rust.formatter = { ---   exe = "rustfmt", ---   args = {"--emit=stdout", "--edition=2018"}, --- } - --- latex --- O.lang.latex.auto_save = false --- O.lang.latex.ignore_errors = { } +-- python  -- Additional Plugins --- O.user_plugins = { +-- lvim.plugins = {  --     {"folke/tokyonight.nvim"}, {  --         "ray-x/lsp_signature.nvim",  --         config = function() require"lsp_signature".on_attach() end, @@ -66,13 +68,18 @@ O.lang.tsserver.linter = nil  -- }  -- Autocommands (https://neovim.io/doc/user/autocmd.html) --- O.user_autocommands = {{ "BufWinEnter", "*", "echo \"hi again\""}} +-- lvim.autocommands.custom_groups = { +--   { "BufWinEnter", "*.lua", "setlocal ts=8 sw=8" }, +-- }  -- Additional Leader bindings for WhichKey --- O.user_which_key = { ---   A = { ---     name = "+Custom Leader Keys", ---     a = { "<cmd>echo 'first custom command'<cr>", "Description for a" }, ---     b = { "<cmd>echo 'second custom command'<cr>", "Description for b" }, ---   }, +-- lvim.builtin.which_key.mappings["P"] = { "<cmd>lua require'telescope'.extensions.project.project{}<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>", "Diagnosticss" }, +--   q = { "<cmd>Trouble quickfix<cr>", "QuickFix" }, +--   l = { "<cmd>Trouble loclist<cr>", "LocationList" }, +--   w = { "<cmd>Trouble lsp_workspace_diagnostics<cr>", "Diagnosticss" },  -- } diff --git a/utils/installer/uninstall.sh b/utils/installer/uninstall.sh new file mode 100755 index 00000000..0615e219 --- /dev/null +++ b/utils/installer/uninstall.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +rm -rf ~/.local/share/lunarvim +sudo rm /usr/local/bin/lvim +rm -rf ~/.local/share/applications/lvim.desktop diff --git a/utils/julia/Manifest.toml b/utils/julia/Manifest.toml new file mode 100644 index 00000000..c6c12950 --- /dev/null +++ b/utils/julia/Manifest.toml @@ -0,0 +1,182 @@ +# This file is machine-generated - editing it directly is not advised + +[[ArgTools]] +uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" + +[[Artifacts]] +uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" + +[[Base64]] +uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" + +[[CSTParser]] +deps = ["Tokenize"] +git-tree-sha1 = "9723e1c07c1727082e169ca50789644a552fb023" +uuid = "00ebfdb7-1f24-5e51-bd34-a7502290713f" +version = "3.2.3" + +[[Dates]] +deps = ["Printf"] +uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" + +[[DocumentFormat]] +deps = ["CSTParser", "FilePathsBase", "Tokenize"] +git-tree-sha1 = "cf048d65cbcdec70f10745e5801eeb0c6478a7f7" +uuid = "ffa9a821-9c82-50df-894e-fbcef3ed31cd" +version = "3.2.4" + +[[Downloads]] +deps = ["ArgTools", "LibCURL", "NetworkOptions"] +uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" + +[[FilePathsBase]] +deps = ["Dates", "Mmap", "Printf", "Test", "UUIDs"] +git-tree-sha1 = "0f5e8d0cb91a6386ba47bd1527b240bd5725fbae" +uuid = "48062228-2e41-5def-b9a4-89aafe57970f" +version = "0.9.10" + +[[InteractiveUtils]] +deps = ["Markdown"] +uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" + +[[JSON]] +deps = ["Dates", "Mmap", "Parsers", "Unicode"] +git-tree-sha1 = "81690084b6198a2e1da36fcfda16eeca9f9f24e4" +uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" +version = "0.21.1" + +[[JSONRPC]] +deps = ["JSON", "UUIDs"] +git-tree-sha1 = "1e9a820a29b37864a6738b8fd00eedf3fb8d772e" +uuid = "b9b8584e-8fd3-41f9-ad0c-7255d428e418" +version = "1.3.3" + +[[LanguageServer]] +deps = ["CSTParser", "DocumentFormat", "JSON", "JSONRPC", "Markdown", "Pkg", "REPL", "StaticLint", "SymbolServer", "Tokenize", "URIParser", "UUIDs"] +git-tree-sha1 = "ac9f7da10fbba9cad8455a3436d121eaf8f308f6" +uuid = "2b0e0bc5-e4fd-59b4-8912-456d1b03d8d7" +version = "4.0.0" + +[[LibCURL]] +deps = ["LibCURL_jll", "MozillaCACerts_jll"] +uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" + +[[LibCURL_jll]] +deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] +uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" + +[[LibGit2]] +deps = ["Base64", "NetworkOptions", "Printf", "SHA"] +uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" + +[[LibSSH2_jll]] +deps = ["Artifacts", "Libdl", "MbedTLS_jll"] +uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" + +[[Libdl]] +uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" + +[[Logging]] +uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" + +[[Markdown]] +deps = ["Base64"] +uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" + +[[MbedTLS_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" + +[[Mmap]] +uuid = "a63ad114-7e13-5084-954f-fe012c677804" + +[[MozillaCACerts_jll]] +uuid = "14a3606d-f60d-562e-9121-12d972cd8159" + +[[NetworkOptions]] +uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" + +[[Parsers]] +deps = ["Dates"] +git-tree-sha1 = "c8abc88faa3f7a3950832ac5d6e690881590d6dc" +uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" +version = "1.1.0" + +[[Pkg]] +deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] +uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" + +[[Printf]] +deps = ["Unicode"] +uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" + +[[REPL]] +deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] +uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" + +[[Random]] +deps = ["Serialization"] +uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" + +[[SHA]] +uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" + +[[Serialization]] +uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" + +[[Sockets]] +uuid = "6462fe0b-24de-5631-8697-dd941f90decc" + +[[StaticLint]] +deps = ["CSTParser", "Serialization", "SymbolServer"] +git-tree-sha1 = "337ca6f234947b31e921a424f7d0ec8dda22ed49" +uuid = "b3cc710f-9c33-5bdb-a03d-a94903873e97" +version = "8.0.0" + +[[SymbolServer]] +deps = ["InteractiveUtils", "LibGit2", "Markdown", "Pkg", "REPL", "SHA", "Serialization", "Sockets", "UUIDs"] +git-tree-sha1 = "9053544866f779dfb87027c52a332e2830e868ab" +uuid = "cf896787-08d5-524d-9de7-132aaa0cb996" +version = "7.0.0" + +[[TOML]] +deps = ["Dates"] +uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" + +[[Tar]] +deps = ["ArgTools", "SHA"] +uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" + +[[Test]] +deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] +uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[[Tokenize]] +git-tree-sha1 = "eee92eda3cc8e104b7e56ff4c1fcf0d78ca37c89" +uuid = "0796e94c-ce3b-5d07-9a54-7f471281c624" +version = "0.5.18" + +[[URIParser]] +deps = ["Unicode"] +git-tree-sha1 = "53a9f49546b8d2dd2e688d216421d050c9a31d0d" +uuid = "30578b45-9adc-5946-b283-645ec420af67" +version = "0.4.1" + +[[UUIDs]] +deps = ["Random", "SHA"] +uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" + +[[Unicode]] +uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" + +[[Zlib_jll]] +deps = ["Libdl"] +uuid = "83775a58-1f1d-513f-b197-d71354ab007a" + +[[nghttp2_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" + +[[p7zip_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" diff --git a/utils/julia/Project.toml b/utils/julia/Project.toml new file mode 100644 index 00000000..50cd7702 --- /dev/null +++ b/utils/julia/Project.toml @@ -0,0 +1,3 @@ +[deps] +LanguageServer = "2b0e0bc5-e4fd-59b4-8912-456d1b03d8d7" +SymbolServer = "cf896787-08d5-524d-9de7-132aaa0cb996" diff --git a/utils/julia/run.jl b/utils/julia/run.jl new file mode 100644 index 00000000..4662e1b2 --- /dev/null +++ b/utils/julia/run.jl @@ -0,0 +1,37 @@ +# Load LanguageServer from the project next to this file +## Save old load path +old_load_path = copy(LOAD_PATH) +push!(empty!(LOAD_PATH), @__DIR__) +## Load packages +using LanguageServer, SymbolServer +## Restore old load path +append!(empty!(LOAD_PATH), old_load_path) + +# Figure out the active project +## This configuration is a good default +project_path = let +    dirname(something( +        ## 1. Finds an explicitly set project (JULIA_PROJECT) +        Base.load_path_expand(( +            p = get(ENV, "JULIA_PROJECT", nothing); +            p === nothing ? nothing : isempty(p) ? nothing : p +        )), +        ## 2. Look for a Project.toml file in the current working directory, +        ##    or parent directories, with $HOME as an upper boundary +        Base.current_project(), +        ## 3. First entry in the load path +        get(Base.load_path(), 1, nothing), +        ## 4. Fallback to default global environment, +        ##    this is more or less unreachable +        Base.load_path_expand("@v#.#"), +    )) +end + +# Depot path for the server to index (empty uses default). +depot_path = get(ENV, "JULIA_DEPOT_PATH", "") + +# Start the server +@info "Running julia language server" VERSION project_path depot_path +server = LanguageServer.LanguageServerInstance(stdin, stdout, project_path, depot_path) +server.runlinter = true +run(server) diff --git a/utils/vscode_config/settings.json b/utils/vscode_config/settings.json index 5ba2f460..d8a91c0f 100644 --- a/utils/vscode_config/settings.json +++ b/utils/vscode_config/settings.json @@ -1,8 +1,8 @@  {    "vscode-neovim.neovimExecutablePaths.darwin": "/usr/local/bin/nvim",    "vscode-neovim.neovimExecutablePaths.linux": "/usr/local/bin/nvim", -  "vscode-neovim.neovimInitVimPaths.darwin": "$HOME/.config/nvim/vimscript/nv-vscode/init.vim", -  "vscode-neovim.neovimInitVimPaths.linux": "$HOME/.config/nvim/vimscript/nv-vscode/init.vim", +  "vscode-neovim.neovimInitVimPaths.darwin": "$HOME/.config/nvim/utils/lv-vscode/init.vim", +  "vscode-neovim.neovimInitVimPaths.linux": "$HOME/.config/nvim/utils/lv-vscode/init.vim",    "whichkey.sortOrder": "alphabetically",    "whichkey.delay": 0,    "whichkey.bindings": [ | 
