fix java and cleanup
This commit is contained in:
parent
6171b6b704
commit
7123bf8ae6
|
|
@ -1,24 +0,0 @@
|
|||
================================================================================
|
||||
INTRODUCTION *kickstart.nvim*
|
||||
|
||||
Kickstart.nvim is a project to help you get started on your neovim journey.
|
||||
|
||||
*kickstart-is-not*
|
||||
It is not:
|
||||
- Complete framework for every plugin under the sun
|
||||
- Place to add every plugin that could ever be useful
|
||||
|
||||
*kickstart-is*
|
||||
It is:
|
||||
- Somewhere that has a good start for the most common "IDE" type features:
|
||||
- autocompletion
|
||||
- goto-definition
|
||||
- find references
|
||||
- fuzzy finding
|
||||
- and hinting at what more can be done :)
|
||||
- A place to _kickstart_ your journey.
|
||||
- You should fork this project and use/modify it so that it matches your
|
||||
style and preferences. If you don't want to do that, there are probably
|
||||
other projects that would fit much better for you (and that's great!)!
|
||||
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
||||
3
doc/tags
3
doc/tags
|
|
@ -1,3 +0,0 @@
|
|||
kickstart-is kickstart.txt /*kickstart-is*
|
||||
kickstart-is-not kickstart.txt /*kickstart-is-not*
|
||||
kickstart.nvim kickstart.txt /*kickstart.nvim*
|
||||
|
|
@ -1,271 +0,0 @@
|
|||
local java_cmds = vim.api.nvim_create_augroup('java_cmds', { clear = true })
|
||||
local cache_vars = {}
|
||||
|
||||
-- Here you can add files/folders that you use at
|
||||
-- the root of your project. `nvim-jdtls` will use
|
||||
-- these to find the path to your project source code.
|
||||
local root_files = {
|
||||
'.git',
|
||||
|
||||
--- here are more examples files that may or
|
||||
--- may not work as root files, according to some guy on the internet
|
||||
-- 'mvnw',
|
||||
-- 'gradlew',
|
||||
-- 'pom.xml',
|
||||
-- 'build.gradle',
|
||||
}
|
||||
|
||||
local features = {
|
||||
-- change this to `true` to enable codelens
|
||||
codelens = false,
|
||||
|
||||
-- change this to `true` if you have `nvim-dap`,
|
||||
-- `java-test` and `java-debug-adapter` installed
|
||||
debugger = false,
|
||||
}
|
||||
|
||||
local function get_jdtls_paths()
|
||||
if cache_vars.paths then
|
||||
return cache_vars.paths
|
||||
end
|
||||
|
||||
local path = {}
|
||||
|
||||
path.data_dir = vim.fn.stdpath 'cache' .. '/nvim-jdtls'
|
||||
|
||||
local jdtls_install = require('mason-registry').get_package('jdtls'):get_install_path()
|
||||
|
||||
path.java_agent = jdtls_install .. '/lombok.jar'
|
||||
path.launcher_jar = vim.fn.glob(jdtls_install .. '/plugins/org.eclipse.equinox.launcher_*.jar')
|
||||
|
||||
if vim.fn.has 'mac' == 1 then
|
||||
path.platform_config = jdtls_install .. '/config_mac'
|
||||
elseif vim.fn.has 'unix' == 1 then
|
||||
path.platform_config = jdtls_install .. '/config_linux'
|
||||
elseif vim.fn.has 'win32' == 1 then
|
||||
path.platform_config = jdtls_install .. '/config_win'
|
||||
end
|
||||
|
||||
path.bundles = {}
|
||||
|
||||
---
|
||||
-- Include java-test bundle if present
|
||||
---
|
||||
local java_test_path = require('mason-registry').get_package('java-test'):get_install_path()
|
||||
|
||||
local java_test_bundle = vim.split(vim.fn.glob(java_test_path .. '/extension/server/*.jar'), '\n')
|
||||
|
||||
if java_test_bundle[1] ~= '' then
|
||||
vim.list_extend(path.bundles, java_test_bundle)
|
||||
end
|
||||
|
||||
---
|
||||
-- Include java-debug-adapter bundle if present
|
||||
---
|
||||
local java_debug_path = require('mason-registry').get_package('java-debug-adapter'):get_install_path()
|
||||
|
||||
local java_debug_bundle = vim.split(vim.fn.glob(java_debug_path .. '/extension/server/com.microsoft.java.debug.plugin-*.jar'), '\n')
|
||||
|
||||
if java_debug_bundle[1] ~= '' then
|
||||
vim.list_extend(path.bundles, java_debug_bundle)
|
||||
end
|
||||
|
||||
---
|
||||
-- Useful if you're starting jdtls with a Java version that's
|
||||
-- different from the one the project uses.
|
||||
---
|
||||
path.runtimes = {
|
||||
-- Note: the field `name` must be a valid `ExecutionEnvironment`,
|
||||
-- you can find the list here:
|
||||
-- https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request
|
||||
{
|
||||
name = 'JavaSE-21',
|
||||
path = vim.fn.expand '~/.sdkman/candidates/java/21.0.1-amzn',
|
||||
},
|
||||
}
|
||||
|
||||
cache_vars.paths = path
|
||||
|
||||
return path
|
||||
end
|
||||
|
||||
local function enable_codelens(bufnr)
|
||||
pcall(vim.lsp.codelens.refresh)
|
||||
|
||||
vim.api.nvim_create_autocmd('BufWritePost', {
|
||||
buffer = bufnr,
|
||||
group = java_cmds,
|
||||
desc = 'refresh codelens',
|
||||
callback = function()
|
||||
pcall(vim.lsp.codelens.refresh)
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
local function enable_debugger(bufnr)
|
||||
require('jdtls').setup_dap { hotcodereplace = 'auto' }
|
||||
require('jdtls.dap').setup_dap_main_class_configs()
|
||||
|
||||
local opts = { buffer = bufnr }
|
||||
vim.keymap.set('n', '<leader>df', "<cmd>lua require('jdtls').test_class()<cr>", opts)
|
||||
vim.keymap.set('n', '<leader>dn', "<cmd>lua require('jdtls').test_nearest_method()<cr>", opts)
|
||||
end
|
||||
|
||||
local function jdtls_on_attach(client, bufnr)
|
||||
if features.debugger then
|
||||
enable_debugger(bufnr)
|
||||
end
|
||||
|
||||
if features.codelens then
|
||||
enable_codelens(bufnr)
|
||||
end
|
||||
|
||||
-- The following mappings are based on the suggested usage of nvim-jdtls
|
||||
-- https://github.com/mfussenegger/nvim-jdtls#usage
|
||||
|
||||
local opts = { buffer = bufnr }
|
||||
vim.keymap.set('n', '<A-o>', "<cmd>lua require('jdtls').organize_imports()<cr>", opts)
|
||||
vim.keymap.set('n', 'crv', "<cmd>lua require('jdtls').extract_variable()<cr>", opts)
|
||||
vim.keymap.set('x', 'crv', "<esc><cmd>lua require('jdtls').extract_variable(true)<cr>", opts)
|
||||
vim.keymap.set('n', 'crc', "<cmd>lua require('jdtls').extract_constant()<cr>", opts)
|
||||
vim.keymap.set('x', 'crc', "<esc><cmd>lua require('jdtls').extract_constant(true)<cr>", opts)
|
||||
vim.keymap.set('x', 'crm', "<esc><Cmd>lua require('jdtls').extract_method(true)<cr>", opts)
|
||||
end
|
||||
|
||||
local function jdtls_setup(event)
|
||||
local jdtls = require 'jdtls'
|
||||
|
||||
local path = get_jdtls_paths()
|
||||
local data_dir = path.data_dir .. '/' .. vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t')
|
||||
|
||||
if cache_vars.capabilities == nil then
|
||||
jdtls.extendedClientCapabilities.resolveAdditionalTextEditsSupport = true
|
||||
|
||||
local ok_cmp, cmp_lsp = pcall(require, 'cmp_nvim_lsp')
|
||||
cache_vars.capabilities = vim.tbl_deep_extend('force', vim.lsp.protocol.make_client_capabilities(), ok_cmp and cmp_lsp.default_capabilities() or {})
|
||||
end
|
||||
|
||||
-- The command that starts the language server
|
||||
-- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line
|
||||
local 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',
|
||||
'-javaagent:' .. path.java_agent,
|
||||
'-Xms1g',
|
||||
'--add-modules=ALL-SYSTEM',
|
||||
'--add-opens',
|
||||
'java.base/java.util=ALL-UNNAMED',
|
||||
'--add-opens',
|
||||
'java.base/java.lang=ALL-UNNAMED',
|
||||
|
||||
-- 💀
|
||||
'-jar',
|
||||
path.launcher_jar,
|
||||
|
||||
-- 💀
|
||||
'-configuration',
|
||||
path.platform_config,
|
||||
|
||||
-- 💀
|
||||
'-data',
|
||||
data_dir,
|
||||
}
|
||||
|
||||
local home = os.getenv 'HOME'
|
||||
local lsp_settings = {
|
||||
java = {
|
||||
-- jdt = {
|
||||
-- ls = {
|
||||
-- vmargs = "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx1G -Xms100m"
|
||||
-- }
|
||||
-- },
|
||||
eclipse = {
|
||||
downloadSources = true,
|
||||
},
|
||||
configuration = {
|
||||
updateBuildConfiguration = 'interactive',
|
||||
runtimes = path.runtimes,
|
||||
},
|
||||
maven = {
|
||||
downloadSources = true,
|
||||
},
|
||||
implementationsCodeLens = {
|
||||
enabled = true,
|
||||
},
|
||||
referencesCodeLens = {
|
||||
enabled = true,
|
||||
},
|
||||
-- inlayHints = {
|
||||
-- parameterNames = {
|
||||
-- enabled = 'all' -- literals, all, none
|
||||
-- }
|
||||
-- },
|
||||
format = {
|
||||
enabled = true,
|
||||
settings = {
|
||||
url = home .. '/.config/nvim/clavisit-eclipse-code-formatter.xml',
|
||||
profile = 'ClavisJavaStyle',
|
||||
},
|
||||
},
|
||||
},
|
||||
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.*',
|
||||
},
|
||||
},
|
||||
contentProvider = {
|
||||
preferred = 'fernflower',
|
||||
},
|
||||
extendedClientCapabilities = jdtls.extendedClientCapabilities,
|
||||
sources = {
|
||||
organizeImports = {
|
||||
starThreshold = 9999,
|
||||
staticStarThreshold = 9999,
|
||||
},
|
||||
},
|
||||
codeGeneration = {
|
||||
toString = {
|
||||
template = '${object.className}{${member.name()}=${member.value}, ${otherMembers}}',
|
||||
},
|
||||
useBlocks = true,
|
||||
},
|
||||
}
|
||||
|
||||
-- This starts a new client & server,
|
||||
-- or attaches to an existing client & server depending on the `root_dir`.
|
||||
jdtls.start_or_attach {
|
||||
cmd = cmd,
|
||||
settings = lsp_settings,
|
||||
on_attach = jdtls_on_attach,
|
||||
capabilities = cache_vars.capabilities,
|
||||
root_dir = jdtls.setup.find_root(root_files),
|
||||
flags = {
|
||||
allow_incremental_sync = true,
|
||||
},
|
||||
init_options = {
|
||||
bundles = path.bundles,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
group = java_cmds,
|
||||
pattern = { 'java' },
|
||||
desc = 'Setup jdtls',
|
||||
callback = jdtls_setup,
|
||||
})
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
-- "gc" to comment visual regions/lines
|
||||
return { 'numToStr/Comment.nvim', opts = {} }
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
return { -- Adds git related signs to the gutter, as well as utilities for managing changes
|
||||
'lewis6991/gitsigns.nvim',
|
||||
opts = {
|
||||
signs = {
|
||||
add = { text = '+' },
|
||||
change = { text = '~' },
|
||||
delete = { text = '_' },
|
||||
topdelete = { text = '‾' },
|
||||
changedelete = { text = '~' },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
return { 'mfussenegger/nvim-jdtls' }
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
return { -- Fuzzy Finder (files, lsp, etc)
|
||||
'nvim-telescope/telescope.nvim',
|
||||
event = 'VimEnter',
|
||||
branch = '0.1.x',
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
{ -- If encountering errors, see telescope-fzf-native README for installation instructions
|
||||
'nvim-telescope/telescope-fzf-native.nvim',
|
||||
|
||||
-- `build` is used to run some command when the plugin is installed/updated.
|
||||
-- This is only run then, not every time Neovim starts up.
|
||||
build = 'make',
|
||||
|
||||
-- `cond` is a condition used to determine whether this plugin should be
|
||||
-- installed and loaded.
|
||||
cond = function()
|
||||
return vim.fn.executable 'make' == 1
|
||||
end,
|
||||
},
|
||||
{ 'nvim-telescope/telescope-ui-select.nvim' },
|
||||
|
||||
-- Useful for getting pretty icons, but requires a Nerd Font.
|
||||
{ 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
|
||||
},
|
||||
config = function()
|
||||
-- [[ Configure Telescope ]]
|
||||
-- See `:help telescope` and `:help telescope.setup()`
|
||||
require('telescope').setup {
|
||||
-- You can put your default mappings / updates / etc. in here
|
||||
-- All the info you're looking for is in `:help telescope.setup()`
|
||||
--
|
||||
-- defaults = {
|
||||
-- mappings = {
|
||||
-- i = { ['<c-enter>'] = 'to_fuzzy_refine' },
|
||||
-- },
|
||||
-- },
|
||||
-- pickers = {}
|
||||
extensions = {
|
||||
['ui-select'] = {
|
||||
require('telescope.themes').get_dropdown(),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- Enable Telescope extensions if they are installed
|
||||
pcall(require('telescope').load_extension, 'fzf')
|
||||
pcall(require('telescope').load_extension, 'ui-select')
|
||||
|
||||
-- See `:help telescope.builtin`
|
||||
local builtin = require 'telescope.builtin'
|
||||
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
|
||||
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
|
||||
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
|
||||
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
|
||||
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
|
||||
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
|
||||
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
|
||||
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
|
||||
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
|
||||
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
|
||||
|
||||
-- Slightly advanced example of overriding default behavior and theme
|
||||
vim.keymap.set('n', '<leader>/', function()
|
||||
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
|
||||
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
|
||||
winblend = 10,
|
||||
previewer = false,
|
||||
})
|
||||
end, { desc = '[/] Fuzzily search in current buffer' })
|
||||
|
||||
-- It's also possible to pass additional configuration options.
|
||||
-- See `:help telescope.builtin.live_grep()` for information about particular keys
|
||||
vim.keymap.set('n', '<leader>s/', function()
|
||||
builtin.live_grep {
|
||||
grep_open_files = true,
|
||||
prompt_title = 'Live Grep in Open Files',
|
||||
}
|
||||
end, { desc = '[S]earch [/] in Open Files' })
|
||||
|
||||
-- Shortcut for searching your Neovim configuration files
|
||||
vim.keymap.set('n', '<leader>sn', function()
|
||||
builtin.find_files { cwd = vim.fn.stdpath 'config' }
|
||||
end, { desc = '[S]earch [N]eovim files' })
|
||||
end,
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
return { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
return { -- Useful plugin to show you pending keybinds.
|
||||
'folke/which-key.nvim',
|
||||
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
|
||||
config = function() -- This is the function that runs, AFTER loading
|
||||
require('which-key').setup()
|
||||
|
||||
-- Document existing key chains
|
||||
require('which-key').add {
|
||||
{ '<leader>c', group = '[C]ode' },
|
||||
{ '<leader>c_', hidden = true },
|
||||
{ '<leader>d', group = '[D]ocument' },
|
||||
{ '<leader>d_', hidden = true },
|
||||
{ '<leader>h', group = 'Git [H]unk' },
|
||||
{ '<leader>h_', hidden = true },
|
||||
{ '<leader>r', group = '[R]ename' },
|
||||
{ '<leader>r_', hidden = true },
|
||||
{ '<leader>s', group = '[S]earch' },
|
||||
{ '<leader>s_', hidden = true },
|
||||
{ '<leader>t', group = '[T]oggle' },
|
||||
{ '<leader>t_', hidden = true },
|
||||
{ '<leader>w', group = '[W]orkspace' },
|
||||
{ '<leader>w_', hidden = true },
|
||||
}
|
||||
-- visual mode
|
||||
require('which-key').add {
|
||||
{ '<leader>h', desc = 'Git [H]unk', mode = 'v' },
|
||||
}
|
||||
end,
|
||||
}
|
||||
|
|
@ -1,15 +1,5 @@
|
|||
-- debug.lua
|
||||
--
|
||||
-- Shows how to use the DAP plugin to debug your code.
|
||||
--
|
||||
-- Primarily focused on configuring the debugger for Go, but can
|
||||
-- be extended to other languages as well. That's why it's called
|
||||
-- kickstart.nvim and not kitchen-sink.nvim ;)
|
||||
|
||||
return {
|
||||
-- NOTE: Yes, you can install new plugins here!
|
||||
'mfussenegger/nvim-dap',
|
||||
-- NOTE: And you can specify dependencies as well
|
||||
dependencies = {
|
||||
-- Creates a beautiful debugger UI
|
||||
'rcarriga/nvim-dap-ui',
|
||||
|
|
@ -29,27 +19,16 @@ return {
|
|||
local dapui = require 'dapui'
|
||||
|
||||
require('mason-nvim-dap').setup {
|
||||
-- Makes a best effort to setup the various debuggers with
|
||||
-- reasonable debug configurations
|
||||
automatic_installation = true,
|
||||
|
||||
-- You can provide additional configuration to the handlers,
|
||||
-- see mason-nvim-dap README for more information
|
||||
handlers = {},
|
||||
|
||||
-- You'll need to check that you have the required things installed
|
||||
-- online, please don't ask me how to install them :)
|
||||
ensure_installed = {
|
||||
-- Update this to ensure that you have the debuggers for the langs you want
|
||||
'delve',
|
||||
'netcoredbg',
|
||||
'codelldb',
|
||||
'java-debug-adapter',
|
||||
'java-test',
|
||||
},
|
||||
}
|
||||
|
||||
-- Basic debugging keymaps, feel free to change to your liking!
|
||||
vim.keymap.set('n', '<F5>', dap.continue, { desc = 'Debug: Start/Continue' })
|
||||
vim.keymap.set('n', '<F1>', dap.step_into, { desc = 'Debug: Step Into' })
|
||||
vim.keymap.set('n', '<F2>', dap.step_over, { desc = 'Debug: Step Over' })
|
||||
|
|
@ -62,9 +41,31 @@ return {
|
|||
-- Dap UI setup
|
||||
-- For more information, see |:help nvim-dap-ui|
|
||||
dapui.setup {
|
||||
-- Set icons to characters that are more likely to work in every terminal.
|
||||
-- Feel free to remove or use ones that you like more! :)
|
||||
-- Don't feel like these are good choices.
|
||||
layouts = {
|
||||
{
|
||||
-- You can change the order of elements in the sidebar
|
||||
elements = {
|
||||
-- Provide IDs as strings or tables with "id" and "size" keys
|
||||
{
|
||||
id = 'scopes',
|
||||
size = 0.35, -- Can be float or integer > 1
|
||||
},
|
||||
{ id = 'breakpoints', size = 0.25 },
|
||||
{ id = 'stacks', size = 0.25 },
|
||||
{ id = 'watches', size = 0.25 },
|
||||
},
|
||||
size = 40,
|
||||
position = 'left', -- Can be "left" or "right"
|
||||
},
|
||||
{
|
||||
elements = {
|
||||
'repl',
|
||||
'console',
|
||||
},
|
||||
size = 15,
|
||||
position = 'bottom', -- Can be "bottom" or "top"
|
||||
},
|
||||
},
|
||||
icons = { expanded = '▾', collapsed = '▸', current_frame = '*' },
|
||||
controls = {
|
||||
icons = {
|
||||
|
|
@ -87,14 +88,5 @@ return {
|
|||
dap.listeners.after.event_initialized['dapui_config'] = dapui.open
|
||||
dap.listeners.before.event_terminated['dapui_config'] = dapui.close
|
||||
dap.listeners.before.event_exited['dapui_config'] = dapui.close
|
||||
|
||||
-- Install golang specific config
|
||||
require('dap-go').setup {
|
||||
delve = {
|
||||
-- On Windows delve must be run attached or it crashes.
|
||||
-- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring
|
||||
detached = vim.fn.has 'win32' == 0,
|
||||
},
|
||||
}
|
||||
end,
|
||||
}
|
||||
|
|
|
|||
282
lua/plugins.lua
282
lua/plugins.lua
|
|
@ -1,5 +1,3 @@
|
|||
-- [[ Install `lazy.nvim` plugin manager ]]
|
||||
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
|
||||
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
|
||||
|
|
@ -7,260 +5,32 @@ if not vim.loop.fs_stat(lazypath) then
|
|||
end ---@diagnostic disable-next-line: undefined-field
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
-- [[ Configure and install plugins ]]
|
||||
--
|
||||
-- To check the current status of your plugins, run
|
||||
-- :Lazy
|
||||
--
|
||||
-- You can press `?` in this menu for help. Use `:q` to close the window
|
||||
--
|
||||
-- To update plugins you can run
|
||||
-- :Lazy update
|
||||
--
|
||||
-- NOTE: Here is where you install your plugins.
|
||||
require('lazy').setup({
|
||||
-- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link).
|
||||
'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
|
||||
|
||||
-- NOTE: Plugins can also be added by using a table,
|
||||
-- with the first argument being the link and the following
|
||||
-- keys can be used to configure plugin behavior/loading/etc.
|
||||
--
|
||||
-- Use `opts = {}` to force a plugin to be loaded.
|
||||
--
|
||||
-- This is equivalent to:
|
||||
-- require('Comment').setup({})
|
||||
|
||||
-- "gc" to comment visual regions/lines
|
||||
{ 'numToStr/Comment.nvim', opts = {} },
|
||||
|
||||
-- Here is a more advanced example where we pass configuration
|
||||
-- options to `gitsigns.nvim`. This is equivalent to the following Lua:
|
||||
-- require('gitsigns').setup({ ... })
|
||||
--
|
||||
-- See `:help gitsigns` to understand what the configuration keys do
|
||||
{ -- Adds git related signs to the gutter, as well as utilities for managing changes
|
||||
'lewis6991/gitsigns.nvim',
|
||||
opts = {
|
||||
signs = {
|
||||
add = { text = '+' },
|
||||
change = { text = '~' },
|
||||
delete = { text = '_' },
|
||||
topdelete = { text = '‾' },
|
||||
changedelete = { text = '~' },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- NOTE: Plugins can also be configured to run Lua code when they are loaded.
|
||||
--
|
||||
-- This is often very useful to both group configuration, as well as handle
|
||||
-- lazy loading plugins that don't need to be loaded immediately at startup.
|
||||
--
|
||||
-- For example, in the following configuration, we use:
|
||||
-- event = 'VimEnter'
|
||||
--
|
||||
-- which loads which-key before all the UI elements are loaded. Events can be
|
||||
-- normal autocommands events (`:help autocmd-events`).
|
||||
--
|
||||
-- Then, because we use the `config` key, the configuration only runs
|
||||
-- after the plugin has been loaded:
|
||||
-- config = function() ... end
|
||||
|
||||
{ -- Useful plugin to show you pending keybinds.
|
||||
'folke/which-key.nvim',
|
||||
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
|
||||
config = function() -- This is the function that runs, AFTER loading
|
||||
require('which-key').setup()
|
||||
|
||||
-- Document existing key chains
|
||||
require('which-key').register {
|
||||
['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
|
||||
['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
|
||||
['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
|
||||
['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
|
||||
['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
|
||||
['<leader>t'] = { name = '[T]oggle', _ = 'which_key_ignore' },
|
||||
['<leader>h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' },
|
||||
}
|
||||
-- visual mode
|
||||
require('which-key').register({
|
||||
['<leader>h'] = { 'Git [H]unk' },
|
||||
}, { mode = 'v' })
|
||||
end,
|
||||
},
|
||||
|
||||
-- NOTE: Plugins can specify dependencies.
|
||||
--
|
||||
-- The dependencies are proper plugin specifications as well - anything
|
||||
-- you do for a plugin at the top level, you can do for a dependency.
|
||||
--
|
||||
-- Use the `dependencies` key to specify the dependencies of a particular plugin
|
||||
|
||||
{ -- Fuzzy Finder (files, lsp, etc)
|
||||
'nvim-telescope/telescope.nvim',
|
||||
event = 'VimEnter',
|
||||
branch = '0.1.x',
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
{ -- If encountering errors, see telescope-fzf-native README for installation instructions
|
||||
'nvim-telescope/telescope-fzf-native.nvim',
|
||||
|
||||
-- `build` is used to run some command when the plugin is installed/updated.
|
||||
-- This is only run then, not every time Neovim starts up.
|
||||
build = 'make',
|
||||
|
||||
-- `cond` is a condition used to determine whether this plugin should be
|
||||
-- installed and loaded.
|
||||
cond = function()
|
||||
return vim.fn.executable 'make' == 1
|
||||
end,
|
||||
},
|
||||
{ 'nvim-telescope/telescope-ui-select.nvim' },
|
||||
|
||||
-- Useful for getting pretty icons, but requires a Nerd Font.
|
||||
{ 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
|
||||
},
|
||||
config = function()
|
||||
-- Telescope is a fuzzy finder that comes with a lot of different things that
|
||||
-- it can fuzzy find! It's more than just a "file finder", it can search
|
||||
-- many different aspects of Neovim, your workspace, LSP, and more!
|
||||
--
|
||||
-- The easiest way to use Telescope, is to start by doing something like:
|
||||
-- :Telescope help_tags
|
||||
--
|
||||
-- After running this command, a window will open up and you're able to
|
||||
-- type in the prompt window. You'll see a list of `help_tags` options and
|
||||
-- a corresponding preview of the help.
|
||||
--
|
||||
-- Two important keymaps to use while in Telescope are:
|
||||
-- - Insert mode: <c-/>
|
||||
-- - Normal mode: ?
|
||||
--
|
||||
-- This opens a window that shows you all of the keymaps for the current
|
||||
-- Telescope picker. This is really useful to discover what Telescope can
|
||||
-- do as well as how to actually do it!
|
||||
|
||||
-- [[ Configure Telescope ]]
|
||||
-- See `:help telescope` and `:help telescope.setup()`
|
||||
require('telescope').setup {
|
||||
-- You can put your default mappings / updates / etc. in here
|
||||
-- All the info you're looking for is in `:help telescope.setup()`
|
||||
--
|
||||
-- defaults = {
|
||||
-- mappings = {
|
||||
-- i = { ['<c-enter>'] = 'to_fuzzy_refine' },
|
||||
-- },
|
||||
-- },
|
||||
-- pickers = {}
|
||||
extensions = {
|
||||
['ui-select'] = {
|
||||
require('telescope.themes').get_dropdown(),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- Enable Telescope extensions if they are installed
|
||||
pcall(require('telescope').load_extension, 'fzf')
|
||||
pcall(require('telescope').load_extension, 'ui-select')
|
||||
|
||||
-- See `:help telescope.builtin`
|
||||
local builtin = require 'telescope.builtin'
|
||||
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
|
||||
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
|
||||
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
|
||||
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
|
||||
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
|
||||
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
|
||||
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
|
||||
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
|
||||
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
|
||||
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
|
||||
|
||||
-- Slightly advanced example of overriding default behavior and theme
|
||||
vim.keymap.set('n', '<leader>/', function()
|
||||
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
|
||||
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
|
||||
winblend = 10,
|
||||
previewer = false,
|
||||
})
|
||||
end, { desc = '[/] Fuzzily search in current buffer' })
|
||||
|
||||
-- It's also possible to pass additional configuration options.
|
||||
-- See `:help telescope.builtin.live_grep()` for information about particular keys
|
||||
vim.keymap.set('n', '<leader>s/', function()
|
||||
builtin.live_grep {
|
||||
grep_open_files = true,
|
||||
prompt_title = 'Live Grep in Open Files',
|
||||
}
|
||||
end, { desc = '[S]earch [/] in Open Files' })
|
||||
|
||||
-- Shortcut for searching your Neovim configuration files
|
||||
vim.keymap.set('n', '<leader>sn', function()
|
||||
builtin.find_files { cwd = vim.fn.stdpath 'config' }
|
||||
end, { desc = '[S]earch [N]eovim files' })
|
||||
end,
|
||||
},
|
||||
|
||||
{ -- LSP Configuration & Plugins
|
||||
'neovim/nvim-lspconfig',
|
||||
dependencies = {
|
||||
-- Automatically install LSPs and related tools to stdpath for Neovim
|
||||
{ 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants
|
||||
{ 'j-hui/fidget.nvim', opts = {} }, -- Useful status updates for LSP.
|
||||
'williamboman/mason-lspconfig.nvim',
|
||||
'WhoIsSethDaniel/mason-tool-installer.nvim',
|
||||
|
||||
-- Useful status updates for LSP.
|
||||
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
|
||||
{ 'j-hui/fidget.nvim', opts = {} },
|
||||
'nvim-java/nvim-java',
|
||||
|
||||
-- `neodev` configures Lua LSP for your Neovim config, runtime and plugins
|
||||
-- used for completion, annotations and signatures of Neovim apis
|
||||
{ 'folke/neodev.nvim', opts = {} },
|
||||
},
|
||||
config = function()
|
||||
-- Brief aside: **What is LSP?**
|
||||
--
|
||||
-- LSP is an initialism you've probably heard, but might not understand what it is.
|
||||
--
|
||||
-- LSP stands for Language Server Protocol. It's a protocol that helps editors
|
||||
-- and language tooling communicate in a standardized fashion.
|
||||
--
|
||||
-- In general, you have a "server" which is some tool built to understand a particular
|
||||
-- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers
|
||||
-- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone
|
||||
-- processes that communicate with some "client" - in this case, Neovim!
|
||||
--
|
||||
-- LSP provides Neovim with features like:
|
||||
-- - Go to definition
|
||||
-- - Find references
|
||||
-- - Autocompletion
|
||||
-- - Symbol Search
|
||||
-- - and more!
|
||||
--
|
||||
-- Thus, Language Servers are external tools that must be installed separately from
|
||||
-- Neovim. This is where `mason` and related plugins come into play.
|
||||
--
|
||||
-- If you're wondering about lsp vs treesitter, you can check out the wonderfully
|
||||
-- and elegantly composed help section, `:help lsp-vs-treesitter`
|
||||
|
||||
-- This function gets run when an LSP attaches to a particular buffer.
|
||||
-- That is to say, every time a new file is opened that is associated with
|
||||
-- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this
|
||||
-- function will be executed to configure the current buffer
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }),
|
||||
callback = function(event)
|
||||
-- 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.
|
||||
--
|
||||
-- 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 map = function(keys, func, desc)
|
||||
vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
|
||||
end
|
||||
|
||||
-- Jump to the definition of the word under your cursor.
|
||||
-- This is where a variable was first declared, or where a function is defined, etc.
|
||||
-- To jump back, press <C-t>.
|
||||
map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
|
||||
|
|
@ -349,9 +119,6 @@ require('lazy').setup({
|
|||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities())
|
||||
|
||||
-- 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. Available keys are:
|
||||
-- - cmd (table): Override the default command used to start the server
|
||||
-- - filetypes (table): Override the default list of associated filetypes for the server
|
||||
|
|
@ -360,6 +127,7 @@ require('lazy').setup({
|
|||
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
|
||||
local servers = {
|
||||
tsserver = {},
|
||||
angularls = {},
|
||||
stylelint_lsp = {
|
||||
filetypes = { 'css', 'scss' },
|
||||
root_dir = require('lspconfig').util.root_pattern('package.json', '.git'),
|
||||
|
|
@ -434,11 +202,21 @@ require('lazy').setup({
|
|||
'jdtls',
|
||||
'prettier',
|
||||
})
|
||||
|
||||
-- Skip automatic setup for servers
|
||||
local skip_setup = {
|
||||
'jdtls',
|
||||
}
|
||||
|
||||
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
|
||||
|
||||
require('mason-lspconfig').setup {
|
||||
handlers = {
|
||||
function(server_name)
|
||||
if vim.tbl_contains(skip_setup, server_name) then
|
||||
return
|
||||
end
|
||||
|
||||
local server = servers[server_name] or {}
|
||||
-- This handles overriding only values explicitly passed
|
||||
-- by the server configuration above. Useful when disabling
|
||||
|
|
@ -446,6 +224,15 @@ require('lazy').setup({
|
|||
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
|
||||
require('lspconfig')[server_name].setup(server)
|
||||
end,
|
||||
jdtls = function()
|
||||
require('java').setup {
|
||||
-- Your custom jdtls settings goes here
|
||||
}
|
||||
|
||||
require('lspconfig').jdtls.setup {
|
||||
-- Your custom nvim-java configuration goes here
|
||||
}
|
||||
end,
|
||||
},
|
||||
}
|
||||
end,
|
||||
|
|
@ -481,7 +268,9 @@ require('lazy').setup({
|
|||
typescript = { 'prettier' },
|
||||
javascript = { 'prettier' },
|
||||
json = { 'prettier' },
|
||||
scss = { 'prettier' },
|
||||
html = { 'prettier' },
|
||||
|
||||
-- Conform can also run multiple formatters sequentially
|
||||
-- python = { "isort", "black" },
|
||||
--
|
||||
|
|
@ -604,16 +393,9 @@ require('lazy').setup({
|
|||
},
|
||||
|
||||
{ -- You can easily change to a different colorscheme.
|
||||
-- Change the name of the colorscheme plugin below, and then
|
||||
-- change the command in the config to whatever the name of that colorscheme is.
|
||||
--
|
||||
-- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
|
||||
'folke/tokyonight.nvim',
|
||||
priority = 1000, -- Make sure to load this before all the other start plugins.
|
||||
init = function()
|
||||
-- Load the colorscheme here.
|
||||
-- Like many other themes, this one has different styles, and you could load
|
||||
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
|
||||
vim.cmd.colorscheme 'tokyonight-night'
|
||||
|
||||
-- You can configure highlights by doing something like:
|
||||
|
|
@ -621,9 +403,6 @@ require('lazy').setup({
|
|||
end,
|
||||
},
|
||||
|
||||
-- Highlight todo, notes, etc in comments
|
||||
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
|
||||
|
||||
{ -- Collection of various small independent plugins/modules
|
||||
'echasnovski/mini.nvim',
|
||||
config = function()
|
||||
|
|
@ -665,7 +444,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', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc', 'c', 'java' },
|
||||
-- Autoinstall languages that are not installed
|
||||
auto_install = true,
|
||||
highlight = {
|
||||
|
|
@ -694,16 +473,7 @@ require('lazy').setup({
|
|||
end,
|
||||
},
|
||||
|
||||
-- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the
|
||||
-- init.lua. If you want these files, they are in the repository, so you can just download them and
|
||||
-- place them in the correct locations.
|
||||
|
||||
-- NOTE: Next step on your Neovim journey: Add/Configure additional plugins for Kickstart
|
||||
--
|
||||
-- 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.debug',
|
||||
-- require 'kickstart.plugins.indent_line',
|
||||
-- require 'kickstart.plugins.lint',
|
||||
-- require 'kickstart.plugins.autopairs',
|
||||
|
|
|
|||
Loading…
Reference in New Issue