Skip to content

High CPU Usage - MacOS/Neovim #429

Open
@wilkinson4

Description

@wilkinson4

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

Hello! I have recently been experimenting with postgres-language-server in my neovim config on neovim 0.11.1, and MacOS Sequoia 15.5. I am using vim-dadbod-ui to manage my database connections and nvim-lsp to run the postgres-language-server when I am editing a sql buffer. I started noticing excessive battery drain on my 2023 Macbook Pro, and I realized the postgres-tools process was consistently running at 100% CPU usage.

To Reproduce

  1. Setup vim dadbod and vim dadbod ui per the docs
  2. I have the following lsp lua config for postgres lsp:
local function on_attach(client, bufnr)
  vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')

  local function buf_keymap(mode, lhs, rhs)
    vim.keymap.set(mode, lhs, rhs, { buffer = true, silent = true })
  end

  if client.name == 'eslint' then
    client.server_capabilities.documentFormattingProvider = true
    client.server_capabilities.documentRangeFormattingProvider = true
  end

  buf_keymap('n', 'K', function() vim.lsp.buf.hover() end)
  buf_keymap('n', 'gd', function() vim.lsp.buf.definition() end)
  buf_keymap('n', '1gd', function()
    vim.cmd('vsplit')
    vim.lsp.buf.definition()
  end)
  buf_keymap('n', '<c-]>', function() vim.lsp.buf.declaration() end)
  buf_keymap('n', 'gD', function() vim.lsp.buf.implementation() end)
  buf_keymap('n', '<c-k>', function() vim.lsp.buf.signature_help() end)
  buf_keymap('n', '1gD', function() vim.lsp.buf.type_definition() end)
  buf_keymap('n', 'sr', function() vim.lsp.buf.references() end)
  buf_keymap('n', 'gW', function() vim.lsp.buf.workspace_symbol() end)
  buf_keymap('n', 'gA', function() vim.lsp.buf.code_action() end)
  buf_keymap('v', 'gA', function() vim.lsp.buf.range_code_action() end)
  buf_keymap('n', 'sd', function() vim.diagnostic.open_float() end)
  buf_keymap('n', '<f4>',
    function() vim.lsp.buf.format({ async = true, filter = function(client) return client.name ~= "typescript-tools" end }) end)
  buf_keymap('v', '<f4>', function() vim.lsp.buf.range_formatting({}) end)

  buf_keymap('n', '<f3>', function() vim.lsp.buf.rename() end)
end

local capabilities = vim.lsp.protocol.make_client_capabilities()
local servers = {
   'postgres_lsp'
}

local configs = {}

for _, lsp in ipairs(servers) do
  local config = configs[lsp] or {}
  config.on_attach = on_attach
  config.capabilities = capabilities

  vim.lsp.config[lsp] = config
  vim.lsp.enable(lsp)
end
  1. Add a database connection via vim-dadbod-ui and open a new sql buffer

System information

MacOS Sequoia 15.5, 2023 Macbook Pro, Neovim 11.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions