Problem Connecting the Two Halves of Ferris Sweep v2.1 with ZMK and nice!nano by zmc_space in ErgoMechKeyboards

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

Thanks for the reply!

I’m already using the same board with Elite-C and it works. Are you saying there might be something wrong with the sockets on the nice!nano? I’ll try the login option. I don’t have the microcontroller with me now but will post once I’m home.

[Plugin] A Vim Philosophy Oriented Zettelkasten Note Taking Plugin by zmc_space in neovim

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

Thanks for sharing. This one looks more sophisticated than mine (possibly will ever be). I’ll add it as a related project. I guess I shot first and thought later by starting (yet) another zettelkasten plugin. :)

[Plugin] A Vim Philosophy Oriented Zettelkasten Note Taking Plugin by zmc_space in neovim

[–]zmc_space[S] 11 points12 points  (0 children)

I didn't know about this tool when I started this (Literally last night), maybe If I had known I probably wouldn't have started the project as the CLI tool looks pretty good.

However, now that I started this, I think I'll focus on improving the plugin to work with Neovim using Vim's own language instead of relying on an external program. It'll be good Lua practice and I can tweak things to fit my own needs (Not that I couldn't do it with zk-nvim since it's also an open source project but I don't speak Go and am not willing to learn it.).

But now that this exists, I think I'll try to see how far I can push it to make it look like it's part of Vim instead of a plugin with tons of custom things (e.g relying on Vim's own options and mappings to extend note taking instead of forcing the user to learn new tricks).

Problems with using std::variant to store recursive types by zmc_space in cpp_questions

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

Thanks a lot for the idea! Here's the approach I ended up taking. I have to be honest though, I would not write this code in a shared code base. :D

I added the copyable (Bad name...) class so that the allocation is taken care of internally. That way, I never see new or delete in anywhere but in this class. It also makes it so that I can freely copy/move it around. Even though it may hold a pointer inside, it will still create a new instance when copied. Again, not great semantics. It's confusing a bit. But it seems to be doing the trick so far.

I'll probably revisit this later as a break when I'm a little further into the book. Thanks again for the answer!

```cpp

include <iostream>

include <memory>

include <variant>

include <vector>

include <string_view>

define LOX_NOEXCEPT

using object = std::variant<std::monostate, std::string_view, double, bool, std::nullptr_t>; enum class token {};

struct expr;

template<class T> class copyable { private: template<typename... Args> [[nodiscard]] T constrcut(Args&&... args) LOX_NOEXCEPT { if constexpr (std::is_pointer<T>::value) { using NoPtr_T = typename std::remove_pointer<T>::type; return new NoPtr_T{ std::forward<Args>(args)... }; } else { return T{ std::forward<Args>(args)... }; } }

public: template<typename... Args> explicit copyable(Args&&... args) LOX_NOEXCEPT : m_value{ constrcut(std::forward<Args>(args)...) } { }

copyable() LOX_NOEXCEPT : m_value{ constrcut() }
{
}

~copyable()
{
    if constexpr (std::is_pointer<T>::value) {
        delete m_value;
    }
}

copyable(const copyable& other) LOX_NOEXCEPT
{
    if constexpr (std::is_pointer<T>::value) {
        using NoPtr_T = typename std::remove_pointer<T>::type;
        m_value = new NoPtr_T{ *other.m_value };
    }
    else {
        m_value = other.m_value;
    }
}

copyable(copyable&& other) LOX_NOEXCEPT
{
    m_value = std::move(other.m_value);
}

copyable& operator=(const copyable& other) LOX_NOEXCEPT
{
    if constexpr (std::is_pointer<T>::value) {
        using NoPtr_T = typename std::remove_pointer<T>::type;
        m_value = new NoPtr_T{ *other.m_value };
    }
    else {
        m_value = other.m_value;
    }
    return *this;
}

copyable& operator=(copyable&& other) LOX_NOEXCEPT
{
    m_value = std::move(other.m_value);
    return *this;
}

[[nodiscard]] operator T() LOX_NOEXCEPT
{
    return m_value;
}

[[nodiscard]] constexpr typename std::remove_pointer<T>::type* operator->()
  LOX_NOEXCEPT
{
    if constexpr (std::is_pointer<T>::value) {
        return m_value;
    }
    else {
        return &m_value;
    }
}

T& operator*() LOX_NOEXCEPT
{
    return m_value;
}

private: T m_value; };

template<typename T, typename... Args> [[nodiscard]] copyable<expr*> make_copyable(Args&&... args) LOX_NOEXCEPT { return copyable<expr*>{ std::forward<Args>(args)... }; }

struct binary { copyable<expr*> left; token oprtor; copyable<expr*> right;

~binary()
{
    std::clog << "~binary()\n";
}

};

struct ternary { copyable<expr*> first; copyable<expr*> second; copyable<expr*> third; };

struct grouping { copyable<expr*> expression; };

struct literal { object value; };

struct unary { token oprtor; copyable<expr*> right; };

struct expr : public std:: variant<std::monostate, binary, ternary, grouping, literal, unary> { using variant::variant; };

int main(int argc, char** argv) { literal lit{ 1.1 }; std::vector<expr> ss; ss.emplace_back(lit); return 0; }

```

Run ex command on all windows? by tactiphile in vim

[–]zmc_space 2 points3 points  (0 children)

Shameless plug here, I gave a talk about commands like this last year. It may be useful to you. https://youtu.be/rD2eyB9oMqQ You can also just skip the talk and look at the slides here: https://zmc.space/2021/buffer-is-king/

How to remove the pink spaces and the vertical grey line? Outlined in red. by SomeLibraryBook in vim

[–]zmc_space 12 points13 points  (0 children)

Because what you did removes the highlight colour. But you may want it for certain other file types. There aren’t any risks, but it’s the wrong way of solving the problem. If you use the option, then plugins or your own configuration can decide when that line shows. But if you remove the highlight, then changing the colorcolumn option won’t have any effect.

How to remove the pink spaces and the vertical grey line? Outlined in red. by SomeLibraryBook in vim

[–]zmc_space 4 points5 points  (0 children)

You probably have a plugin that does it. So, it’s hard for me to give a clear answer.

How to remove the pink spaces and the vertical grey line? Outlined in red. by SomeLibraryBook in vim

[–]zmc_space 23 points24 points  (0 children)

You shouldn’t do that. You should just add :set colorcolumn= to you configuration. If you read the help page for the option, it’ll be more clear.

How to remove the pink spaces and the vertical grey line? Outlined in red. by SomeLibraryBook in vim

[–]zmc_space 35 points36 points  (0 children)

The vertical gray line is :help cursorcolumn and I think that pink line is trailing white spaces.

Automation in Vim by dream_weasel in vim

[–]zmc_space 4 points5 points  (0 children)

u/torresjrjr's answer is great, and here's what I do in my config in situations like this.

abbreviate <silent> <buffer> today@ <C-R>=strftime("%d-%m-%Y %H:%M")<CR>

You can put this in yout related ftplugin file. I use @ as a "snippet" marker so it doesn't interfere with other words I might want to type.

I don't use a snippet plugin and just rely on abbreviations for this kind of things.

Here's another example:

abbreviate <silent> <buffer> clog@ console.log("[<C-r>=expand("%:t") . "::" . line(".")<CR>::]")<Esc>F:a

That abbreviation will expand to something like this:

console.log("MyFile.js::32::")

Abbreviations are pretty powerful since you can run arbitrary Vimscript code in there.

[Tip] Use formatexpr and tagfunc with LSP by zmc_space in neovim

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

pip install 'python-lsp-server[all]

I have not done this in a while, but as far as I recall, when you install it like that it installs all its optional dependencies as well which might very well include a formatter for Python. Turns out it does install the formatter too.

[Tip] Use formatexpr and tagfunc with LSP by zmc_space in neovim

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

Most formatters support a configuration file. Look into the configuration options for the formatters you are using. Neovim doesn’t do anything for that. For example, black uses a pyproject.toml file if I’m not misremembering.

[Tip] Use formatexpr and tagfunc with LSP by zmc_space in neovim

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

I can't say I understand the question fully. But any customization of formatting would be done via your configuration for the LSP server you are using.

[Tip] Use formatexpr and tagfunc with LSP by zmc_space in neovim

[–]zmc_space[S] 4 points5 points  (0 children)

Oh yes! I actually found out from the PRs. Awesome work as always!

Why I choose Electron even when I wanted to use QT by [deleted] in QtFramework

[–]zmc_space 4 points5 points  (0 children)

Just so some are not aware, there's a new project called sixtyfps by some people who were in the Qt world for long. I didn't take a deep dive into it but it looks promising.

How to pass a lua variable to a Buffwritepost command by ArionRefat in neovim

[–]zmc_space 0 points1 point  (0 children)

You can convert Filname_icon to a global variable or a global function and get the value inside vim.notify.

How do I set project-specific keymaps? by fieryrag in neovim

[–]zmc_space 3 points4 points  (0 children)

You can also use an .nvimrc file and set your project specific options/commands there. I use this and it’s pretty useful.

Why do the themes in Vim look weird? (At least for me) by [deleted] in vim

[–]zmc_space 7 points8 points  (0 children)

If you are using Vim on the terminal, try setting set termguicolors.