nvim/lua/config/utils.lua

53 lines
1.5 KiB
Lua
Raw Normal View History

local M = {}
M.has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match '%s' == nil
end
2023-06-19 11:33:42 +02:00
--[=[ function M.on_attach(client, bufnr)
--[[ vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') ]]
if client.name == 'jdt.ls' then
client.server_capabilities.documentFormattingProvider = false
vim.lsp.codelens.refresh()
if JAVA_DAP_ACTIVE then
require('jdtls').setup_dap { hotcodereplace = 'auto' }
require('jdtls.dap').setup_dap_main_class_configs()
end
end
local ft = vim.api.nvim_buf_get_option(bufnr, 'filetype')
2023-04-22 20:25:30 +02:00
local has_formatter = require('null-ls.sources').get_available(ft, 'NULL_LS_FORMATTING') > 0
local enable = false
2023-04-20 14:50:25 +02:00
if has_formatter and not client.name == 'clangd' then
enable = client.name == 'null-ls'
else
enable = not (client.name == 'null-ls')
end
-- util.info(client.name .. " " .. (enable and "yes" or "no"), "format")
client.server_capabilities.documentFormattingProvider = enable
2023-06-19 11:33:42 +02:00
-- client.server_capabilities.semanticTokensProvider = false
client.server_capabilities.semanticTokensProvider = nil
end ]=]
M.lsp_config = {
virtual_text = {
prefix = '',
},
signs = false,
underline = true,
update_in_insert = true,
severity_sort = false,
float = {
focusable = false,
-- style = 'minimal',
border = 'rounded',
source = 'always',
header = '',
prefix = '',
},
}
return M