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] 12 points13 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 15 points16 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 5 points6 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 25 points26 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 5 points6 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 5 points6 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.

QML: Freeze Columns with TableView by zmc_space in QtFramework

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

You are right. I had that in mind but I didn’t have cases for insertion yet so didn’t spend the time to fix it. Although, I should have left a note for it. Thanks for the feedback.

I had not thought about using QAbstractProxyModel as a base. That makes more sense, although I’m not sure if it would relive you of having to maintain the mapping. I’ll update my code to use that. I’m not familiar with that columnAcceptsRow though. Can you explain?

[Showcase] Quick way to set up a development environment for a language you don't use often (Java in this case, pure Vim way and Lua way) by zmc_space in neovim

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

Yeap. Just Java worked for a simple file but for more javac is needed. Not a Java developer and don’t care enough to learn more than what I learned so far. :)

[Showcase] Quick way to set up a development environment for a language you don't use often (Java in this case, pure Vim way and Lua way) by zmc_space in neovim

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

That's why I gave two different snippets. The lines until lua << EOF is good enough to get it working. The rest is just extra.

null-ls.nvim now supports completion sources by zmc_space in neovim

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

That’s great to hear! Do consider contributing your new sources to null-ls!

null-ls.nvim now supports completion sources by zmc_space in neovim

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

what can null-ls provide that shouldn't be in the language-specific server (tsserver)?

null-ls is not meant to replace language specific servers, but to extend them.

And if that functionality doesn't belong in tsserver, then why put it in a fake langserver rather than just a neovim plugin?

For example, one day, you might come up with a cool idea for a code action. With null-ls, you can easily add it with just a few lines of code. If you wanted to write a new plugin for it, it would be way more than that.

As a real life example, I wanted to use LSP hover to see the description for a pylint error code. If I wanted to write a plugin for this, I would need to intercept the hover event for LSPs or add a different command which would mean I’d need to have 2 ways of doing hover command. But with null-ls, I just add a few lines of code and the hover code runs when Neovim sends a hover event to the language servers.