Make format on save opt-in, remove jdtls, add ruff
This commit is contained in:
parent
63a39b70fe
commit
21f65c1ed2
1 changed files with 12 additions and 73 deletions
85
init.lua
85
init.lua
|
|
@ -343,12 +343,15 @@ require('lazy').setup({
|
|||
formatters_by_ft = {
|
||||
html = {"prettier"},
|
||||
},
|
||||
format_on_save = {
|
||||
lsp_fallback = true,
|
||||
filter = function(client)
|
||||
return client.name == 'rust-analyzer'
|
||||
end
|
||||
format_on_save = function()
|
||||
if vim.g.format_on_save then
|
||||
return {
|
||||
lsp_fallback = true
|
||||
}
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end,
|
||||
}
|
||||
vim.api.nvim_create_user_command(
|
||||
'Conform',
|
||||
|
|
@ -450,6 +453,7 @@ require('lazy').setup({
|
|||
'jsonls',
|
||||
'lemminx',
|
||||
'lua_ls',
|
||||
'ruff',
|
||||
'ty',
|
||||
'vimls',
|
||||
'yamlls',
|
||||
|
|
@ -534,74 +538,6 @@ require('lazy').setup({
|
|||
},
|
||||
}},
|
||||
{'Saghen/blink.compat', lazy = true, opts = {}},
|
||||
{'mfussenegger/nvim-jdtls', dependencies = {'neovim/nvim-lspconfig'}, config = function()
|
||||
au('FileType', {
|
||||
pattern = 'java',
|
||||
callback = function()
|
||||
local jdtls = require 'jdtls'
|
||||
jdtls.tests = require'jdtls.tests'
|
||||
jdtls.dap = require'jdtls.dap'
|
||||
_G.jdt = jdtls
|
||||
local lspconfig = require'lspconfig'
|
||||
|
||||
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:' .. mason_path('jdtls') .. '/lombok.jar',
|
||||
-- Shut the warning up
|
||||
'--jvm-arg=-XX:+EnableDynamicAgentLoading',
|
||||
-- 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,
|
||||
|
||||
capabilities = lspconfig.util.default_config.capabilities,
|
||||
|
||||
settings = {
|
||||
java = {
|
||||
autobuild = { enabled = false },
|
||||
},
|
||||
},
|
||||
|
||||
init_options = {
|
||||
-- JDTLS plugins
|
||||
bundles = (function()
|
||||
-- add java-debug-adapter
|
||||
local bundles = {
|
||||
vim.fn.glob(mason_path'java-debug-adapter' .. '/extension/server/com.microsoft.java.debug.plugin-*.jar', true)
|
||||
}
|
||||
-- add java-test
|
||||
vim.list_extend(bundles, vim.split(
|
||||
vim.fn.glob(vim.fn.expand('~/.local/share/vscode-java-test/server') .. '/*.jar', true),
|
||||
'\n'
|
||||
))
|
||||
|
||||
return bundles
|
||||
end)(),
|
||||
},
|
||||
|
||||
on_attach = function(client, bufnr)
|
||||
jdtls.setup_dap()
|
||||
vim.keymap.set('n', '<Leader>lo', jdtls.organize_imports, { desc = 'Organize imports', buffer = bufnr })
|
||||
vim.keymap.set('n', '<Leader>Xm', jdtls.test_nearest_method, { desc = 'Test nearest method', buffer = bufnr })
|
||||
vim.keymap.set('n', '<Leader>Xc', jdtls.test_class, { desc = 'Test class', buffer = bufnr })
|
||||
vim.keymap.set('n', '<Leader>Xg', jdtls.tests.goto_subjects, { desc = 'Go to test', buffer = bufnr })
|
||||
vim.keymap.set('n', '<Leader>Xb', 'JdtCompile full', { desc = 'Build', buffer = bufnr })
|
||||
end,
|
||||
}
|
||||
|
||||
jdtls.start_or_attach(config)
|
||||
end
|
||||
})
|
||||
end},
|
||||
{'mrcjkb/rustaceanvim', config = function ()
|
||||
vim.g.rustaceanvim = {
|
||||
server = {
|
||||
|
|
@ -1102,6 +1038,9 @@ require('lazy').setup({
|
|||
}
|
||||
}
|
||||
end},
|
||||
{'michaelb/sniprun', lazy = false, build = 'sh install.sh', keys = {
|
||||
{'<Leader>p', '<Cmd>SnipRun<CR>', mode = {'v', 'n'}, desc = 'Run snippet'},
|
||||
}},
|
||||
{'mhinz/vim-startify', init = function()
|
||||
-- Don't change working directory when opening files
|
||||
g.startify_change_to_dir = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue