Skip to content

Commit

Permalink
Words and small tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
treeman committed May 31, 2024
1 parent 8ff7b16 commit aefd189
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 39 deletions.
46 changes: 33 additions & 13 deletions drafts/migrating_to_rocksnvim.dj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ At times I'm deeply in love and spend all my time caressing the config---like ho
While not as intense as the September affair, I recently got back together with my config to migrate her from the "old and boring" [lazy.nvim][] package manager to the new and exciting [rocks.nvim][].
It wasn't all smooth sailing but with some patience---and a drink or two---our threesome with [rocks.nvim][] was quite enjoyable.

::: note
::: important
There's nothing wrong with [lazy.nvim][]---it's great.\
Sometimes I just want to try out new things.
:::
Expand Down Expand Up @@ -285,28 +285,48 @@ With that said, being able to lazy load plugins is a great feature when you need

## Packadd

{path="rocks.toml"}
```toml
[plugins]
neorg = { version = "1.0.0", opt = true }
```
On a basic level you can accomplish lazy loading by following these three steps:

1. Mark the plugin with `opt = true`lua.

{path="rocks.toml"}
```toml
[plugins]
neorg = { version = "1.0.0", opt = true }
```

This will prevent [rocks.nvim][] from sourcing the plugin at startup.

2. Add the plugin with `packadd`.

```lua
vim.cmd("packadd neorg")
```

3. Setup and configure the plugin as needed.

Steps 2 and 3 should be done on-demand, for example via an autocommand:

```lua
vim.cmd("packadd neorg")
vim.api.nvim_create_autocmd({ "BufReadPre", "BufNewFile" }, {
pattern = "*.norg",
callback = function()
vim.cmd("packadd neorg")
require("neorg").setup()
return true
end,
})
```

## Lazy setup

{path="lua/config/lazy.lua"}
```lua
local autocmd = vim.api.nvim_create_autocmd
local augroup = vim.api.nvim_create_augroup

autocmd({ "BufReadPre", "BufNewFile" }, {
vim.api.nvim_create_autocmd({ "BufReadPre", "BufNewFile" }, {
pattern = "*",
group = augroup("lazy_plugins.lspconfig", { clear = true }),
callback = function(opts)
callback = function()
require("lazy_plugins.lspconfig")
return true
end,
})
```
Expand Down
52 changes: 26 additions & 26 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@ function connect() {
case "Refresh":
location.reload();
break;
case "PositionPage":
// TODO this doesn't work when we have images.
// I guess we need to do some searching to find the best match...

// https://stackoverflow.com/questions/5007530/how-do-i-scroll-to-an-element-using-javascript#22292000
//
// Search for inner text!
// https://stackoverflow.com/questions/3813294/how-to-get-element-by-innertext

const curr_url = window.location.href
.replace(window.location.origin, "")
.replace(/\/$/, "");

if (msg.url == curr_url) {
const cursor = msg.linenum / msg.linecount;
// const target = window.scrollMaxY * cursor - window.screen.height / 6;
const target = window.scrollMaxY * cursor;
// const target = window.scrollMaxY * cursor - window.screen.height;
window.scrollTo(0, target);

// window.scrollTo(0, 0);
// window.scrollByLines(msg.linenum);
break;
}
default:
console.log("Unknown message: ", msg);
//case "PositionPage":
// // TODO this doesn't work when we have images.
// // I guess we need to do some searching to find the best match...
//
// // https://stackoverflow.com/questions/5007530/how-do-i-scroll-to-an-element-using-javascript#22292000
// //
// // Search for inner text!
// // https://stackoverflow.com/questions/3813294/how-to-get-element-by-innertext
//
// const curr_url = window.location.href
// .replace(window.location.origin, "")
// .replace(/\/$/, "");
//
// if (msg.url == curr_url) {
// const cursor = msg.linenum / msg.linecount;
// // const target = window.scrollMaxY * cursor - window.screen.height / 6;
// const target = window.scrollMaxY * cursor;
// // const target = window.scrollMaxY * cursor - window.screen.height;
// window.scrollTo(0, target);
//
// // window.scrollTo(0, 0);
// // window.scrollByLines(msg.linenum);
// break;
// }
//default:
// console.log("Unknown message: ", msg);
}

return false;
Expand Down
1 change: 1 addition & 0 deletions src/server/complete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ fn div_class_completions() -> Vec<CompletionItem> {
DivClass::Note,
DivClass::Tip,
DivClass::Warn,
DivClass::Important,
DivClass::Greek,
]
.into_iter()
Expand Down

0 comments on commit aefd189

Please sign in to comment.