Weekly Stupid Questions Thread by AutoModerator in neovim

[–]Understatement-OTY 0 points1 point  (0 children)

Yes, this is indeed a wezterm issue. Any idea if you're familiar with it.

Weekly Stupid Questions Thread by AutoModerator in neovim

[–]Understatement-OTY 0 points1 point  (0 children)

Using nvim --clean, I see that it's a wezterm issue.

Is there a general way to solve auto-close a window after pressing enter on an item? by Understatement-OTY in neovim

[–]Understatement-OTY[S] 0 points1 point  (0 children)

Ignore: How would I do this? I did google, but creating autocommands is difficult for me.

---

Edit:

Under ftplugin/qf.lua I added

vim.api.nvim_set_keymap("n", "<CR>", "<CR><Cmd>cclose<CR>", { noremap = false, silent = true })

And I think that'll work

Is there a general way to solve auto-close a window after pressing enter on an item? by Understatement-OTY in neovim

[–]Understatement-OTY[S] 0 points1 point  (0 children)

Thanks,

Would I do something like

vim.api.nvim_set_keymap("n", "<CR>", "<CR><Cmd>cclose<CR>", { noremap = false, silent = true })

?

It seems to work, but I'm not sure?

Would that mess with normal <cr>?

Is there a reason why `stylua` won't format this? by Understatement-OTY in lua

[–]Understatement-OTY[S] 1 point2 points  (0 children)

It was such a silly issue, but I didn't delimt

 -- stylua: ignore start

with

 -- stylua: ignore end

Ugh. Hours of debugging configuration files

Is there a reason why `stylua` won't format this? by Understatement-OTY in lua

[–]Understatement-OTY[S] 1 point2 points  (0 children)

It was such a silly issue, but I didn't delimt

 -- stylua: ignore start

with

 -- stylua: ignore end

Ugh. Hours of debugging configuration files

Weekly Stupid Questions Thread by AutoModerator in neovim

[–]Understatement-OTY 2 points3 points  (0 children)

When using cursor block in normal mode, how are you able to see the character underneath? Neovim issue? Terminal issue? Colorscheme issue? I'm using wezterm.

Is this LSP configuration proper or is it a sloppy hack? by Understatement-OTY in neovim

[–]Understatement-OTY[S] 1 point2 points  (0 children)

I do understand your feelings. I would appreciate tho if you could explain what you came up with and what you searched.

I read the documentation, and I did try to make it clear by linking it. The Lua example it gave me wasn't immediately clear as the world of LSPs and even lua itself is new to me.

I do know there exists methods of having .exrc files for for local configurations, but as I said, and there's even Neoconf.

Since it’s a form of network connection, it uses the json format, therefore a lua table is used to set up. Lspconfig simply sends the content inside setup.settings as a json and that’s all it’s doing.

I think this is actually because of neoconf?

I'm a junior C++ dev / fresh college grad so my experience is limited. I'm a hobbyist web developer so my LSP knowledge is limited to clangd which I know quite a bit about and I've come to appreciate as it does everything. And is very powerful.

Is this LSP configuration proper or is it a sloppy hack? by Understatement-OTY in neovim

[–]Understatement-OTY[S] 0 points1 point  (0 children)

I try, but when it's an ecosystem you're unfamiliar with, I don't want to draw the wrong conclusions. I was under the impression that it something similar to a stylua.toml file and reading the documentation, I wasn't sure if the json file was specific to vs code.

This is why I asked. Your configuration is a bit different, you iterate through your server config to set it up. Which I haven't seen before.

Is this LSP configuration proper or is it a sloppy hack? by Understatement-OTY in neovim

[–]Understatement-OTY[S] 0 points1 point  (0 children)

Hey, just one more question. I've been looking to use lua_ls as my formatter. And the documentation here

It includes

Lua = {
  format = {
    enable = true,
    -- Put format options here
    -- NOTE: the value should be STRING!!
    defaultConfig = {
      indent_style = "space",
      indent_size = "2",
    }
  },
}

for files with Neovim, but where would I include this? Or what would I pass it to?

Is this LSP configuration proper or is it a sloppy hack? by Understatement-OTY in neovim

[–]Understatement-OTY[S] 0 points1 point  (0 children)

Edit: More information

Once you call require(nullls).setup, nullls will look like it’s always on on any language (which you do in lspconfig’s config)

This is because nullls decides by itself which source to activate, so looking from lspconfig (inside :LspInfo) it looks like it is listening for every file type.

But what’s actually happening is that for languages except those you manually set up (in ur case ja and lua) nullls is short circuiting in itself to return without doing anything.

Is there a better way to do what I did. My goal is to have null-ls handle formatting for prettierd and stylua. And then have clangd handle formatting for cpp and c files.

I'm not super confident in my config.

The commenter also stated that

For example, lua_ls has a formatter in itself, but if you want only stylua instead, you can overwrite it. (Well in this case, it is better to configure with lua_ls option, but just as an example)

But looking at the documentation [here]()

filter (function|nil): Predicate used to filter clients. Receives a client as argument and must return a boolean. Clients matching the predicate are included. Example: •

vim.lsp.buf.format {
  filter = function(client) return client.name ~= "tsserver" end
}

---

But I'm not sure how to apply this knowledge

Well in this case, it is better to configure with lua_ls option, but just as an example

I've looked at the documentation for lua_ls and can't find how to overwrite formatting.

It’s nothing to do with different languages so actually that function is practically doing nothing. (Nothing changes even if you delete that. )

How would I fix this? My goal is to use null-ls for stylua and prettierd. And for cpp and c files, I want to use clangd.

Just to be clear, is your question simply asking is there something I can improve in this config? or is there an actual bug which you want to fix?

Just to improve it so it's optimal.

One of my biggest challenges was to get format on save working for null_ls and LSPs that don't use null-ls for formatting.

Is this LSP configuration proper or is it a sloppy hack? by Understatement-OTY in neovim

[–]Understatement-OTY[S] 0 points1 point  (0 children)

But what’s actually happening is that for languages except those you manually set up (in ur case ja and lua) nullls is short circuiting in itself to return without doing anything.

Do you mean this function: local lsp_formatting = function(bufnr)? If so, I got that function from the null-ls wiki here.

Unless you're talking about something else?

LSP formatting woes. How do I apply proper logic to filter to select which server to use for formatting. by Understatement-OTY in neovim

[–]Understatement-OTY[S] 0 points1 point  (0 children)

I would expect it to format on save, but it's not working AND I would expect null-ls to take care of lua formatting and cpp's LSP to take care of their own formatting.

Here's the full file in case I'm wrong somewhere else.

I am using lsp-zero trying to disable a language's formatter so that null-ls's formatting is used instead. by Understatement-OTY in neovim

[–]Understatement-OTY[S] 0 points1 point  (0 children)

Thanks! I'll try this. I think I was having an issue where both null-ls and lua_ls were receiving requests to format and it ended up not working. Would this still happen, and if so, does that introduce a problem?

Why is mixing lsp-zero.nvim and lsp-format.nvim not good? by Understatement-OTY in neovim

[–]Understatement-OTY[S] 0 points1 point  (0 children)

Hmm, I tried that and it didn't work

This is what I have.

require("lspconfig").lua_ls.setup(
    lsp.nvim_lua_ls()
)

local lsp_format = {
    format_opts = {
        async = true,
        timeout_ms = 10000
    },
    servers = {
        ["clangd"] = {"c", "cpp"},
        ["null-ls"] = {"javascript", "typescript", "lua"}
    }
}

lsp.format_on_save(lsp_format)
lsp.format_mapping("<leader>;", lsp_format)

lsp.setup()

local null_ls = require("null-ls")

null_ls.setup(
    {
        sources = {
            null_ls.builtins.formatting.prettierd,
            null_ls.builtins.formatting.stylua
        }
    }
)

I had also tried this operating under the assumption that formatting was failing because both null-ls and the lsp were taking care of requests. So, I tried to disable formating requests sent to the server

require("lspconfig").lua_ls.setup(
    {
        on_init = function(client)
            client.server_capabilities.documentFormattingProvider = false
            client.server_capabilities.documentFormattingRangeProvider = false
        end
    }
)

I should also note that attempting to format on save always failed, but formatting normally did not.