diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..261eeb9e9f8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index 4d27756c92e..c851ce78827 100644 --- a/README.md +++ b/README.md @@ -1,163 +1,60 @@ -# kickstart.nvim +
+ +
-https://github.com/kdheepak/kickstart.nvim/assets/1813121/f3ff9a2b-c31f-44df-a4fa-8a0d7b17cf7b +--- -### Introduction +## Overview -A starting point for Neovim that is: +**Vi Mongo** is an intuitive Terminal User Interface (TUI) application, written +in Go, designed to streamline and simplify the management of MongoDB databases. +Emphasizing ease of use without sacrificing functionality, Vi Mongo offers a +user-friendly command-line experience for database administrators and developers +alike. -* Small -* Single-file (with examples of moving to multi-file) -* Documented -* Modular +Visit [vi-mongo.com](https://vi-mongo.com) for more information. -This repo is meant to be used by **YOU** to begin your Neovim journey; remove the things you don't use and add what you miss. +![autocomplete](./assets/autocomplete.webp) -Kickstart.nvim targets *only* the latest ['stable'](https://github.com/neovim/neovim/releases/tag/stable) and latest ['nightly'](https://github.com/neovim/neovim/releases/tag/nightly) of Neovim. If you are experiencing issues, please make sure you have the latest versions. +## Installation -Distribution Alternatives: -- [LazyVim](https://www.lazyvim.org/): A delightful distribution maintained by @folke (the author of lazy.nvim, the package manager used here) +To install Vi Mongo, follow the instructions on the [installation page](https://vi-mongo.com/docs/installation). -### Installation +If you are using [Neovim](https://neovim.io/) you can install the plugin from [nvim-plugin](https://github.com/kopecmaciej/vi-mongo.nvim) -> **NOTE** -> [Backup](#FAQ) your previous configuration (if any exists) +## Features -Requirements: -* Make sure to review the readmes of the plugins if you are experiencing errors. In particular: - * [ripgrep](https://github.com/BurntSushi/ripgrep#installation) is required for multiple [telescope](https://github.com/nvim-telescope/telescope.nvim#suggested-dependencies) pickers. -* See [Windows Installation](#Windows-Installation) if you have trouble with `telescope-fzf-native` +- **Intuitive Navigation**: Vi Mongo's simple, intuitive interface makes it easy + to navigate and manage your MongoDB databases. +- **Fast switching between databases**: Vi Mongo allows you to fast switch + between databases. +- **Managing Documents**: Vi Mongo allows you to view, create, update, duplicate + and delete documents in your databases with ease. +- **Managing Collections**: Vi Mongo provides a simple way to manage your + collections, including the ability to create, delete collections. +- **Autocomplete**: Vi Mongo offers an autocomplete feature that suggests + collection names, database names, and MongoDB commands as you type. +- **Query History**: Vi Mongo keeps track of your query history, allowing you to + easily access and reuse previous queries. +- **Multiple Styles**: Vi Mongo supports multiple color schemes, they can be + selected in config file or add/modify easily. -Neovim's configurations are located under the following paths, depending on your OS: +## List of features to be implemented -| OS | PATH | -| :- | :--- | -| Linux | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` | -| MacOS | `$XDG_CONFIG_HOME/nvim`, '~/.config/nvim` | -| Windows | `%userprofile%\AppData\Local\nvim\` | +[vi-mongo.com/docs/roadmap](https://vi-mongo.com/docs/roadmap) -Clone kickstart.nvim: +## Contributing -```sh -# on Linux and Mac -git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim -``` +All contributions are welcome! +1. Create an issue +2. Fork the repository +3. Go with the flow -``` -# on Windows -git clone https://github.com/nvim-lua/kickstart.nvim.git %userprofile%\AppData\Local\nvim\ -``` +If possible please write tests for your changes. -### Post Installation - -Run the following command and then **you are ready to go**! - -```sh -nvim --headless "+Lazy! sync" +qa -``` - -### Recommended Steps - -[Fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) this repo (so that you have your own copy that you can modify) and then installing you can install to your machine using the methods above. - -> **NOTE** -> Your fork's url will be something like this: `https://github.com//kickstart.nvim.git` - -### Configuration And Extension - -* Inside of your copy, feel free to modify any file you like! It's your copy! -* Feel free to change any of the default options in `init.lua` to better suit your needs. -* For adding plugins, there are 3 primary options: - * Add new configuration in `lua/custom/plugins/*` files, which will be auto sourced using `lazy.nvim` (uncomment the line importing the `custom/plugins` directory in the `init.lua` file to enable this) - * Modify `init.lua` with additional plugins. - * Include the `lua/kickstart/plugins/*` files in your configuration. - -You can also merge updates/changes from the repo back into your fork, to keep up-to-date with any changes for the default configuration. - -#### Example: Adding an autopairs plugin - -In the file: `lua/custom/plugins/autopairs.lua`, add: - -```lua --- File: lua/custom/plugins/autopairs.lua - -return { - "windwp/nvim-autopairs", - -- Optional dependency - dependencies = { 'hrsh7th/nvim-cmp' }, - config = function() - require("nvim-autopairs").setup {} - -- If you want to automatically add `(` after selecting a function or method - local cmp_autopairs = require('nvim-autopairs.completion.cmp') - local cmp = require('cmp') - cmp.event:on( - 'confirm_done', - cmp_autopairs.on_confirm_done() - ) - end, -} -``` - - -This will automatically install [windwp/nvim-autopairs](https://github.com/windwp/nvim-autopairs) and enable it on startup. For more information, see documentation for [lazy.nvim](https://github.com/folke/lazy.nvim). - -#### Example: Adding a file tree plugin - -In the file: `lua/custom/plugins/filetree.lua`, add: - -```lua --- Unless you are still migrating, remove the deprecated commands from v1.x -vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) - -return { - "nvim-neo-tree/neo-tree.nvim", - version = "*", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended - "MunifTanjim/nui.nvim", - }, - config = function () - require('neo-tree').setup {} - end, -} -``` - -This will install the tree plugin and add the command `:Neotree` for you. You can explore the documentation at [neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim) for more information. - -### Contribution - -Pull-requests are welcome. The goal of this repo is not to create a Neovim configuration framework, but to offer a starting template that shows, by example, available features in Neovim. Some things that will not be included: - -* Custom language server configuration (null-ls templates) -* Theming beyond a default colorscheme necessary for LSP highlight groups - -Each PR, especially those which increase the line count, should have a description as to why the PR is necessary. - -### FAQ - -* What should I do if I already have a pre-existing neovim configuration? - * You should back it up, then delete all files associated with it. - * This includes your existing init.lua and the neovim files in `~/.local` which can be deleted with `rm -rf ~/.local/share/nvim/` - * You may also want to look at the [migration guide for lazy.nvim](https://github.com/folke/lazy.nvim#-migration-guide) -* What if I want to "uninstall" this configuration: - * See [lazy.nvim uninstall](https://github.com/folke/lazy.nvim#-uninstalling) information -* Are there any cool videos about this plugin? - * Current iteration of kickstart (coming soon) - * Here is one about the previous iteration of kickstart: [video introduction to Kickstart.nvim](https://youtu.be/stqUbv-5u2s). Note the install via init.lua no longer works as specified. Please follow the install instructions in this file instead as they're up to date. - -### Windows Installation - -Installation may require installing build tools, and updating the run command for `telescope-fzf-native` - -See `telescope-fzf-native` documentation for [more details](https://github.com/nvim-telescope/telescope-fzf-native.nvim#installation) - -This requires: - -- Install CMake, and the Microsoft C++ Build Tools on Windows - -```lua -{'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' } -``` +## Issues +For now all issues are resolved, but if you find any new issues, please report +them in the [GitHub Issues](https://github.com/kopecmaciej/vi-mongo/issues) +page. diff --git a/after/plugin/catppuccin-config.lua b/after/plugin/catppuccin-config.lua new file mode 100644 index 00000000000..8572757accc --- /dev/null +++ b/after/plugin/catppuccin-config.lua @@ -0,0 +1,46 @@ +require('catppuccin').setup { + flavour = 'macchiato', -- mocha, frappe, latte, mocha + background = { -- :h background + light = 'latte', + dark = 'mocha', + }, + transparent_background = false, -- disables setting the background color. + show_end_of_buffer = false, -- shows the '~' characters after the end of buffers + term_colors = false, -- sets terminal colors (e.g. `g:terminal_color_0`) + dim_inactive = { + enabled = false, -- dims the background color of inactive window + shade = 'dark', + percentage = 0.15, -- percentage of the shade to apply to the inactive window + }, + no_italic = false, -- Force no italic + no_bold = false, -- Force no bold + no_underline = false, -- Force no underline + styles = { -- Handles the styles of general hi groups (see `:h highlight-args`): + comments = { 'italic' }, -- Change the style of comments + conditionals = { 'italic' }, + loops = {}, + functions = {}, + keywords = {}, + strings = {}, + variables = {}, + numbers = {}, + booleans = {}, + properties = {}, + types = {}, + operators = {}, + }, + color_overrides = {}, + custom_highlights = {}, + integrations = { + cmp = true, + gitsigns = true, + nvimtree = true, + treesitter = true, + notify = false, + mini = { + enabled = true, + indentscope_color = '', + }, + -- For more plugins integrations please scroll down (https://github.com/catppuccin/nvim#integrations) + }, +} diff --git a/after/plugin/cmp.lua b/after/plugin/cmp.lua new file mode 100644 index 00000000000..026f5b49833 --- /dev/null +++ b/after/plugin/cmp.lua @@ -0,0 +1,60 @@ +-- [[ Configure nvim-cmp ]] +-- See `:help cmp` +vim.api.nvim_set_hl(0, 'CmpGhostText', { link = 'Comment', default = true }) +local cmp = require 'cmp' +local luasnip = require 'luasnip' +require('luasnip.loaders.from_vscode').lazy_load() +luasnip.config.setup {} + +cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete {}, + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'path' }, + { name = 'buffer' }, + { + { name = 'buffer' }, + }, + }, +} + +cmp.setup.filetype({ 'sql', 'mysql' }, { + sources = { + { name = 'vim-dadbod-completion' }, + { name = 'buffer' }, + }, +}) diff --git a/after/plugin/conform-config.lua b/after/plugin/conform-config.lua new file mode 100644 index 00000000000..161cc1d65f7 --- /dev/null +++ b/after/plugin/conform-config.lua @@ -0,0 +1,34 @@ +require('conform').setup { + formatters_by_ft = { + lua = { 'stylua' }, + python = { 'black' }, --'isort', + javascript = { "prettierd", "prettier", stop_after_first = true }, + javascriptreact = { 'prettier' }, + typescriptreact = { 'prettier' }, + typescript = { 'prettier' }, + xml = { 'prettier', 'xmlformat' }, + html = { 'prettier' }, + htmldjango = { 'prettier' }, + go = { 'gofumpt', 'goimports-reviser', 'golines', stop_after_first = true }, + java = { 'google-java-format' }, + templ = { 'templ' }, + }, + format_on_save = { + -- I recommend these options. See :help conform.format for details. + lsp_fallback = true, + timeout_ms = 600, + }, + -- If this is set, Conform will run the formatter asynchronously after save. + -- It will pass the table to conform.format(). + -- This can also be a function that returns the table. + format_after_save = { + lsp_fallback = true, + }, +} + +-- vim.api.nvim_create_autocmd('BufWritePre', { +-- pattern = '*', +-- callback = function(args) +-- require('conform').format { bufnr = args.buf } +-- end, +-- }) diff --git a/after/plugin/dadbod-ui-config.lua b/after/plugin/dadbod-ui-config.lua new file mode 100644 index 00000000000..4b42e97d2e5 --- /dev/null +++ b/after/plugin/dadbod-ui-config.lua @@ -0,0 +1,30 @@ +vim.keymap.set('n', 'db', 'DBUIToggle', { noremap = true, desc = 'DB UI Toggle' }) +vim.keymap.set('n', 'dba', 'DBUIAddConnection', { noremap = true, desc = 'Add New DB Connection' }) + +local M = {} + +local function db_completion() + require('cmp').setup.buffer { sources = { { name = 'vim-dadbod-completion' } } } +end + +function M.setup() + vim.api.nvim_create_autocmd('FileType', { + pattern = { + 'sql', + }, + command = [[setlocal omnifunc=vim_dadbod_completion#omni]], + }) + + vim.api.nvim_create_autocmd('FileType', { + pattern = { + 'sql', + 'mysql', + 'plsql', + }, + callback = function() + vim.schedule(db_completion) + end, + }) +end + +return M diff --git a/after/plugin/gopher-config.lua b/after/plugin/gopher-config.lua new file mode 100644 index 00000000000..61448df78a8 --- /dev/null +++ b/after/plugin/gopher-config.lua @@ -0,0 +1,15 @@ +require('gopher').setup { + commands = { + go = 'go', + gomodifytags = 'gomodifytags', + gotests = '~/go/bin/gotests', -- also you can set custom command path + impl = 'impl', + iferr = 'iferr', + }, +} + +vim.keymap.set('n', 'gsv', ':GoTagAdd validate:required', { desc = 'Add validation to struct' }) +vim.keymap.set('n', 'gaj', ':GoTagAdd json', { desc = 'Add JSON Tag TO Go Struct' }) +vim.keymap.set('n', 'gax', ':GoTagAdd xml', { desc = 'Add XML Tag TO Go Struct' }) +vim.keymap.set('n', 'gadb', ':GoTagAdd db', { desc = 'Add DB Tag TO Go Struct' }) +vim.keymap.set('n', 'gmt', ':GoMod tidy', { desc = 'go mod tidy' }) diff --git a/after/plugin/lazygit-config.lua b/after/plugin/lazygit-config.lua new file mode 100644 index 00000000000..23e77ab147a --- /dev/null +++ b/after/plugin/lazygit-config.lua @@ -0,0 +1,2 @@ +--[[ LazyGit Configurations ]] +vim.keymap.set("n", "gg", ":LazyGit", { silent = true, desc = 'Launch Lazygit' }) diff --git a/after/plugin/lsp-config.lua b/after/plugin/lsp-config.lua new file mode 100644 index 00000000000..5944438a428 --- /dev/null +++ b/after/plugin/lsp-config.lua @@ -0,0 +1,77 @@ +require('mason').setup() +require('mason-lspconfig').setup() + +vim.lsp.enable 'rust_analyzer' +vim.lsp.enable 'pyright' + +vim.lsp.enable 'jdtls' + +vim.lsp.enable 'lua_ls' + +vim.lsp.enable 'gopls' +vim.lsp.enable 'templ' + +vim.lsp.enable 'dartls' +-- vim.lsp.enable 'htmx' + +-- vim.lsp.enable 'jsonls' +-- vim.lsp.enable 'html' + +vim.lsp.enable 'ts_ls' +-- vim.lsp.enable 'eslint' + +-- vim.lsp.enable 'tsserver' +vim.lsp.enable 'tailwindcss' + +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities.textDocument.foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true, +} + +local function on_attach(bufnr) + -- 'opts' table to avoid repetition for buffer and remap settings + local opts = { buffer = bufnr, remap = false } + + -- Require Telescope for LSP-related functions + local tele = require 'telescope.builtin' + + -- Set up keymaps with clear descriptions + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, { desc = 'Lsp: Goto Declaration', buffer = bufnr, remap = false }) + vim.keymap.set('n', 'K', 'lua vim.lsp.buf.hover()', opts) + -- vim.keymap.set('n', 'K', vim.lsp.buf.hover, { desc = 'Lsp: Hover Documentation', buffer = bufnr, remap = false }) + vim.keymap.set('n', 'vws', vim.lsp.buf.workspace_symbol, { desc = 'Lsp: Workspace Symbols', buffer = bufnr, remap = false }) + vim.keymap.set('n', 'vd', vim.diagnostic.open_float, { desc = 'Lsp: View Line Diagnostic', buffer = bufnr, remap = false }) + vim.keymap.set('n', '[d', vim.diagnostic.goto_next, { desc = 'Lsp: Next Diagnostic', buffer = bufnr, remap = false }) + vim.keymap.set('n', ']d', vim.diagnostic.goto_prev, { desc = 'Lsp: Previous Diagnostic', buffer = bufnr, remap = false }) + vim.keymap.set('n', 'dd', vim.diagnostic.setloclist, { desc = 'Lsp: List Diagnostics', buffer = bufnr, remap = false }) + vim.keymap.set('n', 'do', vim.diagnostic.open_float, { desc = 'Lsp: Open Diagnostic Float', buffer = bufnr, remap = false }) + vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, { desc = 'Lsp: Code Action', buffer = bufnr, remap = false }) + vim.keymap.set('n', 'gd', tele.lsp_definitions, { desc = 'Lsp: Goto Definition', buffer = bufnr, remap = false }) + vim.keymap.set('n', 'gr', tele.lsp_references, { desc = 'Lsp: Goto References', buffer = bufnr, remap = false }) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, { desc = 'Lsp: Rename Symbol', buffer = bufnr, remap = false }) + + vim.keymap.set('n', 'lf', function() + require('conform').format { bufnr = bufnr } + end, { buffer = bufnr, desc = 'Lsp: Format Buffer' }) + + vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, { desc = 'Lsp: Add Workspace Folder', buffer = bufnr, remap = false }) + vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, { desc = 'Lsp: Remove Workspace Folder', buffer = bufnr, remap = false }) + vim.keymap.set('n', 'wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, { desc = 'Lsp: List Workspace Folders', buffer = bufnr, remap = false }) + + local tele = require 'telescope.builtin' + + vim.keymap.set('n', 'fs', tele.lsp_document_symbols, { desc = 'Lsp: Document Symbols (Current File)', buffer = bufnr, remap = false }) + vim.keymap.set('n', 'fS', tele.lsp_dynamic_workspace_symbols, { desc = 'Lsp: Workspace Symbols (Dynamic)', buffer = bufnr, remap = false }) + vim.keymap.set('n', 'ft', tele.lsp_type_definitions, { desc = 'Lsp: Goio Type Definition', buffer = bufnr, remap = false }) + vim.keymap.set('n', 'fi', tele.lsp_implementations, { desc = 'Lsp: Goto Implementations', buffer = bufnr, remap = false }) +end + +vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('UserLspConfig', {}), + callback = function(ev) + on_attach(ev.buf) + end, +}) diff --git a/after/plugin/mini-comment-config.lua b/after/plugin/mini-comment-config.lua new file mode 100644 index 00000000000..0d1a09d0bf1 --- /dev/null +++ b/after/plugin/mini-comment-config.lua @@ -0,0 +1,42 @@ +require('mini.comment').setup { + -- Options which control module behavior + options = { + -- Function to compute custom 'commentstring' (optional) + custom_commentstring = function() + return vim.bo.commentstring + end, + + -- Whether to ignore blank lines + ignore_blank_line = false, + + -- Whether to recognize as comment only lines without indent + start_of_line = false, + + -- Whether to ensure single space pad for comment parts + pad_comment_parts = true, + }, + + -- Module mappings. Use `''` (empty string) to disable one. + mappings = { + -- Toggle comment (like `gcip` - comment inner paragraph) for both + -- Normal and Visual modes + comment = '++', + + -- Toggle comment on current line + comment_line = '++', + + -- Toggle comment on visual selection + comment_visual = '++', + + -- Define 'comment' textobject (like `dgc` - delete whole comment block) + textobject = '++', + }, + + -- Hook functions to be executed at certain stage of commenting + hooks = { + -- Before successful commenting. Does nothing by default. + pre = function() end, + -- After successful commenting. Does nothing by default. + post = function() end, + }, +} diff --git a/after/plugin/nvim-java-config.lua b/after/plugin/nvim-java-config.lua new file mode 100644 index 00000000000..9a8169cac22 --- /dev/null +++ b/after/plugin/nvim-java-config.lua @@ -0,0 +1,74 @@ +local java_21_home_dir = '/Library/Java/JavaVirtualMachines/openjdk.jdk/Contents/Home' +local java_17_home_dir = '/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home' +local java_11_home_dir = '/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home' + +local function on_attach(client, bufnr) + local opts = { buffer = bufnr, remap = false } + + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) + vim.keymap.set('n', 'vws', vim.lsp.buf.workspace_symbol, opts) + vim.keymap.set('n', 'vd', vim.diagnostic.open_float, opts) + vim.keymap.set('n', '[d', vim.diagnostic.goto_next, opts) + vim.keymap.set('n', ']d', vim.diagnostic.goto_prev, opts) + vim.keymap.set('n', 'dd', vim.diagnostic.setloclist, opts) + vim.keymap.set('n', 'do', vim.diagnostic.open_float, opts) + vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, opts) + vim.keymap.set('n', 'gd', require('telescope.builtin').lsp_definitions, opts) + vim.keymap.set('n', 'gr', require('telescope.builtin').lsp_references, opts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, opts) + vim.keymap.set('n', 'lf', function() + require('conform').format() + end, { buffer = bufnr, desc = 'Format Buffer' }) + vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, opts) + vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, opts) + vim.keymap.set('n', 'wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, opts) +end + +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities.textDocument.foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true, +} + +require('lspconfig').jdtls.setup { + on_attach = on_attach, + capabilities = capabilities, + settings = { + java = { + configuration = { + runtimes = { + { + name = 'JavaSE-17', + path = java_17_home_dir .. '/bin/java', + default = true, + }, + }, + }, + }, + }, +} + +local function is_java_file() + return vim.bo.filetype == 'java' +end + +-- Function to run the Maven Wildfly redeploy command +local function redeploy_wildfly() + vim.cmd '!mvn wildfly:redeploy' +end + +-- Create the keymap +vim.keymap.set('n', 'jd', function() + if is_java_file() then + redeploy_wildfly() + else + vim.notify 'This keymap only works for Java files.' + end +end, { desc = 'Redeploy Wildfly' }) + +vim.diagnostic.config { + virtual_text = true, +} diff --git a/after/plugin/nvim-ufo-config.lua b/after/plugin/nvim-ufo-config.lua new file mode 100644 index 00000000000..29b14e86cf5 --- /dev/null +++ b/after/plugin/nvim-ufo-config.lua @@ -0,0 +1,27 @@ +vim.o.foldcolumn = '1' -- '0' is not bad +vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value +vim.o.foldlevelstart = 99 +vim.o.foldenable = true + +-- Using ufo provider need remap `zR` and `zM`. If Neovim is 0.6.1, remap yourself +vim.keymap.set('n', 'zR', require('ufo').openAllFolds) +vim.keymap.set('n', 'zM', require('ufo').closeAllFolds) + +vim.keymap.set('n', 'zK', function() + local winid = ufo.peekFoldedLinesUnderCursor() + if not winid then + vim.lsp.buf.hover() + end +end) + +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities.textDocument.foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true, +} + +require('ufo').setup { + provider_selector = function(bufnr, filetype, buftype) + return { 'lsp', 'indent' } + end, +} diff --git a/after/plugin/tailwind-tool-config.lua b/after/plugin/tailwind-tool-config.lua new file mode 100644 index 00000000000..a85525058bc --- /dev/null +++ b/after/plugin/tailwind-tool-config.lua @@ -0,0 +1,3 @@ +require("tailwind-tools").setup({ + +}) diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua new file mode 100644 index 00000000000..ee16cf2511e --- /dev/null +++ b/after/plugin/telescope.lua @@ -0,0 +1,59 @@ +-- [[ Configure Treesitter ]] +require('telescope').setup { + defaults = { + mappings = { + i = { + [''] = false, + [''] = false, + }, + }, + }, +} + +-- Enable telescope fzf native, if installed +pcall(require('telescope').load_extension, 'fzf') + +-- See `:help telescope.builtin` +vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) +vim.keymap.set('n', 'fb', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) +vim.keymap.set('n', '/', function() + -- You can pass additional configuration to telescope to change theme, layout, etc. + require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = true, + }) +end, { desc = '[/] Fuzzily search in current buffer' }) + +vim.keymap.set('n', 'ff', require('telescope.builtin').find_files, { desc = 'Find [F]iles' }) +vim.keymap.set('n', 'fh', require('telescope.builtin').help_tags, { desc = 'Find [H]elp' }) +vim.keymap.set('n', 'fw', require('telescope.builtin').grep_string, { desc = 'Find current [W]ord' }) +vim.keymap.set('n', 'fd', require('telescope.builtin').diagnostics, { desc = 'Find [D]iagnostics' }) +-- vim.keymap.set('n', 'fr', require('telescope.builtin').registers, { desc = 'Find [R]egister' }) +vim.keymap.set('n', 'fF', function() + require('telescope.builtin').find_files { hidden = true, no_ignore = true } +end, { desc = '[S]earch [R]esume' }) + +vim.keymap.set('n', 'fg', require('telescope.builtin').live_grep, { desc = 'Find by [G]rep' }) +vim.keymap.set('n', 'fG', function() + require('telescope.builtin').live_grep { + additional_args = function(args) + return vim.list_extend(args, { '--hidden', '--no-ignore' }) + end, + } +end, { desc = 'Find by [G]rep In all Files' }) + +-- Replace in the Quickfix list +function QuickfixReplace(search, replace) + vim.fn.setqflist {} + local bufnr = vim.fn.bufnr '%' + local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false) + for lnum, line in ipairs(lines) do + if string.match(line, search) then + local replaced_line = string.gsub(line, search, replace) + vim.fn.setqflist { { bufnr = bufnr, lnum = lnum, text = replaced_line } } + end + end + vim.cmd 'cwindow' +end + +vim.api.nvim_set_keymap('n', 'fr', ':lua QuickfixReplace(vim.fn.input("Search: "), vim.fn.input("Replace: "))', { noremap = true }) diff --git a/after/plugin/treesitter-config.lua b/after/plugin/treesitter-config.lua new file mode 100644 index 00000000000..32e8b88117e --- /dev/null +++ b/after/plugin/treesitter-config.lua @@ -0,0 +1,117 @@ +require('nvim-treesitter.configs').setup { + -- A list of parser names, or "all" + ensure_installed = { + 'c', + 'css', + 'lua', + 'rust', + 'go', + 'python', + 'vim', + 'vimdoc', + 'tsx', + 'html', + 'java', + 'javascript', + 'typescript', + 'templ', + }, + context_commentstring = { + enable = true, + }, + + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + + -- Automatically install missing parsers when entering buffer + -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally + auto_install = true, + + highlight = { + -- `false` will disable the whole extension + enable = true, + + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = false, + }, + + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + scope_incremental = '', + node_decremental = '', + }, + }, + + textobjects = { + select = { + enable = true, + lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ['aa'] = '@parameter.outer', + ['ia'] = '@parameter.inner', + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + [']m'] = '@function.outer', + [']]'] = '@class.outer', + }, + goto_next_end = { + [']M'] = '@function.outer', + [']['] = '@class.outer', + }, + goto_previous_start = { + ['[m'] = '@function.outer', + ['[['] = '@class.outer', + }, + goto_previous_end = { + ['[M'] = '@function.outer', + ['[]'] = '@class.outer', + }, + }, + swap = { + enable = true, + swap_next = { + ['a'] = '@parameter.inner', + }, + swap_previous = { + ['A'] = '@parameter.inner', + }, + }, + }, +} + +require'treesitter-context'.setup{ + enable = true, -- Enable this plugin (Can be enabled/disabled later via commands) + multiwindow = false, -- Enable multiwindow support. + max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit. + min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit. + line_numbers = true, + multiline_threshold = 20, -- Maximum number of lines to show for a single context + trim_scope = 'outer', -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer' + mode = 'cursor', -- Line used to calculate context. Choices: 'cursor', 'topline' + -- Separator between context and content. Should be a single character string, like '-'. + -- When separator is set, the context will only show up when there are at least 2 lines above cursorline. + separator = nil, + zindex = 20, -- The Z-index of the context window + on_attach = nil, -- (fun(buf: integer): boolean) return false to disable attaching +} + +vim.filetype.add { + extension = { + templ = 'templ', + }, +} diff --git a/after/plugin/undotree.lua b/after/plugin/undotree.lua new file mode 100644 index 00000000000..b6b9276a542 --- /dev/null +++ b/after/plugin/undotree.lua @@ -0,0 +1 @@ +vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) diff --git a/ftplugin/java.lua b/ftplugin/java.lua new file mode 100644 index 00000000000..076e4310363 --- /dev/null +++ b/ftplugin/java.lua @@ -0,0 +1,115 @@ +local jdtls_ok, jdtls = pcall(require, 'jdtls') +if not jdtls_ok then + vim.notify('JDTLS not found, install with `:MasonInstall jdtls`', vim.log.levels.ERROR) + return +end + +-- Path setup +local jdtls_path = vim.fn.stdpath('data') .. '/mason/packages/jdtls' +local path_to_lsp_server = jdtls_path .. '/config_mac' +local path_to_plugins = jdtls_path .. '/plugins/' +local path_to_jar = vim.fn.glob(path_to_plugins .. 'org.eclipse.equinox.launcher_*.jar') +local lombok_path = vim.fn.glob(path_to_plugins .. 'lombok.jar') + +-- Debug: Print paths +-- print("JDTLS Path: " .. jdtls_path) +-- print("LSP Server Path: " .. path_to_lsp_server) +-- print("JAR Path: " .. path_to_jar) +-- print("Lombok Path: " .. lombok_path) + +-- Check if paths exist +if vim.fn.executable(vim.fn.glob('/Library/Java/JavaVirtualMachines/openjdk.jdk/Contents/Home/bin/java')) == 0 then + vim.notify('Java 17 not found at expected path', vim.log.levels.ERROR) + return +end + +if path_to_jar == '' then + vim.notify('JDTLS JAR not found', vim.log.levels.ERROR) + return +end + +-- Java home directories +local java_17_home = '/Library/Java/JavaVirtualMachines/openjdk.jdk/Contents/Home' + +-- Root directory detection +local root_dir = require('jdtls.setup').find_root({'.git', 'mvnw', 'gradlew', 'pom.xml', 'build.gradle'}) +if root_dir == '' then + print("No root directory found") + return +end + +-- print("Root directory: " .. root_dir) + +-- Workspace setup +local project_name = vim.fn.fnamemodify(root_dir, ':p:h:t') +local workspace_dir = vim.fn.stdpath('data') .. '/site/java/workspace-root/' .. project_name +vim.fn.mkdir(workspace_dir, 'p') + +-- print("Workspace directory: " .. workspace_dir) + +-- Main Config +local config = { + cmd = { + java_17_home .. '/bin/java', + '-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', -- Changed back to ALL for debugging + '-Xms1g', + '--add-modules=ALL-SYSTEM', + '--add-opens', 'java.base/java.util=ALL-UNNAMED', + '--add-opens', 'java.base/java.lang=ALL-UNNAMED', + '-javaagent:' .. lombok_path, + '-jar', path_to_jar, + '-configuration', path_to_lsp_server, + '-data', workspace_dir, + }, + + root_dir = root_dir, + + settings = { + java = { + eclipse = { downloadSources = true }, + maven = { downloadSources = true }, + implementationsCodeLens = { enabled = true }, + referencesCodeLens = { enabled = true }, + references = { includeDecompiledSources = true }, + configuration = { + updateBuildConfiguration = 'interactive', + runtimes = { + { name = 'JavaSE-17', path = java_17_home, default = true } + } + } + }, + signatureHelp = { enabled = true }, + completion = { + favoriteStaticMembers = { + 'org.hamcrest.MatcherAssert.assertThat', + 'org.hamcrest.Matchers.*', + 'org.hamcrest.CoreMatchers.*', + 'org.junit.jupiter.api.Assertions.*', + 'java.util.Objects.requireNonNull', + 'java.util.Objects.requireNonNullElse', + 'org.mockito.Mockito.*', + } + } + }, + + flags = { allow_incremental_sync = true }, + init_options = { bundles = {} } +} + +-- Keymaps setup +config.on_attach = function(_, bufnr) + vim.notify('JDTLS attached to buffer ' .. bufnr, vim.log.levels.INFO) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, { buffer = bufnr }) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { buffer = bufnr }) +end + +-- Debug: Print config command +-- print("JDTLS Command: " .. table.concat(config.cmd, ' ')) +-- +-- -- Start JDTLS +-- print("Starting JDTLS...") +jdtls.start_or_attach(config) diff --git a/init.lua b/init.lua index e5bc576e457..86fb4e34999 100644 --- a/init.lua +++ b/init.lua @@ -1,51 +1,6 @@ ---[[ - -===================================================================== -==================== READ THIS BEFORE CONTINUING ==================== -===================================================================== - -Kickstart.nvim is *not* a distribution. - -Kickstart.nvim is a template for your own configuration. - The goal is that you can read every line of code, top-to-bottom, understand - what your configuration is doing, and modify it to suit your needs. - - Once you've done that, you should start exploring, configuring and tinkering to - explore Neovim! - - If you don't know anything about Lua, I recommend taking some time to read through - a guide. One possible example: - - https://learnxinyminutes.com/docs/lua/ - - - And then you can explore or search through `:help lua-guide` - - https://neovim.io/doc/user/lua-guide.html - - -Kickstart Guide: - -I have left several `:help X` comments throughout the init.lua -You should run that command and read that help section for more information. - -In addition, I have some `NOTE:` items throughout the file. -These are for you, the reader to help understand what is happening. Feel free to delete -them once you know what you're doing, but they should serve as a guide for when you -are first encountering a few different constructs in your nvim config. - -I hope you enjoy your Neovim journey, -- TJ - -P.S. You can delete this when you're done too. It's your config now :) ---]] --- Set as the leader key --- See `:help mapleader` --- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' --- Install package manager --- https://github.com/folke/lazy.nvim --- `:help lazy.nvim.txt` for more info local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' if not vim.loop.fs_stat(lazypath) then vim.fn.system { @@ -59,493 +14,7 @@ if not vim.loop.fs_stat(lazypath) then end vim.opt.rtp:prepend(lazypath) --- NOTE: Here is where you install your plugins. --- You can configure plugins using the `config` key. --- --- You can also configure plugins after the setup call, --- as they will be available in your neovim runtime. -require('lazy').setup({ - -- NOTE: First, some plugins that don't require any configuration - - -- Git related plugins - 'tpope/vim-fugitive', - 'tpope/vim-rhubarb', - - -- Detect tabstop and shiftwidth automatically - 'tpope/vim-sleuth', - - -- NOTE: This is where your plugins related to LSP can be installed. - -- The configuration is done below. Search for lspconfig to find it below. - { - -- LSP Configuration & Plugins - 'neovim/nvim-lspconfig', - dependencies = { - -- Automatically install LSPs to stdpath for neovim - { 'williamboman/mason.nvim', config = true }, - 'williamboman/mason-lspconfig.nvim', - - -- Useful status updates for LSP - -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` - { 'j-hui/fidget.nvim', tag = 'legacy', opts = {} }, - - -- Additional lua configuration, makes nvim stuff amazing! - 'folke/neodev.nvim', - }, - }, - - { - -- Autocompletion - 'hrsh7th/nvim-cmp', - dependencies = { - -- Snippet Engine & its associated nvim-cmp source - 'L3MON4D3/LuaSnip', - 'saadparwaiz1/cmp_luasnip', - - -- Adds LSP completion capabilities - 'hrsh7th/cmp-nvim-lsp', - - -- Adds a number of user-friendly snippets - 'rafamadriz/friendly-snippets', - }, - }, - - -- Useful plugin to show you pending keybinds. - { 'folke/which-key.nvim', opts = {} }, - { - -- Adds git related signs to the gutter, as well as utilities for managing changes - 'lewis6991/gitsigns.nvim', - opts = { - -- See `:help gitsigns.txt` - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, - on_attach = function(bufnr) - vim.keymap.set('n', 'hp', require('gitsigns').preview_hunk, { buffer = bufnr, desc = 'Preview git hunk' }) - - -- don't override the built-in and fugitive keymaps - local gs = package.loaded.gitsigns - vim.keymap.set({'n', 'v'}, ']c', function() - if vim.wo.diff then return ']c' end - vim.schedule(function() gs.next_hunk() end) - return '' - end, {expr=true, buffer = bufnr, desc = "Jump to next hunk"}) - vim.keymap.set({'n', 'v'}, '[c', function() - if vim.wo.diff then return '[c' end - vim.schedule(function() gs.prev_hunk() end) - return '' - end, {expr=true, buffer = bufnr, desc = "Jump to previous hunk"}) - end, - }, - }, - - { - -- Theme inspired by Atom - 'navarasu/onedark.nvim', - priority = 1000, - config = function() - vim.cmd.colorscheme 'onedark' - end, - }, - - { - -- Set lualine as statusline - 'nvim-lualine/lualine.nvim', - -- See `:help lualine.txt` - opts = { - options = { - icons_enabled = false, - theme = 'onedark', - component_separators = '|', - section_separators = '', - }, - }, - }, - - { - -- Add indentation guides even on blank lines - 'lukas-reineke/indent-blankline.nvim', - -- Enable `lukas-reineke/indent-blankline.nvim` - -- See `:help indent_blankline.txt` - main = "ibl", - opts = {}, - }, - - -- "gc" to comment visual regions/lines - { 'numToStr/Comment.nvim', opts = {} }, - - -- Fuzzy Finder (files, lsp, etc) - { - 'nvim-telescope/telescope.nvim', - branch = '0.1.x', - dependencies = { - 'nvim-lua/plenary.nvim', - -- Fuzzy Finder Algorithm which requires local dependencies to be built. - -- Only load if `make` is available. Make sure you have the system - -- requirements installed. - { - 'nvim-telescope/telescope-fzf-native.nvim', - -- NOTE: If you are having trouble with this installation, - -- refer to the README for telescope-fzf-native for more instructions. - build = 'make', - cond = function() - return vim.fn.executable 'make' == 1 - end, - }, - }, - }, - - { - -- Highlight, edit, and navigate code - 'nvim-treesitter/nvim-treesitter', - dependencies = { - 'nvim-treesitter/nvim-treesitter-textobjects', - }, - build = ':TSUpdate', - }, - - -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart - -- These are some example plugins that I've included in the kickstart repository. - -- Uncomment any of the lines below to enable them. - -- require 'kickstart.plugins.autoformat', - -- require 'kickstart.plugins.debug', - - -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` - -- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping - -- up-to-date with whatever is in the kickstart repo. - -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- - -- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins - -- { import = 'custom.plugins' }, -}, {}) - --- [[ Setting options ]] --- See `:help vim.o` --- NOTE: You can change these options as you wish! - --- Set highlight on search -vim.o.hlsearch = false - --- Make line numbers default -vim.wo.number = true - --- Enable mouse mode -vim.o.mouse = 'a' - --- Sync clipboard between OS and Neovim. --- Remove this option if you want your OS clipboard to remain independent. --- See `:help 'clipboard'` -vim.o.clipboard = 'unnamedplus' - --- Enable break indent -vim.o.breakindent = true - --- Save undo history -vim.o.undofile = true - --- Case-insensitive searching UNLESS \C or capital in search -vim.o.ignorecase = true -vim.o.smartcase = true - --- Keep signcolumn on by default -vim.wo.signcolumn = 'yes' - --- Decrease update time -vim.o.updatetime = 250 -vim.o.timeoutlen = 300 - --- Set completeopt to have a better completion experience -vim.o.completeopt = 'menuone,noselect' - --- NOTE: You should make sure your terminal supports this -vim.o.termguicolors = true - --- [[ Basic Keymaps ]] - --- Keymaps for better default experience --- See `:help vim.keymap.set()` -vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) - --- Remap for dealing with word wrap -vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) -vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) - --- [[ Highlight on yank ]] --- See `:help vim.highlight.on_yank()` -local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) -vim.api.nvim_create_autocmd('TextYankPost', { - callback = function() - vim.highlight.on_yank() - end, - group = highlight_group, - pattern = '*', -}) - --- [[ Configure Telescope ]] --- See `:help telescope` and `:help telescope.setup()` -require('telescope').setup { - defaults = { - mappings = { - i = { - [''] = false, - [''] = false, - }, - }, - }, -} - --- Enable telescope fzf native, if installed -pcall(require('telescope').load_extension, 'fzf') - --- See `:help telescope.builtin` -vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) -vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) -vim.keymap.set('n', '/', function() - -- You can pass additional configuration to telescope to change theme, layout, etc. - require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, - }) -end, { desc = '[/] Fuzzily search in current buffer' }) - -vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) -vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) -vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) -vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) -vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) -vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) -vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) - --- [[ Configure Treesitter ]] --- See `:help nvim-treesitter` --- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}' -vim.defer_fn(function() - require('nvim-treesitter.configs').setup { - -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim' }, - - -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) - auto_install = false, - - highlight = { enable = true }, - indent = { enable = true }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = '', - node_incremental = '', - scope_incremental = '', - node_decremental = '', - }, - }, - textobjects = { - select = { - enable = true, - lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ['aa'] = '@parameter.outer', - ['ia'] = '@parameter.inner', - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', - }, - }, - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - [']m'] = '@function.outer', - [']]'] = '@class.outer', - }, - goto_next_end = { - [']M'] = '@function.outer', - [']['] = '@class.outer', - }, - goto_previous_start = { - ['[m'] = '@function.outer', - ['[['] = '@class.outer', - }, - goto_previous_end = { - ['[M'] = '@function.outer', - ['[]'] = '@class.outer', - }, - }, - swap = { - enable = true, - swap_next = { - ['a'] = '@parameter.inner', - }, - swap_previous = { - ['A'] = '@parameter.inner', - }, - }, - }, - } -end, 0) - --- Diagnostic keymaps -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) -vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) - --- [[ Configure LSP ]] --- This function gets run when an LSP connects to a particular buffer. -local on_attach = function(_, bufnr) - -- NOTE: Remember that lua is a real programming language, and as such it is possible - -- to define small helper and utility functions so you don't have to repeat yourself - -- many times. - -- - -- In this case, we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. - local nmap = function(keys, func, desc) - if desc then - desc = 'LSP: ' .. desc - end - - vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) - end - - nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') - nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') - - nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') - nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') - nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') - nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') - nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - - -- See `:help K` for why this keymap - nmap('K', vim.lsp.buf.hover, 'Hover Documentation') - nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') - - -- Lesser used LSP functionality - nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') - nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') - nmap('wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, '[W]orkspace [L]ist Folders') - - -- Create a command `:Format` local to the LSP buffer - vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) - vim.lsp.buf.format() - end, { desc = 'Format current buffer with LSP' }) -end - --- document existing key chains -require('which-key').register({ - ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, - ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, - ['g'] = { name = '[G]it', _ = 'which_key_ignore' }, - ['h'] = { name = 'More git', _ = 'which_key_ignore' }, - ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, - ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, - ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, -}) - --- Enable the following language servers --- Feel free to add/remove any LSPs that you want here. They will automatically be installed. --- --- Add any additional override configuration in the following tables. They will be passed to --- the `settings` field of the server config. You must look up that documentation yourself. --- --- If you want to override the default filetypes that your language server will attach to you can --- define the property 'filetypes' to the map in question. -local servers = { - -- clangd = {}, - -- gopls = {}, - -- pyright = {}, - -- rust_analyzer = {}, - -- tsserver = {}, - -- html = { filetypes = { 'html', 'twig', 'hbs'} }, - - lua_ls = { - Lua = { - workspace = { checkThirdParty = false }, - telemetry = { enable = false }, - }, - }, -} - --- Setup neovim lua configuration -require('neodev').setup() - --- nvim-cmp supports additional completion capabilities, so broadcast that to servers -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) - --- Ensure the servers above are installed -local mason_lspconfig = require 'mason-lspconfig' - -mason_lspconfig.setup { - ensure_installed = vim.tbl_keys(servers), -} - -mason_lspconfig.setup_handlers { - function(server_name) - require('lspconfig')[server_name].setup { - capabilities = capabilities, - on_attach = on_attach, - settings = servers[server_name], - filetypes = (servers[server_name] or {}).filetypes, - } - end -} - --- [[ Configure nvim-cmp ]] --- See `:help cmp` -local cmp = require 'cmp' -local luasnip = require 'luasnip' -require('luasnip.loaders.from_vscode').lazy_load() -luasnip.config.setup {} - -cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert { - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete {}, - [''] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }, - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { 'i', 's' }), - }, - sources = { - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - }, -} - --- The line beneath this is called `modeline`. See `:help modeline` --- vim: ts=2 sts=2 sw=2 et +require('lazy').setup 'plugins' +require 'thrillee' +--[[ require('kickstart.plugins.autoformat') +require('kickstart.plugins.debug') ]] diff --git a/java-config.lua b/java-config.lua new file mode 100644 index 00000000000..07517ee2dcd --- /dev/null +++ b/java-config.lua @@ -0,0 +1,176 @@ +-- Java Language Server configuration. +-- Locations: +-- 'nvim/ftplugin/java.lua'. +-- 'nvim/lang-servers/intellij-java-google-style.xml' + +-- local jdtls_ok, jdtls = pcall(require, 'jdtls') +-- if not jdtls_ok then +-- vim.notify 'JDTLS not found, install with `:LspInstall jdtls`' +-- return +-- end + +local home = os.getenv 'HOME' +local jdtls = require 'jdtls' +-- vim.notify 'Home: ' .. home + +-- See `:help vim.lsp.start_client` for an overview of the supported `config` options. +-- local jdtls_path = vim.fn.stdpath 'data' .. '/mason/packages/jdtls' +local jdtls_path = home .. '/.local/share/nvim/mason/packages/jdtls' +local path_to_lsp_server = jdtls_path .. '/config_mac' +local path_to_plugins = jdtls_path .. '/plugins/' +local path_to_jar = path_to_plugins .. 'org.eclipse.equinox.launcher_1.6.900.v20240613-2009.jar' +local lombok_path = jdtls_path .. '/lombok.jar' +local styling = home .. '/.local/share/java/eclipse-java-google-style.xml' +print(lombok_path) + +local root_markers = { '.git', 'mvnw', 'gradlew', 'pom.xml', 'build.gradle' } +local root_dir = require('jdtls.setup').find_root(root_markers) +if root_dir == '' then + return +end + +local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t') +local workspace_dir = vim.fn.stdpath 'data' .. '/site/java/workspace-root/' .. project_name +os.execute('mkdir ' .. workspace_dir) + +local java_21_home_dir = '/Library/Java/JavaVirtualMachines/openjdk.jdk/Contents/Home' +local java_17_home_dir = '/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home' +local java_11_home_dir = '/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home' + +-- Main Config +local config = { + -- The command that starts the language server + -- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line + cmd = { + java_21_home_dir .. '/bin/java', + '-Declipse.application=org.eclipse.jdt.ls.core.id1', + '-Dosgi.bundles.defaultStartLevel=4', + '-Declipse.product=org.eclipse.jdt.ls.core.product', + '-Dlog.protocol=true', + '-Xmx1g', + '-Dlog.level=ALL', + '--add-modules=ALL-SYSTEM', + '--add-opens', + 'java.base/java.util=ALL-UNNAMED', + '--add-opens', + 'java.base/java.lang=ALL-UNNAMED', + '-javaagent:' .. lombok_path, + '-Xms1g', + '--add-modules=ALL-SYSTEM', + '--add-opens', + 'java.base/java.util=ALL-UNNAMED', + '--add-opens', + 'java.base/java.lang=ALL-UNNAMED', + + '-jar', + path_to_jar, + '-configuration', + path_to_lsp_server, + '-data', + workspace_dir, + }, + + -- This is the default if not provided, you can remove it. Or adjust as needed. + -- One dedicated LSP server & client will be started per unique root_dir + root_dir = root_dir, + + settings = { + java = { + home = java_21_home_dir, + eclipse = { + downloadSources = true, + }, + configuration = { + updateBuildConfiguration = 'interactive', + runtimes = { + { + name = 'JavaSE-21', + path = java_21_home_dir, + }, + { + name = 'JavaSE-11', + path = java_11_home_dir, + }, + { + name = 'JavaSE-17', + path = java_17_home_dir, + }, + }, + }, + maven = { + downloadSources = true, + }, + implementationsCodeLens = { + enabled = true, + }, + referencesCodeLens = { + enabled = true, + }, + references = { + includeDecompiledSources = true, + }, + format = { + settings = { + url = styling, + profile = 'GoogleStyle', + }, + }, + }, + signatureHelp = { enabled = true }, + completion = { + favoriteStaticMembers = { + 'org.hamcrest.MatcherAssert.assertThat', + 'org.hamcrest.Matchers.*', + 'org.hamcrest.CoreMatchers.*', + 'org.junit.jupiter.api.Assertions.*', + 'java.util.Objects.requireNonNull', + 'java.util.Objects.requireNonNullElse', + 'org.mockito.Mockito.*', + }, + importOrder = { + 'java', + 'com', + 'org', + 'javax', + 'jarkata', + }, + }, + sources = { + organizeImports = { + starThreshold = 9999, + staticStarThreshold = 9999, + }, + }, + codeGeneration = { + toString = { + template = '${object.className}{${member.name()}=${member.value}, ${otherMembers}}', + }, + useBlocks = true, + }, + }, + + flags = { + allow_incremental_sync = true, + }, + init_options = { + bundles = { + vim.fn.glob(lombok_path, 1), + }, + }, +} + +-- config['on_attach'] = function(_, bufnr) +-- require('keymaps').map_java_keys(bufnr) +-- require('lsp_signature').on_attach({ +-- bind = true, -- This is mandatory, otherwise border config won't get registered. +-- floating_window_above_cur_line = false, +-- padding = '', +-- handler_opts = { +-- border = 'rounded', +-- }, +-- }, bufnr) +-- end + +-- This starts a new client & server, +-- or attaches to an existing client & server depending on the `root_dir`. +require('jdtls').start_or_attach(config) diff --git a/java.lua b/java.lua new file mode 100644 index 00000000000..fe6aab3736c --- /dev/null +++ b/java.lua @@ -0,0 +1,165 @@ +-- Java Language Server configuration. +-- Locations: +-- 'nvim/ftplugin/java.lua'. +-- 'nvim/lang-servers/intellij-java-google-style.xml' + +local jdtls_ok, jdtls = pcall(require, 'jdtls') +if not jdtls_ok then + vim.notify 'JDTLS not found, install with `:LspInstall jdtls`' + return +end + +-- See `:help vim.lsp.start_client` for an overview of the supported `config` options. +-- local jdtls_path = vim.fn.stdpath 'data' .. '/mason/packages/jdtls' +local jdtls_path = '/Users/oluwatobibello/.local/share/nvim/mason/packages/jdtls' +local path_to_lsp_server = jdtls_path .. '/config_mac' +local path_to_plugins = jdtls_path .. '/plugins/' +local path_to_jar = path_to_plugins .. 'org.eclipse.equinox.launcher_*.jar' +local lombok_path = path_to_plugins .. 'lombok.jar' + +local root_markers = { '.git', 'mvnw', 'gradlew', 'pom.xml', 'build.gradle' } +local root_dir = require('jdtls.setup').find_root(root_markers) +if root_dir == '' then + return +end + +local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t') +local workspace_dir = vim.fn.stdpath 'data' .. '/site/java/workspace-root/' .. project_name +os.execute('mkdir ' .. workspace_dir) + +local java_21_home_dir = '/Library/Java/JavaVirtualMachines/openjdk.jdk/Contents/Home/bin/java' +local java_17_home_dir = '/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home' +local java_11_home_dir = '/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home' + +-- Main Config +local config = { + -- The command that starts the language server + -- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line + cmd = { + java_21_home_dir .. '/bin/java', + '-Declipse.application=org.eclipse.jdt.ls.core.id1', + '-Dosgi.bundles.defaultStartLevel=4', + '-Declipse.product=org.eclipse.jdt.ls.core.product', + '-Dlog.protocol=true', + '-Xmx1g', + '-Dlog.level=ALL', + '--add-modules=ALL-SYSTEM', + '--add-opens', + 'java.base/java.util=ALL-UNNAMED', + '--add-opens', + 'java.base/java.lang=ALL-UNNAMED', + '-javaagent:' .. lombok_path, + '-Xms1g', + '--add-modules=ALL-SYSTEM', + '--add-opens', + 'java.base/java.util=ALL-UNNAMED', + '--add-opens', + 'java.base/java.lang=ALL-UNNAMED', + + '-jar', + path_to_jar, + '-configuration', + path_to_lsp_server, + '-data', + workspace_dir, + }, + + -- This is the default if not provided, you can remove it. Or adjust as needed. + -- One dedicated LSP server & client will be started per unique root_dir + root_dir = root_dir, + + -- Here you can configure eclipse.jdt.ls specific settings + -- See https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request + -- for a list of options + settings = { + java = { + home = java_21_home_dir, + eclipse = { + downloadSources = true, + }, + configuration = { + updateBuildConfiguration = 'interactive', + runtimes = { + { + name = 'JavaSE-21', + path = java_21_home_dir, + }, + { + name = 'JavaSE-11', + path = java_11_home_dir, + }, + { + name = 'JavaSE-17', + path = java_17_home_dir, + }, + }, + }, + maven = { + downloadSources = true, + }, + implementationsCodeLens = { + enabled = true, + }, + referencesCodeLens = { + enabled = true, + }, + references = { + includeDecompiledSources = true, + }, + }, + signatureHelp = { enabled = true }, + completion = { + favoriteStaticMembers = { + 'org.hamcrest.MatcherAssert.assertThat', + 'org.hamcrest.Matchers.*', + 'org.hamcrest.CoreMatchers.*', + 'org.junit.jupiter.api.Assertions.*', + 'java.util.Objects.requireNonNull', + 'java.util.Objects.requireNonNullElse', + 'org.mockito.Mockito.*', + }, + importOrder = { + 'java', + 'com', + 'org', + 'javax', + 'jarkata', + }, + }, + sources = { + organizeImports = { + starThreshold = 9999, + staticStarThreshold = 9999, + }, + }, + codeGeneration = { + toString = { + template = '${object.className}{${member.name()}=${member.value}, ${otherMembers}}', + }, + useBlocks = true, + }, + }, + + flags = { + allow_incremental_sync = true, + }, + init_options = { + bundles = {}, + }, +} + +config['on_attach'] = function(_, bufnr) + require('keymaps').map_java_keys(bufnr) + require('lsp_signature').on_attach({ + bind = true, -- This is mandatory, otherwise border config won't get registered. + floating_window_above_cur_line = false, + padding = '', + handler_opts = { + border = 'rounded', + }, + }, bufnr) +end + +-- This starts a new client & server, +-- or attaches to an existing client & server depending on the `root_dir`. +require('jdtls').start_or_attach(config) diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 00000000000..de0cc15873d --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,55 @@ +{ + "LuaSnip": { "branch": "master", "commit": "fb525166ccc30296fb3457441eb979113de46b00" }, + "alpha-nvim": { "branch": "main", "commit": "a35468cd72645dbd52c0624ceead5f301c566dff" }, + "catppuccin": { "branch": "main", "commit": "fa42eb5e26819ef58884257d5ae95dd0552b9a66" }, + "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, + "cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" }, + "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, + "cmp-path": { "branch": "main", "commit": "c6635aae33a50d6010bf1aa756ac2398a2d54c32" }, + "cmp-vsnip": { "branch": "main", "commit": "989a8a73c44e926199bfd05fa7a516d51f2d2752" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "conform.nvim": { "branch": "master", "commit": "8132ec733eed3bf415b97b76797ca41b59f51d7d" }, + "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, + "gitsigns.nvim": { "branch": "main", "commit": "1b0350ab707713b2bc6c236151f1a324175347b1" }, + "gopher.nvim": { "branch": "main", "commit": "de585144ebde9f0516fb9b542dd42e90c7835b59" }, + "hererocks": { "branch": "master", "commit": "4ce92131e9858950440ab99a25db9a9b43db8cd4" }, + "image.nvim": { "branch": "master", "commit": "4c51d6202628b3b51e368152c053c3fb5c5f76f2" }, + "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, + "lazygit.nvim": { "branch": "main", "commit": "4839ab642962cc76bb1bf278427dc4c59be15072" }, + "lspkind-nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" }, + "lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "c4c84f4521d62de595c0d0f718a9a40c1890c8ce" }, + "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, + "mini.ai": { "branch": "main", "commit": "d172ada7b0281044a06cb9a625a862553c457b6f" }, + "mini.comment": { "branch": "main", "commit": "51c173dffa17dc14c81169deaeea430bd394ab51" }, + "mini.surround": { "branch": "main", "commit": "1a2b59c77a0c4713a5bd8972da322f842f4821b1" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "f481de16a0eb59c985abac8985e3f2e2f75b4875" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-autopairs": { "branch": "master", "commit": "2647cce4cb64fb35c212146663384e05ae126bdf" }, + "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, + "nvim-jdtls": { "branch": "master", "commit": "4d77ff02063cf88963d5cf10683ab1fd15d072de" }, + "nvim-lspconfig": { "branch": "master", "commit": "5e0e9c00d51fcb7efef0d4c49023f9593b38661e" }, + "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, + "nvim-treesitter-context": { "branch": "master", "commit": "1a1a7c5d6d75cb49bf64049dafab15ebe294a79f" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "89ebe73cd2836db80a22d9748999ace0241917a5" }, + "nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" }, + "nvim-ufo": { "branch": "main", "commit": "80fe8215ba566df2fbf3bf4d25f59ff8f41bc0e1" }, + "nvim-web-devicons": { "branch": "master", "commit": "19d6211c78169e78bab372b585b6fb17ad974e82" }, + "nvim-window-picker": { "branch": "main", "commit": "6382540b2ae5de6c793d4aa2e3fe6dbb518505ec" }, + "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, + "promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" }, + "tailwind-tools": { "branch": "master", "commit": "fbe982901d4508b0dcd80e07addf0fcb6dab6c49" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "undotree": { "branch": "master", "commit": "b951b87b46c34356d44aa71886aecf9dd7f5788a" }, + "vi-mongo.nvim": { "branch": "master", "commit": "ac21b4de10b9409c872e81a34b41cee52bf7174c" }, + "vim-dadbod": { "branch": "master", "commit": "e95afed23712f969f83b4857a24cf9d59114c2e6" }, + "vim-dadbod-completion": { "branch": "master", "commit": "a8dac0b3cf6132c80dc9b18bef36d4cf7a9e1fe6" }, + "vim-dadbod-ui": { "branch": "master", "commit": "2900a1617b3df1a48683d872eadbe1101146a49a" }, + "vim-fugitive": { "branch": "master", "commit": "593f831d6f6d779cbabb70a4d1e6b1b1936a88af" }, + "vim-rhubarb": { "branch": "master", "commit": "386daa2e9d98e23e27ad089afcbe5c5a903e488d" }, + "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, + "vim-vsnip": { "branch": "master", "commit": "0a4b8419e44f47c57eec4c90df17567ad4b1b36e" }, + "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } +} diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua deleted file mode 100644 index be0eb9d8d7a..00000000000 --- a/lua/custom/plugins/init.lua +++ /dev/null @@ -1,5 +0,0 @@ --- You can add your own plugins here or in other files in this directory! --- I promise not to create any merge conflicts in this directory :) --- --- See the kickstart.nvim README for more information -return {} diff --git a/lua/plugins/alpha.lua b/lua/plugins/alpha.lua new file mode 100644 index 00000000000..a4f3028a3d6 --- /dev/null +++ b/lua/plugins/alpha.lua @@ -0,0 +1,7 @@ +return { + 'goolord/alpha-nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = function () + require'alpha'.setup(require'alpha.themes.startify'.config) + end +}; diff --git a/lua/plugins/autopairs.lua b/lua/plugins/autopairs.lua new file mode 100644 index 00000000000..d271227f75e --- /dev/null +++ b/lua/plugins/autopairs.lua @@ -0,0 +1,15 @@ +return { + "windwp/nvim-autopairs", + -- Optional dependency + dependencies = { 'hrsh7th/nvim-cmp' }, + config = function() + require("nvim-autopairs").setup {} + -- If you want to automatically add `(` after selecting a function or method + local cmp_autopairs = require('nvim-autopairs.completion.cmp') + local cmp = require('cmp') + cmp.event:on( + 'confirm_done', + cmp_autopairs.on_confirm_done() + ) + end, +} diff --git a/lua/plugins/catppuccin.lua b/lua/plugins/catppuccin.lua new file mode 100644 index 00000000000..cf2318b68be --- /dev/null +++ b/lua/plugins/catppuccin.lua @@ -0,0 +1,8 @@ +return { + 'catppuccin/nvim', + name = 'catppuccin', + priority = 1000, + config = function() + vim.cmd.colorscheme 'catppuccin' + end, +} diff --git a/lua/plugins/conform.lua b/lua/plugins/conform.lua new file mode 100644 index 00000000000..6b816b8da9b --- /dev/null +++ b/lua/plugins/conform.lua @@ -0,0 +1,4 @@ +return { + 'stevearc/conform.nvim', + opts = {}, +} diff --git a/lua/plugins/dadbod.lua b/lua/plugins/dadbod.lua new file mode 100644 index 00000000000..de850af86f7 --- /dev/null +++ b/lua/plugins/dadbod.lua @@ -0,0 +1,17 @@ +return { + 'kristijanhusak/vim-dadbod-ui', + dependencies = { + { 'tpope/vim-dadbod', lazy = true }, + { 'kristijanhusak/vim-dadbod-completion', ft = { 'sql', 'mysql', 'plsql' }, lazy = true }, + }, + cmd = { + 'DBUI', + 'DBUIToggle', + 'DBUIAddConnection', + 'DBUIFindBuffer', + }, + init = function() + -- Your DBUI configuration + vim.g.db_ui_use_nerd_fonts = 1 + end, +} diff --git a/lua/plugins/git-fugitive.lua b/lua/plugins/git-fugitive.lua new file mode 100644 index 00000000000..c171ab32085 --- /dev/null +++ b/lua/plugins/git-fugitive.lua @@ -0,0 +1,6 @@ +return { + -- Git related plugins + 'tpope/vim-fugitive', + 'tpope/vim-rhubarb', + +} diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua new file mode 100644 index 00000000000..7af0234d25e --- /dev/null +++ b/lua/plugins/gitsigns.lua @@ -0,0 +1,31 @@ +return { + -- Adds git related signs to the gutter, as well as utilities for managing changes + 'lewis6991/gitsigns.nvim', + opts = { + -- See `:help gitsigns.txt` + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + }, + on_attach = function(bufnr) + vim.keymap.set('n', 'hp', require('gitsigns').preview_hunk, + { buffer = bufnr, desc = 'Preview git hunk' }) + + -- don't override the built-in and fugitive keymaps + local gs = package.loaded.gitsigns + vim.keymap.set({ 'n', 'v' }, ']c', function() + if vim.wo.diff then return ']c' end + vim.schedule(function() gs.next_hunk() end) + return '' + end, { expr = true, buffer = bufnr, desc = "Jump to next hunk" }) + vim.keymap.set({ 'n', 'v' }, '[c', function() + if vim.wo.diff then return '[c' end + vim.schedule(function() gs.prev_hunk() end) + return '' + end, { expr = true, buffer = bufnr, desc = "Jump to previous hunk" }) + end, + }, +} diff --git a/lua/plugins/gopher.lua b/lua/plugins/gopher.lua new file mode 100644 index 00000000000..b313e260763 --- /dev/null +++ b/lua/plugins/gopher.lua @@ -0,0 +1,7 @@ +return { + 'olexsmir/gopher.nvim', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-treesitter/nvim-treesitter', + }, +} diff --git a/lua/plugins/lazygit.lua b/lua/plugins/lazygit.lua new file mode 100644 index 00000000000..64de826a21e --- /dev/null +++ b/lua/plugins/lazygit.lua @@ -0,0 +1,9 @@ +return { + { + "kdheepak/lazygit.nvim", + -- optional for floating window border decoration + dependencies = { + "nvim-lua/plenary.nvim", + }, + }, +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 00000000000..58825056b69 --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,26 @@ +return { + 'neovim/nvim-lspconfig', + dependencies = { + -- LSP Support + { 'williamboman/mason.nvim' }, + { 'williamboman/mason-lspconfig.nvim' }, + + -- Autocompletion + { 'hrsh7th/nvim-cmp' }, + { 'hrsh7th/cmp-buffer' }, + { 'hrsh7th/cmp-path' }, + { 'saadparwaiz1/cmp_luasnip' }, + { 'hrsh7th/cmp-nvim-lsp' }, + { 'hrsh7th/cmp-nvim-lua' }, + { 'hrsh7th/cmp-cmdline' }, + { 'hrsh7th/cmp-vsnip' }, + { 'hrsh7th/vim-vsnip' }, + + -- Snippets + { 'L3MON4D3/LuaSnip' }, + + { 'rafamadriz/friendly-snippets' }, + }, + -- Use the lazy option to lazy-load the plugin on events or commands + lazy = false, +} diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 00000000000..b9a10ced098 --- /dev/null +++ b/lua/plugins/lualine.lua @@ -0,0 +1,13 @@ +return { + -- Set lualine as statusline + 'nvim-lualine/lualine.nvim', + -- See `:help lualine.txt` + opts = { + options = { + icons_enabled = false, + theme = 'onedark', + component_separators = '|', + section_separators = '', + }, + }, +} diff --git a/lua/plugins/mini-ai.lua b/lua/plugins/mini-ai.lua new file mode 100644 index 00000000000..83d0110dcb7 --- /dev/null +++ b/lua/plugins/mini-ai.lua @@ -0,0 +1,22 @@ +return { + 'echasnovski/mini.ai', + -- keys = { + -- { "a", mode = { "x", "o" } }, + -- { "i", mode = { "x", "o" } }, + -- }, + opts = function() + local ai = require 'mini.ai' + return { + n_lines = 500, + custom_textobjects = { + o = ai.gen_spec.treesitter({ + a = { '@block.outer', '@conditional.outer', '@loop.outer' }, + i = { '@block.inner', '@conditional.inner', '@loop.inner' }, + }, {}), + f = ai.gen_spec.treesitter({ a = '@function.outer', i = '@function.inner' }, {}), + c = ai.gen_spec.treesitter({ a = '@class.outer', i = '@class.inner' }, {}), + t = { '<([%p%w]-)%f[^<%w][^<>]->.-', '^<.->().*()$' }, + }, + } + end, +} diff --git a/lua/plugins/mini-comment.lua b/lua/plugins/mini-comment.lua new file mode 100644 index 00000000000..3c1cfdc8502 --- /dev/null +++ b/lua/plugins/mini-comment.lua @@ -0,0 +1,11 @@ +return { + 'echasnovski/mini.comment', + event = 'VeryLazy', + opts = { + options = { + custom_commentstring = function() + return require('ts_context_commentstring.internal').calculate_commentstring() or vim.bo.commentstring + end, + }, + }, +} diff --git a/lua/plugins/neo-tree.lua b/lua/plugins/neo-tree.lua new file mode 100644 index 00000000000..9fba323e417 --- /dev/null +++ b/lua/plugins/neo-tree.lua @@ -0,0 +1,141 @@ +return { + 'nvim-neo-tree/neo-tree.nvim', + branch = 'v3.x', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-tree/nvim-web-devicons', + 'MunifTanjim/nui.nvim', + '3rd/image.nvim', + { + 's1n7ax/nvim-window-picker', + version = '2.*', + config = function() + require('window-picker').setup { + filter_rules = { + include_current_win = false, + autoselect_one = true, + bo = { + filetype = { 'neo-tree', 'neo-tree-popup', 'notify' }, + buftype = { 'terminal', 'quickfix' }, + }, + }, + } + end, + }, + }, + cmd = 'Neotree', + keys = { + { + 'o', + function() + if vim.bo.filetype == 'neo-tree' then + vim.cmd.wincmd 'p' + else + vim.cmd.Neotree 'focus' + end + end, + desc = 'Toggle Explorer Focus', + }, + { '', 'Neotree toggle', desc = 'Toggle Explorer' }, + }, + init = function() + vim.g.neo_tree_remove_legacy_commands = true + end, + + opts = { + auto_clean_after_session_restore = true, + close_if_last_window = true, + source_selector = { + winbar = true, + content_layout = 'center', + }, + commands = { + parent_or_close = function(state) + local node = state.tree:get_node() + if (node.type == 'directory' or node:has_children()) and node:is_expanded() then + state.commands.toggle_node(state) + else + require('neo-tree.ui.renderer').focus_node(state, node:get_parent_id()) + end + end, + child_or_open = function(state) + local node = state.tree:get_node() + if node.type == 'directory' or node:has_children() then + if not node:is_expanded() then -- if unexpanded, expand + state.commands.toggle_node(state) + else -- if expanded and has children, seleect the next child + require('neo-tree.ui.renderer').focus_node(state, node:get_child_ids()[1]) + end + else -- if not a directory just open it + state.commands.open(state) + end + end, + copy_selector = function(state) + local node = state.tree:get_node() + local filepath = node:get_id() + local filename = node.name + local modify = vim.fn.fnamemodify + + local results = { + e = { val = modify(filename, ':e'), msg = 'Extension only' }, + f = { val = filename, msg = 'Filename' }, + F = { val = modify(filename, ':r'), msg = 'Filename w/o extension' }, + h = { val = modify(filepath, ':~'), msg = 'Path relative to Home' }, + p = { val = modify(filepath, ':.'), msg = 'Path relative to CWD' }, + P = { val = filepath, msg = 'Absolute path' }, + } + + local messages = { + { '\nChoose to copy to clipboard:\n', 'Normal' }, + } + for i, result in pairs(results) do + if result.val and result.val ~= '' then + vim.list_extend(messages, { + { ('%s.'):format(i), 'Identifier' }, + { (' %s: '):format(result.msg) }, + { result.val, 'String' }, + { '\n' }, + }) + end + end + vim.api.nvim_echo(messages, false, {}) + local result = results[vim.fn.getcharstr()] + if result and result.val and result.val ~= '' then + vim.notify('Copied: ' .. result.val) + vim.fn.setreg('+', result.val) + end + end, + }, + window = { + width = 30, + mappings = { + [''] = false, -- disable space until we figure out which-key disabling + ['[b'] = 'prev_source', + [']b'] = 'next_source', + o = 'open', + --[[ O = "system_open", ]] + h = 'parent_or_close', + l = 'child_or_open', + Y = 'copy_selector', + }, + }, + filesystem = { + hijack_netrw_behavior = 'open_current', + use_libuv_file_watcher = true, + follow_current_file = { + enabled = true, -- This will find and focus the file in the active buffer every time + -- -- the current file is changed while the tree is open. + leave_dirs_open = false, -- `false` closes auto expanded dirs, such as with `:Neotree reveal` + }, + }, + event_handlers = { + { + event = 'neo_tree_buffer_enter', + handler = function(_) + vim.opt_local.signcolumn = 'auto' + -- require("neo-tree").close_all() + end, + }, + }, + }, +} diff --git a/lua/plugins/nvim-cmp.lua b/lua/plugins/nvim-cmp.lua new file mode 100644 index 00000000000..443e97bc79c --- /dev/null +++ b/lua/plugins/nvim-cmp.lua @@ -0,0 +1,26 @@ +return { + -- Autocompletion + { + 'hrsh7th/nvim-cmp', + dependencies = { + 'tailwind-tools', + 'onsails/lspkind-nvim', + -- Snippet Engine & its associated nvim-cmp source + 'L3MON4D3/LuaSnip', + 'saadparwaiz1/cmp_luasnip', + -- Adds LSP completion capabilities + 'hrsh7th/cmp-nvim-lsp', + -- Adds a number of user-friendly snippets + 'rafamadriz/friendly-snippets', + }, + opts = function() + return { + formatting = { + format = require('lspkind').cmp_format { + before = require('tailwind-tools.cmp').lspkind_format, + }, + }, + } + end, + }, +} diff --git a/lua/plugins/nvim-java.lua b/lua/plugins/nvim-java.lua new file mode 100644 index 00000000000..c38647483ae --- /dev/null +++ b/lua/plugins/nvim-java.lua @@ -0,0 +1 @@ +return { "mfussenegger/nvim-jdtls" } diff --git a/lua/plugins/nvim-ufo.lua b/lua/plugins/nvim-ufo.lua new file mode 100644 index 00000000000..db84458d703 --- /dev/null +++ b/lua/plugins/nvim-ufo.lua @@ -0,0 +1 @@ +return { 'kevinhwang91/nvim-ufo', dependencies = 'kevinhwang91/promise-async' } diff --git a/lua/plugins/sleuth.lua b/lua/plugins/sleuth.lua new file mode 100644 index 00000000000..5654a920455 --- /dev/null +++ b/lua/plugins/sleuth.lua @@ -0,0 +1,7 @@ +return { + 'tpope/vim-sleuth', + config = function() + -- Your configuration for vim-sleuth goes here + end, + opts = {}, +} diff --git a/lua/plugins/surrond.lua b/lua/plugins/surrond.lua new file mode 100644 index 00000000000..64cd6a0b30b --- /dev/null +++ b/lua/plugins/surrond.lua @@ -0,0 +1,14 @@ +return { + 'echasnovski/mini.surround', + opts = { + mappings = { + add = 'gsa', -- Add surrounding in Normal and Visual modes + delete = 'gsd', -- Delete surrounding + find = 'gsf', -- Find surrounding (to the right) + find_left = 'gsF', -- Find surrounding (to the left) + highlight = 'gsh', -- Highlight surrounding + replace = 'gsr', -- Replace surrounding + update_n_lines = 'gsn', -- Update `n_lines` + }, + }, +} diff --git a/lua/plugins/tailwind-tools.lua b/lua/plugins/tailwind-tools.lua new file mode 100644 index 00000000000..e435d615200 --- /dev/null +++ b/lua/plugins/tailwind-tools.lua @@ -0,0 +1,11 @@ +return { + "luckasRanarison/tailwind-tools.nvim", + name = "tailwind-tools", + build = ":UpdateRemotePlugins", + dependencies = { + "nvim-treesitter/nvim-treesitter", + "nvim-telescope/telescope.nvim", -- optional + "neovim/nvim-lspconfig", -- optional + }, + opts = {} -- your configuration +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 00000000000..d20ee888202 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,19 @@ +return { + 'nvim-telescope/telescope.nvim', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + -- Fuzzy Finder Algorithm which requires local dependencies to be built. + -- Only load if `make` is available. Make sure you have the system + -- requirements installed. + { + 'nvim-telescope/telescope-fzf-native.nvim', + -- NOTE: If you are having trouble with this installation, + -- refer to the README for telescope-fzf-native for more instructions. + build = 'make', + cond = function() + return vim.fn.executable 'make' == 1 + end, + }, + }, + } diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 00000000000..d056f92d35a --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,36 @@ +return { + -- Highlight, edit, and navigate code + 'nvim-treesitter/nvim-treesitter', + dependencies = { + 'nvim-treesitter/nvim-treesitter-textobjects', + 'windwp/nvim-ts-autotag', + -- 'JoosepAlviste/nvim-ts-context-commentstring', + 'nvim-treesitter/nvim-treesitter-context', + }, + cmd = { + 'TSBufDisable', + 'TSBufEnable', + 'TSBufToggle', + 'TSDisable', + 'TSEnable', + 'TSToggle', + 'TSInstall', + 'TSInstallInfo', + 'TSInstallSync', + 'TSModuleInfo', + 'TSUninstall', + 'TSUpdate', + 'TSUpdateSync', + }, + build = ':TSUpdate', + opts = { + highlight = { + enable = true, + -- disable = function(_, bufnr) return vim.api.nvim_buf_line_count(bufnr) > 10000 end, + }, + incremental_selection = { enable = true }, + indent = { enable = true }, + autotag = { enable = true }, + context_commentstring = { enable = true, enable_autocmd = false }, + }, +} diff --git a/lua/plugins/undotree.lua b/lua/plugins/undotree.lua new file mode 100644 index 00000000000..7774a4a9eaf --- /dev/null +++ b/lua/plugins/undotree.lua @@ -0,0 +1 @@ +return { 'mbbill/undotree' } diff --git a/lua/plugins/vi-mongo.lua b/lua/plugins/vi-mongo.lua new file mode 100644 index 00000000000..82950134976 --- /dev/null +++ b/lua/plugins/vi-mongo.lua @@ -0,0 +1,10 @@ +return { + 'kopecmaciej/vi-mongo.nvim', + config = function() + require('vi-mongo').setup() + end, + cmd = { 'ViMongo' }, + keys = { + { 'vm', 'ViMongo', desc = 'ViMongo' }, + }, +} diff --git a/lua/plugins/which-key.lua b/lua/plugins/which-key.lua new file mode 100644 index 00000000000..ab4e2caa6a5 --- /dev/null +++ b/lua/plugins/which-key.lua @@ -0,0 +1 @@ +return { 'folke/which-key.nvim', opts = {} } diff --git a/lua/thrillee/editor-configs.lua b/lua/thrillee/editor-configs.lua new file mode 100644 index 00000000000..1b945f0ffc0 --- /dev/null +++ b/lua/thrillee/editor-configs.lua @@ -0,0 +1,65 @@ +-- [[ Basic Keymaps ]] +vim.o.relativenumber = true + +-- Make line numbers default +vim.wo.number = true + +-- Enable mouse mode +vim.o.mouse = 'a' + +-- Enable break indent +vim.o.breakindent = true + +-- Save undo history +vim.o.undofile = true + +-- Case-insensitive searching UNLESS \C or capital in search +vim.o.ignorecase = true +vim.o.smartcase = true + +-- Keep signcolumn on by default +vim.wo.signcolumn = 'yes' + +-- Decrease update time +--[[ vim.o.timeoutlen = 300 ]] + +-- Set completeopt to have a better completion experience +vim.o.completeopt = 'menuone,noselect' + +-- NOTE: You should make sure your terminal supports this +vim.o.termguicolors = true + +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true + +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = os.getenv 'HOME' .. '/.vim/undodir' + +vim.opt.smartindent = true + +vim.opt.wrap = false + +vim.opt.hlsearch = false +vim.opt.incsearch = true + +vim.opt.scrolloff = 8 +vim.opt.signcolumn = 'yes' +vim.opt.isfname:append '@-@' + +vim.opt.updatetime = 50 + +vim.opt.colorcolumn = '100' + +-- [[ Highlight on yank ]] +-- See `:help vim.highlight.on_yank()` +local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) +vim.api.nvim_create_autocmd('TextYankPost', { + callback = function() + vim.highlight.on_yank() + end, + group = highlight_group, + pattern = '*', +}) diff --git a/lua/thrillee/init.lua b/lua/thrillee/init.lua new file mode 100644 index 00000000000..353ed989c9a --- /dev/null +++ b/lua/thrillee/init.lua @@ -0,0 +1,3 @@ +require("thrillee.editor-configs") +require("thrillee.remaps") +require("thrillee.splits") diff --git a/lua/thrillee/remaps.lua b/lua/thrillee/remaps.lua new file mode 100644 index 00000000000..3d7808c5394 --- /dev/null +++ b/lua/thrillee/remaps.lua @@ -0,0 +1,37 @@ +-- Keymaps for better default experience +-- See `:help vim.keymap.set()` +vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) + +-- Remap for dealing with word wrap +vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) +vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) + +vim.keymap.set('i', 'jk', '') + +vim.keymap.set('n', 'w', 'w!', { desc = 'Save File' }) +vim.keymap.set('n', 'q', 'confirm q', { desc = 'Quit File' }) + +vim.keymap.set('v', '', '"*y', { desc = 'Copy to system clipboard' }) +vim.keymap.set('v', 'p', [["_dP]], { desc = 'Paste and retain paste in clipboard' }) +vim.keymap.set('n', 'sr', [[:%s/\<\>//gI]], { desc = 'Search and Replace Highlighted Word' }) + +vim.keymap.set('n', 'J', 'mzJ`z', { desc = 'Keep cusor in index position on J' }) + +-- Keep cusor in middle of buffer +vim.keymap.set('n', '', 'zz', { desc = '⬇ middle of buffer and keep cusor in middle of buffer' }) +vim.keymap.set('n', '', 'zz', { desc = '⬆ middle of buffer and keep cusor in middle of buffer' }) +vim.keymap.set('n', 'N', 'nzzzv', { desc = 'next search and keep cusor in middle of buffer' }) +vim.keymap.set('n', 'n', 'Nzzzv', { desc = 'previous search and keep cusor in middle of buffer' }) + +-- Move highlighted up or down +vim.keymap.set('v', 'J', ":m '>+1gv=gv", { desc = 'Move highlighted up' }) +vim.keymap.set('v', 'K', ":m '<-2gv=gv", { desc = 'Move highlighted down' }) + +-- Map c to close and save the buffer +vim.api.nvim_set_keymap('n', 'c', [[:w | bd]], { noremap = true, silent = true }) + +-- Map c quickfix list remaps +vim.api.nvim_set_keymap('n', 'cj', 'cnext', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'ck', 'cprev', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'cq', 'cclose', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'co', 'copen', { noremap = true, silent = true }) diff --git a/lua/thrillee/splits.lua b/lua/thrillee/splits.lua new file mode 100644 index 00000000000..fd771d46182 --- /dev/null +++ b/lua/thrillee/splits.lua @@ -0,0 +1,40 @@ +--[[ Split cmd ]] +vim.opt.splitbelow = true +vim.opt.splitright = true + +vim.keymap.set('n', '||', 'vsplit', { desc = 'Vertical Split' }) +vim.keymap.set('n', '--', 'split', { desc = 'Horinzontal Split' }) + +-- vim.keymap.set('n', '', 'h', { desc = 'Navigate to the left' }) +-- vim.keymap.set('n', '', '', { desc = 'Navigate below' }) +-- vim.keymap.set('n', '', 'k', { desc = 'Navigate up' }) +-- vim.keymap.set('n', '', 'l', { desc = 'Navigate right' }) + +vim.keymap.set('n', 'sh', 'h', { desc = 'Navigate to the left' }) +vim.keymap.set('n', 'sj', '', { desc = 'Navigate below' }) +vim.keymap.set('n', 'sk', 'k', { desc = 'Navigate up' }) +vim.keymap.set('n', 'sl', 'l', { desc = 'Navigate right' }) + +vim.keymap.set('n', 'hh', ':vertical resize +3', { silent = true }) +vim.keymap.set('n', 'll', ':vertical resize -3', { silent = true }) +vim.keymap.set('n', 'kk', ':resize +3', { silent = true }) +vim.keymap.set('n', 'jj', ':resize -3', { silent = true }) + +vim.g.original_size = nil + +function Toggle_maximize_pane() + local winnr = vim.api.nvim_get_current_win() + local width = vim.api.nvim_win_get_width(winnr) + local height = vim.api.nvim_win_get_height(winnr) + if vim.g.original_size == nil then + vim.g.original_size = { width, height } + vim.api.nvim_win_set_width(winnr, vim.o.columns) + vim.api.nvim_win_set_height(winnr, vim.o.lines) + else + vim.api.nvim_win_set_width(winnr, vim.g.original_size[1]) + vim.api.nvim_win_set_height(winnr, vim.g.original_size[2]) + vim.g.original_size = nil + end +end + +vim.keymap.set('n', '', 'lua Toggle_maximize_pane()', { noremap = true, desc = 'Maximize Current Split' }) diff --git a/nvim-jdtls.lua b/nvim-jdtls.lua new file mode 100644 index 00000000000..00044ebd1fc --- /dev/null +++ b/nvim-jdtls.lua @@ -0,0 +1,6 @@ +return { + 'mfussenegger/nvim-jdtls', + dependencies = { + 'nvim-lua/plenary.nvim', + }, +}