GithubHelp home page GithubHelp logo

Comments (3)

folke avatar folke commented on May 18, 2024 5

I just pushed some change to make it easier to delete/add/change lsp keymaps:

  {
    "neovim/nvim-lspconfig",
    init = function()
      local keys = require("lazyvim.plugins.lsp.keymaps").get()
      -- change a keymap
      keys[#keys + 1] = { "K", "<cmd>echo 'hello'<cr>" }
      -- disable a keymap
      keys[#keys + 1] = { "K", false }
      -- add a keymap
      keys[#keys + 1] = { "H", "<cmd>echo 'hello'<cr>" }
    end,
}

The keymap definition is the same as for the lazy.nvim keys property

from lazyvim.

al-ce avatar al-ce commented on May 18, 2024

Don't know if this is the most efficient way but I copied the entire plugins/lsp/init.lua file in my plugins/ folder (I used plugins/lsp.lua where I put some other lsp related plugin configs) because there were some other things I wanted to change. Relevant changes below:

  {
    "neovim/nvim-lspconfig",
    -- other relevant lazy.nvim settings here, including opts table
    config = function(plugin, opts)
      -- other config stuff here

      -- setup formatting and keymaps
      require("lazyvim.util").on_attach(function(client, buffer)
        require("lazyvim.plugins.lsp.format").on_attach(client, buffer)
        -- require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer)
        require("config.lsp_keymaps").on_attach(client, buffer)
      end)

    -- Other config stuff here
    })
    end
  }

I comment out the on_attach call for keymaps I think you're referring to, while keeping the format opts. Then I add a call to config/lsp_keymaps.lua (where the optional keymaps.lua/options.lua etc files are in the runtime path) that just has a copy of plugins/lsp/keymaps.lua, and from there I can comment out/edit whatever.

Again, not sure that's the most efficient way, but I like it since I can update to any other changes I want to follow with little hassle, since lazy.nvim makes updates so easy to follow.

from lazyvim.

folke avatar folke commented on May 18, 2024

I'll see for an easier way to override those mapping tomorrow!

from lazyvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.