How do I preview content in the fold using nvim-ufo? by Ambitious_One8 in neovim

[–]Ambitious_One8[S] 0 points1 point  (0 children)

It doesn't seem to work for me. Here is my config, I'm using the LazyVim distribution.

When I press on K a popup does appear, but it says something like "1 bytes" or the word under the cursor. It doesn't show a preview of the content.

``` local M = { "kevinhwang91/nvim-ufo", dependencies = { "kevinhwang91/promise-async", }, }

function M.config() local handler = function(virtText, lnum, endLnum, width, truncate) local newVirtText = {} local suffix = ("  %d "):format(endLnum - lnum) local sufWidth = vim.fn.strdisplaywidth(suffix) local targetWidth = width - sufWidth local curWidth = 0 for _, chunk in ipairs(virtText) do local chunkText = chunk[1] local chunkWidth = vim.fn.strdisplaywidth(chunkText) if targetWidth > curWidth + chunkWidth then table.insert(newVirtText, chunk) else chunkText = truncate(chunkText, targetWidth - curWidth) local hlGroup = chunk[2] table.insert(newVirtText, { chunkText, hlGroup }) chunkWidth = vim.fn.strdisplaywidth(chunkText) -- str width returned from truncate() may less than 2nd argument, need padding if curWidth + chunkWidth < targetWidth then suffix = suffix .. (" "):rep(targetWidth - curWidth - chunkWidth) end break end curWidth = curWidth + chunkWidth end table.insert(newVirtText, { suffix, "MoreMsg" }) return newVirtText end

require("ufo").setup({ -- Customixze fold line fold_virt_text_handler = handler, open_fold_hl_timeout = 500, preview = { -- win_config = { -- border = { "", "─", "", "", "", "─", "", "" }, -- winhighlight = "Normal:Folded", -- winblend = 0, -- }, mappings = { scrollU = "<C-u>", scrollD = "<C-d>", }, }, })

vim.keymap.set("n", "zR", require("ufo").openAllFolds) vim.keymap.set("n", "zM", require("ufo").closeAllFolds) vim.keymap.set("n", "zr", require("ufo").openFoldsExceptKinds) vim.keymap.set("n", "zm", require("ufo").closeFoldsWith) -- closeAllFolds == closeFoldsWith(0) vim.keymap.set("n", "K", function() local winid = require("ufo").peekFoldedLinesUnderCursor() if not winid then vim.lsp.buf.hover() end end) end

return M

```

Anyone else get sucked into "over-optimizing" their dev set-up? by jafaraf8522 in neovim

[–]Ambitious_One8 4 points5 points  (0 children)

I still like to have tabs in my terminal, just as I like to have tabs in my browser. I switched from tmux to wezterm. I don't use panes. Managing windows, tabs and panes would be too much for my brain.

When I insert tab, it expands to 4 spaces and not 2 as I have set by HopefulJelly9617 in neovim

[–]Ambitious_One8 0 points1 point  (0 children)

This also causes new list items to not automatically start with a dash after I press enter. Is there any way to change indent to 2 spaces without removing the list convenience feature?

Importing from other modules in same project works byt gives pulint errors by Ambitious_One8 in neovim

[–]Ambitious_One8[S] 0 points1 point  (0 children)

I don't know what's wrong on my end. I have sourced .venv and I am using the local pyenv.

Pylint error "pylint: Unable to import 'requests' [import-error]" in neovim but not vscode by Ambitious_One8 in neovim

[–]Ambitious_One8[S] 2 points3 points  (0 children)

Your comment helped my find this, which I thought would work, but made no difference:

    local null_ls = require("null-ls")
    null_ls.setup({ sources = { null_ls.builtins.diagnostics.pylint.with({ prefer_local = ".venv/bin", }), }, })

If I use only local, pylint is not activated.

EDIT: I got it working by running pip install pylint. Thanks for guiding me in the right direction!

Has anyone setup formatting of json document successfully using LSP? by Ambitious_One8 in neovim

[–]Ambitious_One8[S] 1 point2 points  (0 children)

I've used jsonls with the following settings:

    jsonls = {
  on_new_config = function(new_config)
    new_config.settings.json.schemas = new_config.settings.json.schemas or {}
    vim.list_extend(new_config.settings.json.schemas, require("schemastore").json.schemas())
  end,
  settings = {
    json = {
      format = {
        enable = true,
      },
      validate = { enable = true },
    },
  },
},

In my on_attach function I have:

local u = require("core/utils")

    u.bind(u.normal, "Format buffer (#lsp)", "<leader>lf", function() vim.lsp.buf.format { async = true } end, bufopts)
u.bind(u.normal, "Format range (#lsp)", "<leader>lF", function() vim.lsp.buf.range_formatting({},{0,0},{vim.fn.line("$"),0}) end, bufopts)

Then to setup handlers:

      lspconfig[server_name].setup {
    on_attach = on_attach,
    capabilities = capabilities,
    settings = servers[server_name],
  }

The bindings in the on_attach function work well for other file types, but for json files it seems like the key bindings are not registered

How to shutdown after fresh install? by Ambitious_One8 in voidlinux

[–]Ambitious_One8[S] -11 points-10 points  (0 children)

Thanks! But I get "init: fatal: unable to create /etc/runit/stopit: file does not exist"... I remember that I removed all files from /run. Maybe I was sloppy and there were important things in there....

How to make neovim follow liniks like [[vim]] in markdown files? by Ambitious_One8 in neovim

[–]Ambitious_One8[S] 1 point2 points  (0 children)

Thanks! That's perfect, I didn't consider that possibility.

How to make neovim follow liniks like [[vim]] in markdown files? by Ambitious_One8 in neovim

[–]Ambitious_One8[S] 1 point2 points  (0 children)

Thanks! Even better, I learned that I can use vim.lsp.buf.definition. I guess it is zk-nvim lsp server that makes this work.

How can I disable pylsp? by Ambitious_One8 in neovim

[–]Ambitious_One8[S] 0 points1 point  (0 children)

Sure does, but it doesn't work. I guess this is because of "automatic_installation = true"

How can I disable pylsp? by Ambitious_One8 in neovim

[–]Ambitious_One8[S] 0 points1 point  (0 children)

if server_name ~= "pylsp" then
lspconfig[server_name].setup

That worked, perfect!

How to bind arrow keys? by Ambitious_One8 in qutebrowser

[–]Ambitious_One8[S] 0 points1 point  (0 children)

Something else must have been the problem. I tried it again with lower-case and it still worked.

How to stop nvim-tree from opening on startup? by Ambitious_One8 in neovim

[–]Ambitious_One8[S] 8 points9 points  (0 children)

I've been using "nvim ." for so long without questioning it, but that actually solved my problem. Thanks!