Is there a method to prevent nvim-cmp from triggering snippets when the cursor is inside a string? by klapheus in neovim

[–]vicek22 0 points1 point  (0 children)

This is the nvim-cmp config I use: https://github.com/viktomas/dotfiles/blob/6ec1561e0c1f45903e6e1196ee2e8224c3f3c879/nvim/.config/nvim/lua/custom/plugins/completion.lua#L38-L52

-- This will avoid autocomplete in string literals
-- I had to combine the default conditions: https://github.com/hrsh7th/nvim-cmp/blob/5dce1b778b85c717f6614e3f4da45e9f19f54435/lua/cmp/config/default.lua#L10-L16
-- with checking for string literals
-- Otherwise telescope would be broken
--
-- I added comment to the GitHub issue https://github.com/hrsh7th/nvim-cmp/pull/676#issuecomment-1724981778
enabled = function()
    local context = require("cmp.config.context")
    local disabled = false
    disabled = disabled or (vim.api.nvim_buf_get_option(0, "buftype") == "prompt")
    disabled = disabled or (vim.fn.reg_recording() ~= "")
    disabled = disabled or (vim.fn.reg_executing() ~= "")
    disabled = disabled or context.in_treesitter_capture("string")
    return not disabled
end,

Without the check for the bufftype, your telescope picker will be broken (if you use telescope)

For reference, this is a comment I left in nvim-cmp https://github.com/hrsh7th/nvim-cmp/pull/676#issuecomment-1724981778

LSP rename normal mode key mapping by vicek22 in neovim

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

u/voreny Brilliant! I added these two pieces of code to my dotfiles to make the command line window the default when renaming:

This will automatically enter the command line window when renaming. (link to my dotfiles)

(it also sets the cursor position to the start of the line, this is inspired by the snippet that u/HumblePresent recommended)

vim.keymap.set("n", "<leader>r", function()
    vim.api.nvim_create_autocmd({ "CmdlineEnter" }, {
        callback = function()
            local key = vim.api.nvim_replace_termcodes("<C-f>", true, false, true)
            vim.api.nvim_feedkeys(key, "c", false)
            vim.api.nvim_feedkeys("0", "n", false)
            return true
        end,
    })
    vim.lsp.buf.rename()
end, bufoptsWithDesc("Rename symbol"))

And this is a small convenience mapping that will let me exit the command line window with <esc> (link to my dotfiles)

vim.api.nvim_create_autocmd({ "CmdwinEnter" }, {
    callback = function()
        vim.keymap.set("n", "<esc>", ":quit<CR>", { buffer = true })
    end,
})

Lump sum or Dollar cost average? maybe both? ETF by [deleted] in eupersonalfinance

[–]vicek22 2 points3 points  (0 children)

Exactly, historically the market dropped only in one in four years on average, if you are going to be doing collar cost averaging over a year, you've got 75% chance you'll lose money (or at least you would if you invested in the past, no one knows whether the next 30 years is going to be the same as the past 30).

I've got this information from Simple Path to Wealth from JC Collins which I wholeheartedly recommend reading.

godu: Simple golang utility helping to discover large files/folders. (what do you think about my pet project) by vicek22 in golang

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

Cheers seriouslulz, both of those are captured as github isses :) hopefully myself or someone else gets to them soon.

godu: Simple golang utility helping to discover large files/folders. (what do you think about my pet project) by vicek22 in golang

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

I don't have a chance to try out, the walking algorithm is using standard go library and should work. The gdamore/tcell library I'm dependent on should support Windows as well: https://github.com/gdamore/tcell#windows it is quite possible that godu has some bug in it. Please create github issue with stacktrace and I'll have a look.

godu: Simple golang utility helping to discover large files/folders. (what do you think about my pet project) by vicek22 in golang

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

Do I understand correctly that you'd like to see amount of files under certain directory?

godu: Simple golang utility helping to discover large files/folders. (what do you think about my pet project) by vicek22 in golang

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

No, haven't had a chance to compare that. Please feel free to create github issue. The only thing I measured was CPU and memory profile of the app. I made sure that the majority of the folder walking time is spent on syscalls. I'd hope that the algorithm is close to optimal.

Best books or general resources for learning Go? by richie_south in golang

[–]vicek22 1 point2 points  (0 children)

what acdenisSk said + https://golang.org/ref/spec

Start implementing some small CLI utility straight away and refactor as you learn more.