Giter Site home page Giter Site logo

Comments (2)

luan avatar luan commented on July 24, 2024

How can I "move" this 1-line change into my user settings?

You'd have to move the whole config.

Do I copy all of lang.lua into one of the lua/user files? Can I re-run the language-server's setup() function from one of those? Is there some clever way to just send my 1 extra config option to the language server at run-time or something?

Pretty much, you can re-run the setup() function after.lua, but beware, as we found in #90 it's a bit buggy, and you need to wrap it invim.schedule():

vim.schedule(function()
lspconfig.rust_analyzer.setup({
         importPrefix = "by_self",
       },
       cargo = {
         loadOutDirsFromCheck = true,
         runBuildScripts = true
       },
end)

This gave me an idea, we could probably export the built-in LSP configs so you can extend them. Basically we can pull out the table (aka object, thanks lua) out of the setup params into a file called lsp_configs.lua, which we then import in lang.lua. You could then import the same file in after.lua and override anything you wanted by merging a custom config in (cue in google how to merge tables in lua, lol).

I'm not sure I'll have time to work on that anytime soon, but would accept a PR.

from nvim.

rosenhouse avatar rosenhouse commented on July 24, 2024

Thanks Luan, I think that did it?!?

I had to copy over some dependencies from lang.lua, so now my full ~/.config/nvim/lua/user/after.lua looks like this, and it seems to be working...

local lspconfig = require('lspconfig')
local capabilities = vim.lsp.protocol.make_client_capabilities()
local lsp_status = require('lsp-status')
local on_attach = function(client, bufnr)
    lsp_status.on_attach(client, bufnr)

    require('lsp_signature').on_attach({
        debug = false,
        handler_opts = {
            border = "single",
        },
    })
end
vim.schedule(function()
    lspconfig.rust_analyzer.setup({
        capabilities = capabilities,
        on_attach = on_attach,
        settings = {
            ["rust-analyzer"] = {
                assist = {
                    importGranularity = "module",
                    importPrefix = "by_self",
                },
                cargo = {
                    loadOutDirsFromCheck = true,
                    runBuildScripts = true
                },
                procMacro = {
                    enable = true
                },
            },
        },
    })
end)

Thank you!

from nvim.

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.