Skip to content

Commit

Permalink
feat(nvim): handle php large files
Browse files Browse the repository at this point in the history
  • Loading branch information
RayGuo-ergou committed Apr 18, 2024
1 parent 95e6de3 commit e8c756a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 39 deletions.
38 changes: 0 additions & 38 deletions nvim/lua/ergou/plugins/mini-nvim.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,42 +119,4 @@ return {
},
},
},
{
'echasnovski/mini.animate',
event = 'VeryLazy',
opts = function()
-- don't use animate when scrolling with the mouse
local mouse_scrolled = false
for _, scroll in ipairs({ 'Up', 'Down' }) do
local key = '<ScrollWheel' .. scroll .. '>'
vim.keymap.set({ '', 'i' }, key, function()
mouse_scrolled = true
return key
end, { expr = true })
end

local animate = require('mini.animate')
return {
resize = {
timing = animate.gen_timing.linear({ duration = 100, unit = 'total' }),
},
cursor = {
enable = false,
},
scroll = {
timing = animate.gen_timing.linear({ duration = 150, unit = 'total' }),
subscroll = animate.gen_subscroll.equal({
max_output_steps = 120,
predicate = function(total_scroll)
if mouse_scrolled then
mouse_scrolled = false
return false
end
return total_scroll > 1
end,
}),
},
}
end,
},
}
2 changes: 2 additions & 0 deletions nvim/lua/ergou/plugins/none-ls.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
local lsp_util = require('ergou.util.lsp')
return {
{
'nvimtools/none-ls.nvim',
event = 'LazyFile',
enabled = not lsp_util.PHP.working_large_file,
dependencies = { 'davidmh/cspell.nvim' },
config = function()
local null_ls = require('null-ls')
Expand Down
16 changes: 15 additions & 1 deletion nvim/lua/ergou/util/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ M.CSPELL_CONFIG_FILES = {
'.cspell.config.json',
}

M.PHP = {
working_large_file = true,
}

function M.get_clients(opts)
local ret = {} ---@type vim.lsp.Client[]
if vim.lsp.get_clients then
Expand Down Expand Up @@ -143,7 +147,17 @@ M.get_servers = function()
},
},
},
intelephense = {},
-- intelephense is a node.js server, so it's pretty slow
-- And can only running one thread
-- Use phpactor instead for large files
-- it's not as good as intelephense, but it's faster
intelephense = {
enabled = not M.PHP.working_large_file,
},
-- To install phpactor, need php8
phpactor = {
enabled = M.PHP.working_large_file,
},
marksman = {},
lua_ls = {
settings = {
Expand Down

0 comments on commit e8c756a

Please sign in to comment.