From c6dbd5bb6ff8e850192d7f1ce967bff313097f7b Mon Sep 17 00:00:00 2001 From: DaceKonn Date: Mon, 1 Jul 2024 13:48:34 +0200 Subject: [PATCH 1/7] DaceKonn - first personalizations and configs --- init.lua | 26 ++++++++++++++++---------- lua/dacekonn/plugins/centerpad.lua | 7 +++++++ lua/dacekonn/plugins/stay-centered.lua | 3 +++ 3 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 lua/dacekonn/plugins/centerpad.lua create mode 100644 lua/dacekonn/plugins/stay-centered.lua diff --git a/init.lua b/init.lua index 88658ef3033..9275421c39f 100644 --- a/init.lua +++ b/init.lua @@ -91,7 +91,13 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true + +-- NOTE: my neovide options +-- [[ Neovide ]] +vim.o.guifont = 'FiraCode Nerd Font' +vim.opt.linespace = 15 +vim.g.neovide_scale_factor = 0.7 -- [[ Setting options ]] -- See `:help vim.opt` @@ -102,7 +108,7 @@ vim.g.have_nerd_font = false vim.opt.number = true -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true +vim.opt.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -152,7 +158,7 @@ vim.opt.inccommand = 'split' vim.opt.cursorline = true -- Minimal number of screen lines to keep above and below the cursor. -vim.opt.scrolloff = 10 +vim.opt.scrolloff = 20 -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` @@ -873,19 +879,19 @@ require('lazy').setup({ -- Here are some example plugins that I've included in the Kickstart repository. -- Uncomment any of the lines below to enable them (you will need to restart nvim). -- - -- require 'kickstart.plugins.debug', - -- require 'kickstart.plugins.indent_line', - -- require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', - -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + require 'kickstart.plugins.debug', + require 'kickstart.plugins.indent_line', + require 'kickstart.plugins.lint', + require 'kickstart.plugins.autopairs', + require 'kickstart.plugins.neo-tree', + require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- This is the easiest way to modularize your config. -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - -- { import = 'custom.plugins' }, + { import = 'dacekonn.plugins'}, }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the diff --git a/lua/dacekonn/plugins/centerpad.lua b/lua/dacekonn/plugins/centerpad.lua new file mode 100644 index 00000000000..29144fd4164 --- /dev/null +++ b/lua/dacekonn/plugins/centerpad.lua @@ -0,0 +1,7 @@ +return { + { -- Add indentation guides even on blank lines + 'smithbm2316/centerpad.nvim', + -- Enable `lukas-reineke/indent-blankline.nvim` + -- See `:help ibl` + }, +} diff --git a/lua/dacekonn/plugins/stay-centered.lua b/lua/dacekonn/plugins/stay-centered.lua new file mode 100644 index 00000000000..6a762f6d64f --- /dev/null +++ b/lua/dacekonn/plugins/stay-centered.lua @@ -0,0 +1,3 @@ +return { + 'arnamak/stay-centered.nvim', +} From 3fd39057dd186eb24b654189316bb5c8f36c6c42 Mon Sep 17 00:00:00 2001 From: DaceKonn Date: Wed, 3 Jul 2024 14:27:20 +0200 Subject: [PATCH 2/7] Add java lsp and neogit --- ftplugin/java.lua | 72 ++++++++ init.lua | 6 +- lua/dacekonn/plugins/git.lua | 313 +++++++++++++++++++++++++++++++++++ 3 files changed, 389 insertions(+), 2 deletions(-) create mode 100644 ftplugin/java.lua create mode 100644 lua/dacekonn/plugins/git.lua diff --git a/ftplugin/java.lua b/ftplugin/java.lua new file mode 100644 index 00000000000..033ae89061f --- /dev/null +++ b/ftplugin/java.lua @@ -0,0 +1,72 @@ +local home = os.getenv 'HOME' +local share = '/AppData/Local/nvim-data' +local workspace_path = home .. share .. '/jdtls-workspace/' +local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t') +local workspace_dir = workspace_path .. project_name + +local status, jdtls = pcall(require, 'jdtls') +if not status then + return +end +local extendedClientCapabilities = jdtls.extendedClientCapabilities + +local config = { + cmd = { + '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', + '-Xmx1g', + '--add-modules=ALL-SYSTEM', + '--add-opens', + 'java.base/java.util=ALL-UNNAMED', + '--add-opens', + 'java.base/java.lang=ALL-UNNAMED', + '-javaagent:' .. home .. share .. '/mason/packages/jdtls/lombok.jar', + '-jar', + vim.fn.glob(home .. share .. '/mason/packages/jdtls/plugins/org.eclipse.equinox.launcher_*.jar'), + '-configuration', + home .. share .. '/mason/packages/jdtls/config_win', + '-data', + workspace_dir, + }, + root_dir = require('jdtls.setup').find_root { '.git', 'mvnw', 'gradlew', 'pom.xml', 'build.gradle' }, + + settings = { + java = { + signatureHelp = { enabled = true }, + extendedClientCapabilities = extendedClientCapabilities, + maven = { + downloadSources = true, + }, + referencesCodeLens = { + enabled = true, + }, + references = { + includeDecompiledSources = true, + }, + inlayHints = { + parameterNames = { + enabled = 'all', -- literals, all, none + }, + }, + format = { + enabled = false, + }, + }, + }, + + init_options = { + bundles = {}, + }, +} +require('jdtls').start_or_attach(config) + +vim.keymap.set('n', 'co', "lua require'jdtls'.organize_imports()", { desc = 'Organize Imports' }) +vim.keymap.set('n', 'crv', "lua require('jdtls').extract_variable()", { desc = 'Extract Variable' }) +vim.keymap.set('v', 'crv', "lua require('jdtls').extract_variable(true)", { desc = 'Extract Variable' }) +vim.keymap.set('n', 'crc', "lua require('jdtls').extract_constant()", { desc = 'Extract Constant' }) +vim.keymap.set('v', 'crc', "lua require('jdtls').extract_constant(true)", { desc = 'Extract Constant' }) +vim.keymap.set('v', 'crm', "lua require('jdtls').extract_method(true)", { desc = 'Extract Method' }) diff --git a/init.lua b/init.lua index 9275421c39f..b752484b1f7 100644 --- a/init.lua +++ b/init.lua @@ -414,6 +414,8 @@ require('lazy').setup({ end, }, + { 'mfussenegger/nvim-jdtls' }, + { -- LSP Configuration & Plugins 'neovim/nvim-lspconfig', dependencies = { @@ -841,7 +843,7 @@ require('lazy').setup({ 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc' }, + ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc', 'java' }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -891,7 +893,7 @@ require('lazy').setup({ -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - { import = 'dacekonn.plugins'}, + { import = 'dacekonn.plugins' }, }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the diff --git a/lua/dacekonn/plugins/git.lua b/lua/dacekonn/plugins/git.lua new file mode 100644 index 00000000000..d627542a8a1 --- /dev/null +++ b/lua/dacekonn/plugins/git.lua @@ -0,0 +1,313 @@ +return { + 'NeogitOrg/neogit', + dependencies = { + 'nvim-lua/plenary.nvim', -- required + 'sindrets/diffview.nvim', -- optional - Diff integration + + -- Only one of these is needed, not both. + 'nvim-telescope/telescope.nvim', -- optional + 'ibhagwan/fzf-lua', -- optional + }, + config = function() + local neogit = require 'neogit' + + neogit.setup { + -- Hides the hints at the top of the status buffer + disable_hint = false, + -- Disables changing the buffer highlights based on where the cursor is. + disable_context_highlighting = false, + -- Disables signs for sections/items/hunks + disable_signs = false, + -- Changes what mode the Commit Editor starts in. `true` will leave nvim in normal mode, `false` will change nvim to + -- insert mode, and `"auto"` will change nvim to insert mode IF the commit message is empty, otherwise leaving it in + -- normal mode. + disable_insert_on_commit = 'auto', + -- When enabled, will watch the `.git/` directory for changes and refresh the status buffer in response to filesystem + -- events. + filewatcher = { + interval = 1000, + enabled = true, + }, + -- "ascii" is the graph the git CLI generates + -- "unicode" is the graph like https://github.com/rbong/vim-flog + graph_style = 'ascii', + -- Used to generate URL's for branch popup action "pull request". + git_services = { + ['github.com'] = 'https://github.com/${owner}/${repository}/compare/${branch_name}?expand=1', + ['bitbucket.org'] = 'https://bitbucket.org/${owner}/${repository}/pull-requests/new?source=${branch_name}&t=1', + ['gitlab.com'] = 'https://gitlab.com/${owner}/${repository}/merge_requests/new?merge_request[source_branch]=${branch_name}', + ['azure.com'] = 'https://dev.azure.com/${owner}/_git/${repository}/pullrequestcreate?sourceRef=${branch_name}&targetRef=${target}', + }, + -- Allows a different telescope sorter. Defaults to 'fuzzy_with_index_bias'. The example below will use the native fzf + -- sorter instead. By default, this function returns `nil`. + telescope_sorter = function() + return require('telescope').extensions.fzf.native_fzf_sorter() + end, + -- Persist the values of switches/options within and across sessions + remember_settings = true, + -- Scope persisted settings on a per-project basis + use_per_project_settings = true, + -- Table of settings to never persist. Uses format "Filetype--cli-value" + ignored_settings = { + 'NeogitPushPopup--force-with-lease', + 'NeogitPushPopup--force', + 'NeogitPullPopup--rebase', + 'NeogitCommitPopup--allow-empty', + 'NeogitRevertPopup--no-edit', + }, + -- Configure highlight group features + highlight = { + italic = true, + bold = true, + underline = true, + }, + -- Set to false if you want to be responsible for creating _ALL_ keymappings + use_default_keymaps = true, + -- Neogit refreshes its internal state after specific events, which can be expensive depending on the repository size. + -- Disabling `auto_refresh` will make it so you have to manually refresh the status after you open it. + auto_refresh = true, + -- Value used for `--sort` option for `git branch` command + -- By default, branches will be sorted by commit date descending + -- Flag description: https://git-scm.com/docs/git-branch#Documentation/git-branch.txt---sortltkeygt + -- Sorting keys: https://git-scm.com/docs/git-for-each-ref#_options + sort_branches = '-committerdate', + -- Change the default way of opening neogit + kind = 'tab', + -- Disable line numbers and relative line numbers + disable_line_numbers = true, + -- The time after which an output console is shown for slow running commands + console_timeout = 2000, + -- Automatically show console if a command takes more than console_timeout milliseconds + auto_show_console = true, + -- Automatically close the console if the process exits with a 0 (success) status + auto_close_console = true, + status = { + show_head_commit_hash = true, + recent_commit_count = 10, + HEAD_padding = 10, + HEAD_folded = false, + mode_padding = 3, + mode_text = { + M = 'modified', + N = 'new file', + A = 'added', + D = 'deleted', + C = 'copied', + U = 'updated', + R = 'renamed', + DD = 'unmerged', + AU = 'unmerged', + UD = 'unmerged', + UA = 'unmerged', + DU = 'unmerged', + AA = 'unmerged', + UU = 'unmerged', + ['?'] = '', + }, + }, + commit_editor = { + kind = 'tab', + show_staged_diff = true, + -- Accepted values: + -- "split" to show the staged diff below the commit editor + -- "vsplit" to show it to the right + -- "split_above" Like :top split + -- "vsplit_left" like :vsplit, but open to the left + -- "auto" "vsplit" if window would have 80 cols, otherwise "split" + staged_diff_split_kind = 'split', + }, + commit_select_view = { + kind = 'tab', + }, + commit_view = { + kind = 'vsplit', + verify_commit = vim.fn.executable 'gpg' == 1, -- Can be set to true or false, otherwise we try to find the binary + }, + log_view = { + kind = 'tab', + }, + rebase_editor = { + kind = 'auto', + }, + reflog_view = { + kind = 'tab', + }, + merge_editor = { + kind = 'auto', + }, + tag_editor = { + kind = 'auto', + }, + preview_buffer = { + kind = 'split', + }, + popup = { + kind = 'split', + }, + signs = { + -- { CLOSED, OPENED } + hunk = { '', '' }, + item = { '>', 'v' }, + section = { '>', 'v' }, + }, + -- Each Integration is auto-detected through plugin presence, however, it can be disabled by setting to `false` + integrations = { + -- If enabled, use telescope for menu selection rather than vim.ui.select. + -- Allows multi-select and some things that vim.ui.select doesn't. + telescope = nil, + -- Neogit only provides inline diffs. If you want a more traditional way to look at diffs, you can use `diffview`. + -- The diffview integration enables the diff popup. + -- + -- Requires you to have `sindrets/diffview.nvim` installed. + diffview = nil, + + -- If enabled, uses fzf-lua for menu selection. If the telescope integration + -- is also selected then telescope is used instead + -- Requires you to have `ibhagwan/fzf-lua` installed. + fzf_lua = nil, + }, + sections = { + -- Reverting/Cherry Picking + sequencer = { + folded = false, + hidden = false, + }, + untracked = { + folded = false, + hidden = false, + }, + unstaged = { + folded = false, + hidden = false, + }, + staged = { + folded = false, + hidden = false, + }, + stashes = { + folded = true, + hidden = false, + }, + unpulled_upstream = { + folded = true, + hidden = false, + }, + unmerged_upstream = { + folded = false, + hidden = false, + }, + unpulled_pushRemote = { + folded = true, + hidden = false, + }, + unmerged_pushRemote = { + folded = false, + hidden = false, + }, + recent = { + folded = true, + hidden = false, + }, + rebase = { + folded = true, + hidden = false, + }, + }, + mappings = { + commit_editor = { + ['q'] = 'Close', + [''] = 'Submit', + [''] = 'Abort', + }, + commit_editor_I = { + [''] = 'Submit', + [''] = 'Abort', + }, + rebase_editor = { + ['p'] = 'Pick', + ['r'] = 'Reword', + ['e'] = 'Edit', + ['s'] = 'Squash', + ['f'] = 'Fixup', + ['x'] = 'Execute', + ['d'] = 'Drop', + ['b'] = 'Break', + ['q'] = 'Close', + [''] = 'OpenCommit', + ['gk'] = 'MoveUp', + ['gj'] = 'MoveDown', + [''] = 'Submit', + [''] = 'Abort', + ['[c'] = 'OpenOrScrollUp', + [']c'] = 'OpenOrScrollDown', + }, + rebase_editor_I = { + [''] = 'Submit', + [''] = 'Abort', + }, + finder = { + [''] = 'Select', + [''] = 'Close', + [''] = 'Close', + [''] = 'Next', + [''] = 'Previous', + [''] = 'Next', + [''] = 'Previous', + [''] = 'MultiselectToggleNext', + [''] = 'MultiselectTogglePrevious', + [''] = 'NOP', + }, + -- Setting any of these to `false` will disable the mapping. + popup = { + ['?'] = 'HelpPopup', + ['A'] = 'CherryPickPopup', + ['D'] = 'DiffPopup', + ['M'] = 'RemotePopup', + ['P'] = 'PushPopup', + ['X'] = 'ResetPopup', + ['Z'] = 'StashPopup', + ['b'] = 'BranchPopup', + ['B'] = 'BisectPopup', + ['c'] = 'CommitPopup', + ['f'] = 'FetchPopup', + ['l'] = 'LogPopup', + ['m'] = 'MergePopup', + ['p'] = 'PullPopup', + ['r'] = 'RebasePopup', + ['v'] = 'RevertPopup', + ['w'] = 'WorktreePopup', + }, + status = { + ['k'] = 'MoveUp', + ['j'] = 'MoveDown', + ['q'] = 'Close', + ['o'] = 'OpenTree', + ['I'] = 'InitRepo', + ['1'] = 'Depth1', + ['2'] = 'Depth2', + ['3'] = 'Depth3', + ['4'] = 'Depth4', + [''] = 'Toggle', + ['x'] = 'Discard', + ['s'] = 'Stage', + ['S'] = 'StageUnstaged', + [''] = 'StageAll', + ['K'] = 'Untrack', + ['u'] = 'Unstage', + ['U'] = 'UnstageStaged', + ['$'] = 'CommandHistory', + ['Y'] = 'YankSelected', + [''] = 'RefreshBuffer', + [''] = 'GoToFile', + [''] = 'VSplitOpen', + [''] = 'SplitOpen', + [''] = 'TabOpen', + ['{'] = 'GoToPreviousHunkHeader', + ['}'] = 'GoToNextHunkHeader', + ['[c'] = 'OpenOrScrollUp', + [']c'] = 'OpenOrScrollDown', + }, + }, + } + end, +} From dc77b0d16c1a59ae6208b8196f9b8c251f84dae6 Mon Sep 17 00:00:00 2001 From: DaceKonn Date: Thu, 4 Jul 2024 13:36:21 +0200 Subject: [PATCH 3/7] update configs --- ftplugin/java.lua | 1 + init.lua | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/ftplugin/java.lua b/ftplugin/java.lua index 033ae89061f..a523b44c29c 100644 --- a/ftplugin/java.lua +++ b/ftplugin/java.lua @@ -36,6 +36,7 @@ local config = { settings = { java = { + home = 'c:/Program Files/Java/jdk-17', signatureHelp = { enabled = true }, extendedClientCapabilities = extendedClientCapabilities, maven = { diff --git a/init.lua b/init.lua index b752484b1f7..589da7b95d2 100644 --- a/init.lua +++ b/init.lua @@ -615,6 +615,13 @@ require('lazy').setup({ local ensure_installed = vim.tbl_keys(servers or {}) vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code + 'gopls', + 'jdtls', + 'yaml-language-server', + 'lua-language-server', + 'csharp-language-server', + 'rust-analyzer', + 'marksman', }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } From 7bdc5450212aa26aae2dd4a76c0c930ba8dfe2cc Mon Sep 17 00:00:00 2001 From: Piotr Wolny Date: Thu, 4 Jul 2024 19:10:09 +0200 Subject: [PATCH 4/7] remove csharp lsp from Mason ensure installed --- init.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/init.lua b/init.lua index 589da7b95d2..fd345214a9f 100644 --- a/init.lua +++ b/init.lua @@ -619,7 +619,6 @@ require('lazy').setup({ 'jdtls', 'yaml-language-server', 'lua-language-server', - 'csharp-language-server', 'rust-analyzer', 'marksman', }) From 0a1df33611562e7b8cb0293d231a1aa3842cf51d Mon Sep 17 00:00:00 2001 From: DaceKonn Date: Fri, 5 Jul 2024 12:11:41 +0200 Subject: [PATCH 5/7] Add xml suport and java formatting, also vim-be-good for practice --- init.lua | 3 +++ lua/dacekonn/plugins/vim-be-good.lua | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 lua/dacekonn/plugins/vim-be-good.lua diff --git a/init.lua b/init.lua index fd345214a9f..2a55b0fd319 100644 --- a/init.lua +++ b/init.lua @@ -621,6 +621,9 @@ require('lazy').setup({ 'lua-language-server', 'rust-analyzer', 'marksman', + 'xmlformatter', + 'lemminx', + 'google-java-format', }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } diff --git a/lua/dacekonn/plugins/vim-be-good.lua b/lua/dacekonn/plugins/vim-be-good.lua new file mode 100644 index 00000000000..b1e2a54318f --- /dev/null +++ b/lua/dacekonn/plugins/vim-be-good.lua @@ -0,0 +1,3 @@ +return { + 'ThePrimeagen/vim-be-good', +} From dfd5db86b614bd647eeb405f0f634fce5f02c48c Mon Sep 17 00:00:00 2001 From: DaceKonn Date: Fri, 1 Nov 2024 18:39:12 +0100 Subject: [PATCH 6/7] add zig and zls --- init.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 2a55b0fd319..b78e90c16d4 100644 --- a/init.lua +++ b/init.lua @@ -585,7 +585,9 @@ require('lazy').setup({ -- But for many setups, the LSP (`tsserver`) will work just fine -- tsserver = {}, -- - + zls = { + cmd = { 'zls' }, + }, lua_ls = { -- cmd = {...}, -- filetypes = { ...}, @@ -669,6 +671,7 @@ require('lazy').setup({ end, formatters_by_ft = { lua = { 'stylua' }, + zig = { 'zig fmt' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- From 8a71fd67702d297f274ecfb72222a2650423ee3f Mon Sep 17 00:00:00 2001 From: DaceKonn Date: Fri, 6 Dec 2024 19:57:30 +0100 Subject: [PATCH 7/7] go related configs --- init.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/init.lua b/init.lua index b78e90c16d4..f72448056a1 100644 --- a/init.lua +++ b/init.lua @@ -585,6 +585,20 @@ require('lazy').setup({ -- But for many setups, the LSP (`tsserver`) will work just fine -- tsserver = {}, -- + gopls = { + capabilities = capabilities, + cmd = { 'gopls' }, + filetypes = { 'go', 'gomod', 'gowork', 'gotmpl' }, + settings = { + gopls = { + completeUnimported = true, + usePlaceholders = true, + analyses = { + unusedparams = true, + }, + }, + }, + }, zls = { cmd = { 'zls' }, },