jdtls, sqls, more leader mappings
This commit is contained in:
parent
2486dba138
commit
524afbb9aa
120
init.lua
120
init.lua
|
@ -144,7 +144,7 @@ do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
vim.cmd [[
|
vim.cmd [[
|
||||||
tnoremap <S-Esc> <C-\><C-n>'
|
tnoremap <S-Esc> <C-\><C-n>
|
||||||
]]
|
]]
|
||||||
|
|
||||||
-- Commands
|
-- Commands
|
||||||
|
@ -174,7 +174,7 @@ au('BufWritePost', {
|
||||||
desc = 'Reload config when it is saved, and compile packer cache',
|
desc = 'Reload config when it is saved, and compile packer cache',
|
||||||
})
|
})
|
||||||
au('TextYankPost', {
|
au('TextYankPost', {
|
||||||
callback = vim.highlight.on_yank,
|
callback = function() vim.highlight.on_yank() end,
|
||||||
desc = 'Highlight when text is yanked',
|
desc = 'Highlight when text is yanked',
|
||||||
})
|
})
|
||||||
au('BufReadPost', {
|
au('BufReadPost', {
|
||||||
|
@ -290,6 +290,8 @@ require'packer'.startup(function(use)
|
||||||
use 'hrsh7th/cmp-buffer'
|
use 'hrsh7th/cmp-buffer'
|
||||||
use 'hrsh7th/cmp-path'
|
use 'hrsh7th/cmp-path'
|
||||||
use 'hrsh7th/cmp-cmdline'
|
use 'hrsh7th/cmp-cmdline'
|
||||||
|
use 'nanotee/sqls.nvim'
|
||||||
|
use 'mfussenegger/nvim-jdtls'
|
||||||
use 'simrat39/rust-tools.nvim'
|
use 'simrat39/rust-tools.nvim'
|
||||||
use {'jose-elias-alvarez/null-ls.nvim', requires = {'nvim-lua/plenary.nvim'}, config = function ()
|
use {'jose-elias-alvarez/null-ls.nvim', requires = {'nvim-lua/plenary.nvim'}, config = function ()
|
||||||
local null_ls = require'null-ls'
|
local null_ls = require'null-ls'
|
||||||
|
@ -302,7 +304,9 @@ require'packer'.startup(function(use)
|
||||||
end}
|
end}
|
||||||
use 'SmiteshP/nvim-navic'
|
use 'SmiteshP/nvim-navic'
|
||||||
use {'utilyre/barbecue.nvim', config = function ()
|
use {'utilyre/barbecue.nvim', config = function ()
|
||||||
require'barbecue'.setup()
|
require'barbecue'.setup {
|
||||||
|
show_modified = true,
|
||||||
|
}
|
||||||
end}
|
end}
|
||||||
|
|
||||||
-- UI elements --
|
-- UI elements --
|
||||||
|
@ -380,7 +384,7 @@ require'packer'.startup(function(use)
|
||||||
r = {dap.step_back, 'Step back'},
|
r = {dap.step_back, 'Step back'},
|
||||||
R = {dap.reverse_continue, 'Continue backwards'},
|
R = {dap.reverse_continue, 'Continue backwards'},
|
||||||
C = {dap.run_to_cursor, 'Continue to cursor'},
|
C = {dap.run_to_cursor, 'Continue to cursor'},
|
||||||
p = {dap.paise, 'Pause execution'}
|
p = {dap.pause, 'Pause execution'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end}
|
end}
|
||||||
|
@ -475,7 +479,7 @@ require'packer'.startup(function(use)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end}
|
end}
|
||||||
use 'j-hui/fidget.nvim'
|
use {'j-hui/fidget.nvim', branch = 'legacy'}
|
||||||
use 'tpope/vim-fugitive'
|
use 'tpope/vim-fugitive'
|
||||||
use 'tpope/vim-rhubarb'
|
use 'tpope/vim-rhubarb'
|
||||||
use 'shumphrey/fugitive-gitlab.vim'
|
use 'shumphrey/fugitive-gitlab.vim'
|
||||||
|
@ -498,7 +502,16 @@ require'packer'.startup(function(use)
|
||||||
end}
|
end}
|
||||||
use {'williamboman/mason-lspconfig.nvim', config = function()
|
use {'williamboman/mason-lspconfig.nvim', config = function()
|
||||||
require'mason-lspconfig'.setup {
|
require'mason-lspconfig'.setup {
|
||||||
automatic_installation = true,
|
automatic_installation = true
|
||||||
|
-- figure out how to ensure java-test and java-debug-adapter
|
||||||
|
}
|
||||||
|
end}
|
||||||
|
use {'TimUntersberger/neogit', config = function ()
|
||||||
|
require'neogit'.setup {
|
||||||
|
disable_context_highlighting = true,
|
||||||
|
integrations = {
|
||||||
|
diffview = true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
end}
|
end}
|
||||||
use {'rcarriga/nvim-notify', after = 'telescope.nvim', config = function ()
|
use {'rcarriga/nvim-notify', after = 'telescope.nvim', config = function ()
|
||||||
|
@ -558,6 +571,7 @@ require'packer'.startup(function(use)
|
||||||
h = {'<Cmd>Telescope help_tags<CR>', 'Help page'},
|
h = {'<Cmd>Telescope help_tags<CR>', 'Help page'},
|
||||||
p = {'<Cmd>Telescope project<CR>', 'Projects'},
|
p = {'<Cmd>Telescope project<CR>', 'Projects'},
|
||||||
s = {'<Cmd>Telescope lsp_dynamic_workspace_symbols<CR>', 'Symbols'},
|
s = {'<Cmd>Telescope lsp_dynamic_workspace_symbols<CR>', 'Symbols'},
|
||||||
|
S = {'<Cmd>Telescope lsp_document_symbols<CR>', 'Symbols - current file'},
|
||||||
n = {'<Cmd>Telescope notify<CR>', 'Notifications'},
|
n = {'<Cmd>Telescope notify<CR>', 'Notifications'},
|
||||||
m = {'<Cmd>Telescope man_pages<CR>', 'Man pages'},
|
m = {'<Cmd>Telescope man_pages<CR>', 'Man pages'},
|
||||||
[':'] = {'<Cmd>Telescope commands<CR>', 'Commands'},
|
[':'] = {'<Cmd>Telescope commands<CR>', 'Commands'},
|
||||||
|
@ -696,6 +710,8 @@ require'gitsigns'.setup {
|
||||||
v = {gitsigns.select_hunk, 'Visual select hunk'},
|
v = {gitsigns.select_hunk, 'Visual select hunk'},
|
||||||
d = {gitsigns.toggle_deleted, 'Toggle deleted lines'},
|
d = {gitsigns.toggle_deleted, 'Toggle deleted lines'},
|
||||||
w = {gitsigns.toggle_word_diff, 'Toggle word diffs'},
|
w = {gitsigns.toggle_word_diff, 'Toggle word diffs'},
|
||||||
|
l = {gitsigns.blame_line, 'Blame current line'},
|
||||||
|
L = {gitsigns.toggle_line_blame, 'Toggle line blame'},
|
||||||
b = {':Gitsigns change_base ', 'Change diff base'},
|
b = {':Gitsigns change_base ', 'Change diff base'},
|
||||||
B = {gitsigns.reset_base, 'Reset diff base'},
|
B = {gitsigns.reset_base, 'Reset diff base'},
|
||||||
}
|
}
|
||||||
|
@ -783,6 +799,14 @@ local capabilities = require'cmp_nvim_lsp'.default_capabilities()
|
||||||
local function on_attach(client, bufnr)
|
local function on_attach(client, bufnr)
|
||||||
|
|
||||||
require'which-key'.register({
|
require'which-key'.register({
|
||||||
|
['<Leader>l'] = {
|
||||||
|
d = {vim.lsp.buf.definition, 'Goto definition'},
|
||||||
|
D = {vim.lsp.buf.implementation, 'Goto implementation'},
|
||||||
|
a = {vim.lsp.buf.code_action, 'Code action'},
|
||||||
|
r = {vim.lsp.buf.rename, 'Rename'},
|
||||||
|
t = {vim.lsp.buf.type_definition, 'Type definition'},
|
||||||
|
u = {vim.lsp.buf.references, 'Usages/references'}
|
||||||
|
},
|
||||||
g = {
|
g = {
|
||||||
d = {vim.lsp.buf.definition, 'Goto definition'},
|
d = {vim.lsp.buf.definition, 'Goto definition'},
|
||||||
D = {vim.lsp.buf.implementation, 'Goto implementation'},
|
D = {vim.lsp.buf.implementation, 'Goto implementation'},
|
||||||
|
@ -849,9 +873,78 @@ require'lspconfig'.lua_ls.setup {
|
||||||
|
|
||||||
require'lspconfig'.bashls.setup(default)
|
require'lspconfig'.bashls.setup(default)
|
||||||
require'lspconfig'.clangd.setup(default)
|
require'lspconfig'.clangd.setup(default)
|
||||||
require'lspconfig'.jdtls.setup(default)
|
au('FileType', {
|
||||||
|
pattern = 'java',
|
||||||
|
callback = function ()
|
||||||
|
local ok, jdtls = pcall(require, 'jdtls')
|
||||||
|
if not ok then return end
|
||||||
|
|
||||||
|
local path = vim.fn.stdpath('data') .. '/mason/packages/jdtls'
|
||||||
|
local root_dir = jdtls.setup.find_root({'.git', 'mvnw', 'gradlew'})
|
||||||
|
|
||||||
|
local config = {
|
||||||
|
-- The command to launch jdtls with
|
||||||
|
cmd = {
|
||||||
|
'jdtls',
|
||||||
|
-- Enable logging
|
||||||
|
'--jvm-arg=-Dlog.level=ALL',
|
||||||
|
'--jvm-arg=-Dlog.protocol=true',
|
||||||
|
-- Enable lombok
|
||||||
|
'--jvm-arg=-javaagent:' .. path .. '/lombok.jar',
|
||||||
|
-- store workpace data in ~/.local/share/eclipse/<project-name>
|
||||||
|
'-data', vim.fn.expand('~/.local/share/eclipse/') .. vim.fn.fnamemodify(root_dir, ':p:h:t')
|
||||||
|
},
|
||||||
|
|
||||||
|
root_dir = root_dir,
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
java = {},
|
||||||
|
},
|
||||||
|
|
||||||
|
init_options = {
|
||||||
|
-- JDTLS plugins
|
||||||
|
bundles = (function ()
|
||||||
|
-- add java-debug-adapter
|
||||||
|
local bundles = {
|
||||||
|
vim.fn.glob(vim.fn.stdpath('data') .. '/mason/packages/java-debug-adapter/extension/server/com.microsoft.java.debug.plugin-*.jar', 1)
|
||||||
|
}
|
||||||
|
-- add java-test
|
||||||
|
vim.list_extend(bundles, vim.split(
|
||||||
|
vim.fn.glob(vim.fn.stdpath'data' .. '/mason/packages/java-test/extension/server/*.jar', 1),
|
||||||
|
'\n'
|
||||||
|
))
|
||||||
|
|
||||||
|
return bundles
|
||||||
|
end)(),
|
||||||
|
},
|
||||||
|
|
||||||
|
on_attach = function (client, bufnr)
|
||||||
|
on_attach(client, bufnr)
|
||||||
|
jdtls.setup_dap()
|
||||||
|
jdtls.setup.add_commands()
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
jdtls.start_or_attach(config)
|
||||||
|
end
|
||||||
|
})
|
||||||
require'lspconfig'.nil_ls.setup(default)
|
require'lspconfig'.nil_ls.setup(default)
|
||||||
require'lspconfig'.pyright.setup(default)
|
require'lspconfig'.pyright.setup(default)
|
||||||
|
-- Defer setup to silence deprecation notice
|
||||||
|
au('FileType', {
|
||||||
|
pattern = 'sql',
|
||||||
|
callback = function ()
|
||||||
|
require'lspconfig'.sqls.setup {
|
||||||
|
capabilities = capabilities,
|
||||||
|
on_attach = function (client, bufnr)
|
||||||
|
on_attach(client, bufnr)
|
||||||
|
local ok, sqls = pcall(require, 'sqls')
|
||||||
|
if not ok then return end
|
||||||
|
sqls.on_attach(client, bufnr)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
})
|
||||||
require'lspconfig'.tsserver.setup(default)
|
require'lspconfig'.tsserver.setup(default)
|
||||||
require'lspconfig'.vimls.setup(default)
|
require'lspconfig'.vimls.setup(default)
|
||||||
|
|
||||||
|
@ -954,7 +1047,7 @@ g.startify_lists = {
|
||||||
|
|
||||||
|
|
||||||
---- symbols-outline ----
|
---- symbols-outline ----
|
||||||
vim.g.symbols_outline = {
|
require'symbols-outline'.setup {
|
||||||
-- Don't display preview automatically
|
-- Don't display preview automatically
|
||||||
auto_preview = false,
|
auto_preview = false,
|
||||||
-- Don't highlight the hovered item
|
-- Don't highlight the hovered item
|
||||||
|
@ -1021,14 +1114,13 @@ require('nvim-tree').setup {
|
||||||
},
|
},
|
||||||
-- Match tree cwd to vim's cwd
|
-- Match tree cwd to vim's cwd
|
||||||
update_cwd = true,
|
update_cwd = true,
|
||||||
|
view = {
|
||||||
|
width = 45,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
vim.cmd'highlight NvimTreeOpenedFile guifg=NONE guibg=NONE gui=italic'
|
vim.cmd'highlight NvimTreeOpenedFile guifg=NONE guibg=NONE gui=italic'
|
||||||
au('ColorScheme', {
|
|
||||||
desc = 'Change NvimTreeOpenedFile highlight',
|
|
||||||
command = 'highlight NvimTreeOpenedFile guifg=NONE guibg=NONE gui=italic'
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.keymap.set('n', '<Leader>t', '<Cmd>NvimTreeFindFileToggle<CR>', {desc = 'Nvim Tree'})
|
vim.keymap.set('n', '<Leader>t', '<Cmd>NvimTreeFindFile<CR>', {desc = 'Nvim Tree'})
|
||||||
|
|
||||||
|
|
||||||
---- treesitter ----
|
---- treesitter ----
|
||||||
|
@ -1038,7 +1130,7 @@ require'nvim-treesitter.configs'.setup {
|
||||||
enable = true,
|
enable = true,
|
||||||
},
|
},
|
||||||
ensure_installed = {'lua', 'html', 'c', 'cpp', 'nix', 'vim', 'rust', 'bash', 'markdown', 'java', 'markdown_inline'},
|
ensure_installed = {'lua', 'html', 'c', 'cpp', 'nix', 'vim', 'rust', 'bash', 'markdown', 'java', 'markdown_inline'},
|
||||||
highlight = { enable = true, disable = 'rust' },
|
highlight = { enable = true, disable = {'rust', 'bash'} },
|
||||||
incremental_selection = { enable = true },
|
incremental_selection = { enable = true },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue