Compare commits

..

No commits in common. "99da3611cd312ad1bd2e07c6ad3866f22cc16499" and "b7fece3a2322cc65419b7fc2fe4eaee28448ed5c" have entirely different histories.

41 changed files with 688 additions and 1454 deletions

9
.gitignore vendored
View File

@ -1 +1,8 @@
lazy-lock.json
tt.*
.tests
doc/tags
debug
.repro
foo.*
*.log
data

15
.neoconf.json Normal file
View File

@ -0,0 +1,15 @@
{
"neodev": {
"library": {
"enabled": true,
"plugins": true
}
},
"neoconf": {
"plugins": {
"lua_ls": {
"enabled": true
}
}
}
}

201
LICENSE Normal file
View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

4
README.md Normal file
View File

@ -0,0 +1,4 @@
# 💤 LazyVim
A starter template for [LazyVim](https://github.com/LazyVim/LazyVim).
Refer to the [documentation](https://lazyvim.github.io/installation) to get started.

View File

@ -1,9 +1,3 @@
-- Handle plugins with lazy.nvim
require("core.lazy")
-- General Neovim keymaps
require("core.keymaps")
-- Other options
require("core.options")
-- bootstrap lazy.nvim, LazyVim and your plugins
require("config.lazy")
require("config.manual_color")

52
lazy-lock.json Normal file
View File

@ -0,0 +1,52 @@
{
"LazyVim": { "branch": "main", "commit": "3f034d0a7f58031123300309f2efd3bb0356ee21" },
"blink.cmp": { "branch": "main", "commit": "18b352d12b35bca148427b607098df14b75a218f" },
"bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" },
"catppuccin": { "branch": "main", "commit": "4bb938bbba41d306db18bf0eb0633a5f28fd7ba0" },
"conform.nvim": { "branch": "master", "commit": "a6f5bdb78caa305496357d17e962bbc4c0b392e2" },
"crates.nvim": { "branch": "main", "commit": "1803c8b5516610ba7cdb759a4472a78414ee6cd4" },
"duck.nvim": { "branch": "main", "commit": "d8a6b08af440e5a0e2b3b357e2f78bb1883272cd" },
"flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" },
"friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" },
"fzf-lua": { "branch": "main", "commit": "9b84b53f3297d4912d7eb95b979e9b27e2e61281" },
"gitsigns.nvim": { "branch": "main", "commit": "4c40357994f386e72be92a46f41fc1664c84c87d" },
"grug-far.nvim": { "branch": "main", "commit": "0e391cc375702299b8dac101ff5a7d418fb193b9" },
"hardtime.nvim": { "branch": "main", "commit": "b44e11d7a176f184db8b9666a1b41d5890aa5a5b" },
"harpoon": { "branch": "master", "commit": "1bc17e3e42ea3c46b33c0bbad6a880792692a1b3" },
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
"lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" },
"lualine.nvim": { "branch": "master", "commit": "f4f791f67e70d378a754d02da068231d2352e5bc" },
"markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" },
"mason-nvim-dap.nvim": { "branch": "main", "commit": "09220b99d63d5363f219daa2785242ee5fddba7f" },
"mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" },
"mini.ai": { "branch": "main", "commit": "6e01c0e5a15554852546fac9853960780ac52ed4" },
"mini.icons": { "branch": "main", "commit": "ec61af6e606fc89ee3b1d8f2f20166a3ca917a36" },
"mini.pairs": { "branch": "main", "commit": "1a3e73649c0eaef2f6c48ce1e761c6f0a7c11918" },
"neo-tree.nvim": { "branch": "main", "commit": "e6f5b5e044ba9f380e82fc942212e0679d83b6f6" },
"noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" },
"nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" },
"nvim-dap": { "branch": "master", "commit": "379cf26e9c457b66a0152cd5d018418c03720d47" },
"nvim-dap-ui": { "branch": "master", "commit": "bc81f8d3440aede116f821114547a476b082b319" },
"nvim-dap-virtual-text": { "branch": "master", "commit": "df66808cd78b5a97576bbaeee95ed5ca385a9750" },
"nvim-lint": { "branch": "master", "commit": "6e9dd545a1af204c4022a8fcd99727ea41ffdcc8" },
"nvim-lspconfig": { "branch": "master", "commit": "99c75820f2606b6b446cad7c75ec2ef7ee8a1317" },
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
"nvim-treesitter": { "branch": "master", "commit": "93ce9feb4fabbb37b3e7f47d80f27be778f4d956" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "ad8f0a472148c3e0ae9851e26a722ee4e29b1595" },
"nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" },
"persistence.nvim": { "branch": "main", "commit": "166a79a55bfa7a4db3e26fc031b4d92af71d0b51" },
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
"rainbow-delimiters.nvim": { "branch": "master", "commit": "011d98eaa3a73b5a51d82ce5bc6b1397dde95562" },
"render-markdown.nvim": { "branch": "main", "commit": "98a3b7d3a5befe495f0ab6ca967068f5f1da4421" },
"rustaceanvim": { "branch": "master", "commit": "2b0f0b7e03751cf8ed123322f9b02d8f73fa9df7" },
"smear-cursor.nvim": { "branch": "main", "commit": "4b7334a09cd2434e73588cc0ea63e71177251249" },
"snacks.nvim": { "branch": "main", "commit": "e17d60712c96af7359d61540bd2f421352e4f144" },
"todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" },
"toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" },
"tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" },
"trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" },
"ts-comments.nvim": { "branch": "main", "commit": "872dcfa0418f4a33b7437fb4d9f4e89f2f000d74" },
"vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" },
"which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }
}

15
lazyvim.json Normal file
View File

@ -0,0 +1,15 @@
{
"extras": [
"lazyvim.plugins.extras.dap.core",
"lazyvim.plugins.extras.editor.harpoon2",
"lazyvim.plugins.extras.lang.markdown",
"lazyvim.plugins.extras.lang.rust",
"lazyvim.plugins.extras.lang.toml",
"lazyvim.plugins.extras.ui.smear-cursor"
],
"install_version": 7,
"news": {
"NEWS.md": "10960"
},
"version": 8
}

View File

@ -1,44 +0,0 @@
{
"workspace.library": [
"/home/robot/.local/share/nvim/lazy/neodev.nvim/types/stable",
"/squashfs-root/usr/share/nvim/runtime/lua",
"/home/robot/.local/share/nvim/lazy/close-buffers.nvim/lua",
"/home/robot/.local/share/nvim/lazy/which-key.nvim/lua",
"/home/robot/.local/share/nvim/lazy/melange-nvim/lua",
"/home/robot/.local/share/nvim/lazy/nvim-treesitter-textobjects/lua",
"/home/robot/.local/share/nvim/lazy/telescope.nvim/lua",
"/home/robot/.local/share/nvim/lazy/null-ls.nvim/lua",
"/home/robot/.local/share/nvim/lazy/telescope-fzf-native.nvim/lua",
"/home/robot/.local/share/nvim/lazy/nvim-web-devicons/lua",
"/home/robot/.local/share/nvim/lazy/nvim-cmp/lua",
"/home/robot/.local/share/nvim/lazy/lualine.nvim/lua",
"/home/robot/.local/share/nvim/lazy/cmp-nvim-lsp/lua",
"/home/robot/.local/share/nvim/lazy/cmp-nvim-lua/lua",
"/home/robot/.local/share/nvim/lazy/nvim-lspconfig/lua",
"/home/robot/.local/share/nvim/lazy/catppuccin/lua",
"/home/robot/.local/share/nvim/lazy/cmp-buffer/lua",
"/home/robot/.local/share/nvim/lazy/mason.nvim/lua",
"/home/robot/.local/share/nvim/lazy/gitsigns.nvim/lua",
"/home/robot/.local/share/nvim/lazy/mini.move/lua",
"/home/robot/.local/share/nvim/lazy/cmp-path/lua",
"/home/robot/.local/share/nvim/lazy/lazy.nvim/lua",
"/home/robot/.local/share/nvim/lazy/git-conflict.nvim/lua",
"/home/robot/.local/share/nvim/lazy/nvim-treesitter/lua",
"/home/robot/.local/share/nvim/lazy/everforest/lua",
"/home/robot/.local/share/nvim/lazy/LuaSnip/lua",
"/home/robot/.local/share/nvim/lazy/rose-pine/lua",
"/home/robot/.local/share/nvim/lazy/nui.nvim/lua",
"/home/robot/.local/share/nvim/lazy/gruvbox.nvim/lua",
"/home/robot/.local/share/nvim/lazy/plenary.nvim/lua",
"/home/robot/.local/share/nvim/lazy/cmp_luasnip/lua",
"/home/robot/.local/share/nvim/lazy/bufferline.nvim/lua",
"/home/robot/.local/share/nvim/lazy/neodev.nvim/lua",
"/home/robot/.local/share/nvim/lazy/mason-lspconfig.nvim/lua",
"/home/robot/.local/share/nvim/lazy/Comment.nvim/lua",
"/home/robot/.local/share/nvim/lazy/fidget.nvim/lua",
"/home/robot/.local/share/nvim/lazy/neo-tree.nvim/lua",
"/home/robot/.local/share/nvim/lazy/vim-illuminate/lua",
"/home/robot/.config/nvim/lua",
"${3rd}/luv/library"
]
}

8
lua/config/autocmds.lua Normal file
View File

@ -0,0 +1,8 @@
-- Autocmds are automatically loaded on the VeryLazy event
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
--
-- Add any additional autocmds here
-- with `vim.api.nvim_create_autocmd`
--
-- Or remove existing autocmds by their group name (which is prefixed with `lazyvim_` for the defaults)
-- e.g. vim.api.nvim_del_augroup_by_name("lazyvim_wrap_spell")

31
lua/config/keymaps.lua Normal file
View File

@ -0,0 +1,31 @@
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
-- Add any additional keymaps here
-- Keymaps are automatically loaded on the VeryLazy event
local map = vim.keymap.set
map("n", ";", "A;<Esc>")
-- Lazygit config
local Terminal = require("toggleterm.terminal").Terminal
local lazygit = Terminal:new({ cmd = "lazygit", hidden = true, direction = "tab" })
function _lazygit_toggle()
lazygit:toggle()
end
map("n", "<leader>gg", "<cmd>lua _lazygit_toggle()<cr>")
-- Bacon config
local bacon = Terminal:new({ cmd = "bacon --job clippy", hidden = true, direction = "tab" })
function _bacon_toggle()
bacon:toggle()
end
map("n", "<leader>h", "<cmd>lua _bacon_toggle()<cr>")
-- Wiki-tui config
local wiki = Terminal:new({ cmd = "wiki-tui", hidden = true, direction = "tab" })
function _wiki_toggle()
wiki:toggle()
end
map("n", "<leader>sl", "<cmd>lua _wiki_toggle()<cr>")

53
lua/config/lazy.lua Normal file
View File

@ -0,0 +1,53 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
spec = {
-- add LazyVim and import its plugins
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
-- import/override with your plugins
{ import = "plugins" },
},
defaults = {
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
lazy = false,
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
-- have outdated releases, which may break your Neovim install.
version = false, -- always use the latest git commit
-- version = "*", -- try installing the latest stable version for plugins that support semver
},
install = { colorscheme = { "tokyonight", "habamax" } },
checker = {
enabled = true, -- check for plugin updates periodically
notify = false, -- notify on update
}, -- automatically check for plugin updates
performance = {
rtp = {
-- disable some rtp plugins
disabled_plugins = {
"gzip",
-- "matchit",
-- "matchparen",
-- "netrwPlugin",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
},
},
})

View File

@ -0,0 +1,15 @@
vim.api.nvim_set_hl(0, "String", { fg = "#9ece6a", underline = false, bold = false })
vim.api.nvim_set_hl(0, "Type", { fg = "#00ff00", underline = false, bold = false })
vim.api.nvim_set_hl(0, "Structure", { fg = "#00ff00", underline = false, bold = false })
vim.api.nvim_set_hl(0, "Constant", { fg = "#fab387", underline = false, bold = true })
vim.api.nvim_set_hl(0, "@lsp.type.selfKeyword.rust", { fg = "#b00202", bold = true, underline = false })
vim.api.nvim_set_hl(0, "@lsp.type.typeParamater.rust", { fg = "#ffbf00", bold = true, underline = false })
vim.api.nvim_set_hl(0, "Identifier", { fg = "#ffffff", underline = false, bold = false })
vim.api.nvim_set_hl(0, "Function", { fg = "#025fb0", underline = false, bold = false })
vim.api.nvim_set_hl(0, "@lsp.type.enumMember.rust", { fg = "#fab387", underline = false, bold = false })
vim.api.nvim_set_hl(0, "@lsp.type.interface", { fg = "#a402b0", bold = true, underline = false })
vim.api.nvim_set_hl(0, "Comment", { fg = "#989898", bold = false, underline = false })
vim.api.nvim_set_hl(0, "NvimTreeGitDirty", { fg = "#ffaa00", bold = false, underline = false })
vim.api.nvim_set_hl(0, "@string.escape", { fg = "#aa00ff", bold = false, underline = false })
vim.api.nvim_set_hl(0, "@type.builtin", { fg = "#00ff00", bold = false, underline = false })
vim.api.nvim_set_hl(0, "@lsp.mod.unsafe.rust", { bg = "#aa0000" })

6
lua/config/options.lua Normal file
View File

@ -0,0 +1,6 @@
-- Options are automatically loaded before lazy.nvim startup
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
-- Add any additional options here
vim.g.snacks_animate = false
vim.o.shiftwidth = 4

View File

@ -1,104 +0,0 @@
local map = require("helpers.keys").map
-- Quick access to some common actions
map("n", "<leader>fw", "<cmd>w<cr>", "Write")
map("n", "<leader>fa", "<cmd>wa<cr>", "Write all")
map("n", "<leader>qq", "<cmd>q<cr>", "Quit")
map("n", "<leader>qa", "<cmd>qa!<cr>", "Quit all")
map("n", "<leader>dw", "<cmd>close<cr>", "Window")
map("n", ";", "A;<Esc>", "places \";\" at end of line")
-- Diagnostic keymaps
map('n', 'gx', vim.diagnostic.open_float, "Show diagnostics under cursor")
-- Easier access to beginning and end of lines
map("n", "<M-h>", "^", "Go to beginning of line")
map("n", "<M-l>", "$", "Go to end of line")
-- Better window navigation
map("n", "<C-h>", "<C-w><C-h>", "Navigate windows to the left")
map("n", "<C-j>", "<C-w><C-j>", "Navigate windows down")
map("n", "<C-k>", "<C-w><C-k>", "Navigate windows up")
map("n", "<C-l>", "<C-w><C-l>", "Navigate windows to the right")
-- Move with shift-arrows
map("n", "<S-Left>", "<C-w><S-h>", "Move window to the left")
map("n", "<S-Down>", "<C-w><S-j>", "Move window down")
map("n", "<S-Up>", "<C-w><S-k>", "Move window up")
map("n", "<S-Right>", "<C-w><S-l>", "Move window to the right")
-- Resize with arrows
map("n", "<C-Up>", ":resize +2<CR>")
map("n", "<C-Down>", ":resize -2<CR>")
map("n", "<C-Left>", ":vertical resize +2<CR>")
map("n", "<C-Right>", ":vertical resize -2<CR>")
-- Deleting buffers
local buffers = require("helpers.buffers")
map("n", "<leader>db", buffers.delete_this, "Current buffer")
map("n", "<leader>do", buffers.delete_others, "Other buffers")
map("n", "<leader>da", buffers.delete_all, "All buffers")
-- Navigate buffers
map("n", "<S-l>", ":bnext<CR>")
map("n", "<S-h>", ":bprevious<CR>")
-- Stay in indent mode
map("v", "<", "<gv")
map("v", ">", ">gv")
-- Switch between light and dark modes
map("n", "<leader>ut", function()
if vim.o.background == "dark" then
vim.o.background = "light"
else
vim.o.background = "dark"
end
end, "Toggle between light and dark themes")
-- Clear after search
map("n", "<leader>ur", "<cmd>nohl<cr>", "Clear highlights")
-- Open config
map("n", "<leader>Nc", "<cmd>tabnew ~/.config/nvim/init.lua<cr>", "Open Config")
-- Open Weather
map("n", "<leader>w", "<cmd>lua require'wttr'.get_forecast()<cr>", "Open Weather")
-- Open Common Files
map("n", "<leader>fm", "<cmd>tabnew ~/vex/roberts<cr>", "Open Roberts")
map("n", "<leader>fp", "<cmd>tabnew ~/vex/patch<cr>", "Open Patch")
-- New Tab Terminal (for more perminent use)
map("n", "<leader>ft", "<cmd>tabf term://fish<cr>i", "Open New Terminal")
map("t", "<Esc><leader>", "<C-\\><C-n>", "Return to normal mode")
-- Lazygit config
local Terminal = require('toggleterm.terminal').Terminal
local lazygit = Terminal:new({cmd = "lazygit", hidden = true, direction='tab'})
function _lazygit_toggle()
lazygit:toggle()
end
map("n", "<leader>gg", "<cmd>lua _lazygit_toggle()<cr>", "open lazygit")
-- Bacon config
local bacon = Terminal:new({cmd = "bacon --job clippy", hidden = true, direction='tab'})
function _bacon_toggle()
bacon:toggle()
end
map("n", "<leader>h", "<cmd>lua _bacon_toggle()<cr>", "open bacon")
-- Wiki-tui config
local wiki = Terminal:new({cmd = "wiki-tui", hidden = true, direction='tab'})
function _wiki_toggle()
wiki:toggle()
end
map("n", "<leader>sl", "<cmd>lua _wiki_toggle()<cr>", "open wiki-tui")
map("n", "<leader>r", "<cmd>HackAuto<cr>", ":)")

View File

@ -1,30 +0,0 @@
-- Install lazy.nvim if not already installed
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
-- Use a protected call so we don't error out on first use
local ok, lazy = pcall(require, "lazy")
if not ok then
return
end
-- We have to set the leader key here for lazy.nvim to work
require("helpers.keys").set_leader(" ")
-- Load plugins from specifications
-- (The leader key must be set before this)
lazy.setup("plugins")
-- Might as well set up an easy-access keybinding
require("helpers.keys").map("n", "<leader>pL", lazy.show, "Show Lazy")

View File

@ -1,40 +0,0 @@
local opts = {
shiftwidth = 4,
tabstop = 4,
expandtab = true,
wrap = false,
termguicolors = true,
number = true,
relativenumber = true,
foldcolumn = '0',
foldlevel = 99,
foldlevelstart = 99,
foldenable = true,
}
-- Set options from table
for opt, val in pairs(opts) do
vim.o[opt] = val
end
-- Set other options
local colorscheme = require("helpers.colorscheme")
vim.cmd.colorscheme(colorscheme)
vim.notify = require("notify")
vim.api.nvim_set_hl(0, "String", { fg = "#9ece6a", underline = false, bold = false })
vim.api.nvim_set_hl(0, "Type", { fg = "#00ff00", underline = false, bold = false })
vim.api.nvim_set_hl(0, "Structure", { fg = "#00ff00", underline = false, bold = false })
vim.api.nvim_set_hl(0, "Constant", { fg = "#fab387", underline = false, bold = true })
vim.api.nvim_set_hl(0, "@lsp.type.selfKeyword.rust", {fg = "#b00202", bold = true, underline=false})
vim.api.nvim_set_hl(0, "@lsp.type.typeParamater.rust", {fg = "#ffbf00", bold = true, underline=false})
vim.api.nvim_set_hl(0, "Identifier", { fg = "#ffffff", underline = false, bold = false })
vim.api.nvim_set_hl(0, "Function", { fg = "#025fb0", underline = false, bold = false })
vim.api.nvim_set_hl(0, "@lsp.type.enumMember.rust", { fg = "#fab387", underline = false, bold = false })
vim.api.nvim_set_hl(0, "@lsp.type.interface", {fg = "#a402b0", bold = true, underline=false})
vim.api.nvim_set_hl(0, "Comment", {fg = "#989898", bold = false, underline=false})
vim.api.nvim_set_hl(0, "NvimTreeGitDirty", {fg = "#ffaa00", bold = false, underline=false})
vim.api.nvim_set_hl(0, "@string.escape", {fg = "#aa00ff", bold = false, underline=false})
vim.api.nvim_set_hl(0, "@type.builtin", {fg = "#00ff00", bold = false, underline=false})
vim.api.nvim_set_hl(0, "@lsp.mod.unsafe.rust", {bg = "#aa0000"})
-- vim.api.nvim_set_hl(0, "DiagnosticUnnecessary", {})

View File

@ -1,25 +0,0 @@
local M = {}
local function noop()
print("NOOP")
end
local ok, close_buffers = pcall(require, "close_buffers")
if ok then
M.delete_this = function()
close_buffers.delete({ type = "this" })
end
M.delete_all = function()
close_buffers.delete({ type = "all", force = true })
end
M.delete_others = function()
close_buffers.delete({ type = "other", force = true })
end
else
M.delete_this = function()
vim.cmd.bdelete()
end
M.delete_all = noop
M.delete_others = noop
end
return M

View File

@ -1,24 +0,0 @@
-- Fetch and setup colorscheme if available, otherwise just return 'default'
-- This should prevent Neovim from complaining about missing colorschemes on first boot
local function get_if_available(name, opts)
local lua_ok, colorscheme = pcall(require, name)
if lua_ok then
colorscheme.setup(opts)
return name
end
local vim_ok, _ = pcall(vim.cmd.colorscheme, name)
if vim_ok then
return name
end
return "default"
end
-- Uncomment the colorscheme to use
-- local colorscheme = get_if_available('gruvbox')
-- local colorscheme = get_if_available('rose-pine')
local colorscheme = get_if_available('catppuccin')
-- local colorscheme = get_if_available('melange')
return colorscheme

View File

@ -1,7 +0,0 @@
return {
'goolord/alpha-nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' },
config = function ()
require'alpha'.setup(require'alpha.themes.dashboard'.config)
end
}

16
lua/plugins/blink_cmp.lua Normal file
View File

@ -0,0 +1,16 @@
return {
-- "saghen/blink.cmp",
-- dependencies = { "codeium.nvim", "saghen/blink.compat" },
-- opts = {
-- sources = {
-- compat = { "codeium" },
-- providers = {
-- codeium = {
-- kind = "Codeium",
-- score_offset = 100,
-- async = true,
-- },
-- },
-- },
-- },
}

View File

@ -1,9 +0,0 @@
-- See current buffers at the top of the editor
return {
{
"akinsho/bufferline.nvim",
version = "v3.*",
dependencies = "nvim-tree/nvim-web-devicons",
opts = {},
},
}

View File

@ -1,119 +0,0 @@
-- Autocompletion
return {
{
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
"rafamadriz/friendly-snippets",
-- "zbirenbaum/copilot.lua",
-- "zbirenbaum/copilot-cmp",
},
config = function()
local cmp = require("cmp")
local luasnip = require("luasnip")
-- require("copilot").setup({
-- suggestion = { enabled = false },
-- panel = { enabled = false },
-- })
-- require("copilot-cmp")
require("luasnip/loaders/from_vscode").lazy_load()
local kind_icons = {
Text = "",
Method = "m",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = "",
-- Copilot = "",
}
-- local has_words_before = function()
-- if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then return false end
-- local line, col = unpack(vim.api.nvim_win_get_cursor(0))
-- return col ~= 0 and vim.api.nvim_buf_get_text(0, line-1, 0, line-1, col, {})[1]:match("^%s*$") == nil
-- end
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-k>"] = cmp.mapping.select_prev_item(),
["<C-j>"] = cmp.mapping.select_next_item(),
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = false,
}),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
}),
formatting = {
expandable_indicator = true,
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
-- Kind icons
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
vim_item.menu = ({
nvim_lsp = "[LSP]",
luasnip = "[Snippet]",
buffer = "[Buffer]",
path = "[Path]",
})[entry.source.name]
return vim_item
end,
},
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "path" },
},
})
end,
},
}

View File

@ -0,0 +1,15 @@
return {
{
"catppuccin/nvim",
name = "catppuccin",
},
{
"LazyVim/LazyVim",
opts = {
colorscheme = "catppuccin",
},
},
{
"HiPhish/rainbow-delimiters.nvim",
},
}

197
lua/plugins/example.lua Normal file
View File

@ -0,0 +1,197 @@
-- since this is just an example spec, don't actually load anything here and return an empty spec
-- stylua: ignore
if true then return {} end
-- every spec file under the "plugins" directory will be loaded automatically by lazy.nvim
--
-- In your plugin files, you can:
-- * add extra plugins
-- * disable/enabled LazyVim plugins
-- * override the configuration of LazyVim plugins
return {
-- add gruvbox
{ "ellisonleao/gruvbox.nvim" },
-- Configure LazyVim to load gruvbox
{
"LazyVim/LazyVim",
opts = {
colorscheme = "gruvbox",
},
},
-- change trouble config
{
"folke/trouble.nvim",
-- opts will be merged with the parent spec
opts = { use_diagnostic_signs = true },
},
-- disable trouble
{ "folke/trouble.nvim", enabled = false },
-- override nvim-cmp and add cmp-emoji
{
"hrsh7th/nvim-cmp",
dependencies = { "hrsh7th/cmp-emoji" },
---@param opts cmp.ConfigSchema
opts = function(_, opts)
table.insert(opts.sources, { name = "emoji" })
end,
},
-- change some telescope options and a keymap to browse plugin files
{
"nvim-telescope/telescope.nvim",
keys = {
-- add a keymap to browse plugin files
-- stylua: ignore
{
"<leader>fp",
function() require("telescope.builtin").find_files({ cwd = require("lazy.core.config").options.root }) end,
desc = "Find Plugin File",
},
},
-- change some options
opts = {
defaults = {
layout_strategy = "horizontal",
layout_config = { prompt_position = "top" },
sorting_strategy = "ascending",
winblend = 0,
},
},
},
-- add pyright to lspconfig
{
"neovim/nvim-lspconfig",
---@class PluginLspOpts
opts = {
---@type lspconfig.options
servers = {
-- pyright will be automatically installed with mason and loaded with lspconfig
pyright = {},
},
},
},
-- add tsserver and setup with typescript.nvim instead of lspconfig
{
"neovim/nvim-lspconfig",
dependencies = {
"jose-elias-alvarez/typescript.nvim",
init = function()
require("lazyvim.util").lsp.on_attach(function(_, buffer)
-- stylua: ignore
vim.keymap.set( "n", "<leader>co", "TypescriptOrganizeImports", { buffer = buffer, desc = "Organize Imports" })
vim.keymap.set("n", "<leader>cR", "TypescriptRenameFile", { desc = "Rename File", buffer = buffer })
end)
end,
},
---@class PluginLspOpts
opts = {
---@type lspconfig.options
servers = {
-- tsserver will be automatically installed with mason and loaded with lspconfig
tsserver = {},
},
-- you can do any additional lsp server setup here
-- return true if you don't want this server to be setup with lspconfig
---@type table<string, fun(server:string, opts:_.lspconfig.options):boolean?>
setup = {
-- example to setup with typescript.nvim
tsserver = function(_, opts)
require("typescript").setup({ server = opts })
return true
end,
-- Specify * to use this function as a fallback for any server
-- ["*"] = function(server, opts) end,
},
},
},
-- for typescript, LazyVim also includes extra specs to properly setup lspconfig,
-- treesitter, mason and typescript.nvim. So instead of the above, you can use:
{ import = "lazyvim.plugins.extras.lang.typescript" },
-- add more treesitter parsers
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = {
"bash",
"html",
"javascript",
"json",
"lua",
"markdown",
"markdown_inline",
"python",
"query",
"regex",
"tsx",
"typescript",
"vim",
"yaml",
},
},
},
-- since `vim.tbl_deep_extend`, can only merge tables and not lists, the code above
-- would overwrite `ensure_installed` with the new value.
-- If you'd rather extend the default config, use the code below instead:
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
-- add tsx and treesitter
vim.list_extend(opts.ensure_installed, {
"tsx",
"typescript",
})
end,
},
-- the opts function can also be used to change the default opts:
{
"nvim-lualine/lualine.nvim",
event = "VeryLazy",
opts = function(_, opts)
table.insert(opts.sections.lualine_x, {
function()
return "😄"
end,
})
end,
},
-- or you can return new options to override all the defaults
{
"nvim-lualine/lualine.nvim",
event = "VeryLazy",
opts = function()
return {
--[[add your custom lualine config here]]
}
end,
},
-- use mini.starter instead of alpha
{ import = "lazyvim.plugins.extras.ui.mini-starter" },
-- add jsonls and schemastore packages, and setup treesitter for json, json5 and jsonc
{ import = "lazyvim.plugins.extras.lang.json" },
-- add any tools you want to have installed below
{
"williamboman/mason.nvim",
opts = {
ensure_installed = {
"stylua",
"shellcheck",
"shfmt",
"flake8",
},
},
},
}

View File

@ -1,31 +0,0 @@
-- Git related plugins
return {
{
"lewis6991/gitsigns.nvim",
opts = {},
},
{
"akinsho/git-conflict.nvim",
commit = "2957f74",
config = function()
require("git-conflict").setup({
default_mappings = {
ours = "co",
theirs = "ct",
none = "c0",
both = "cb",
next = "cn",
prev = "cp",
},
})
end,
},
{
"tpope/vim-fugitive",
config = function ()
local map = require("helpers.keys").map
map("n", "<leader>ga", "<cmd>Git add %<cr>", "Stage the current file")
map("n", "<leader>gb", "<cmd>Git blame<cr>", "Show the blame")
end
}
}

View File

@ -1,499 +0,0 @@
return {
{
"letieu/hacker.nvim",
opts = {
content =
[[//! # Functionality for making drivetrains and includes some basic ones.
pub mod motors;
// pub mod no_block;
use core::{
f64::consts::{TAU, PI},
ops::{
RangeInclusive,
Add,
AddAssign,
Sub,
SubAssign,
Mul,
Div,
},
time::Duration,
};
use libm::{
sqrt,
pow,
};
use alloc::{
vec::Vec,
vec,
};
use crate::{prelude::*, println_blue};
use motors::MotorGroup;
pub struct Drive<T: MotorGroup, C: Config = DefaultConfig> {
pub left_motor: T,
pub right_motor: T,
pub config: C,
}
impl<T: MotorGroup, C: Config> DriveTrain for Drive<T, C> {
type Config = C;
type MotorError = T::MotorError;
fn move_i8(&mut self, l: i8, r: i8) -> Result<(), T::MotorError> {
self.left_motor.move_i8(l)?;
self.right_motor.move_i8(r)
}
fn move_voltage(&mut self, l: i32, r: i32) -> Result<(), T::MotorError> {
self.left_motor.move_voltage(l)?;
self.right_motor.move_voltage(r)
}
fn config(&self) -> &Self::Config {
&self.config
}
}
/// Represents the drivetrain of the robot
pub trait DriveTrain {
type Config: Config;
type MotorError;
///moves the sides of the drivetrain the specified voltadge
fn move_voltage(&mut self, left: i32, right: i32) -> Result<(), Self::MotorError>;
///moves the sides of the drivetrain the specified number
fn move_i8(&mut self, left: i8, right: i8) -> Result<(), Self::MotorError>;
fn config(&self) -> &Self::Config;
fn drive(&mut self, y: i8, x: i8) -> Result<(), Self::MotorError> {
let (left, right) = self.config().drive_math(y, x);
self.move_i8(left, right)?;
Ok(())
}
/// one frame of a pid loop, moves twards specified point
fn go_to(
&mut self,
heading: Angle,
init: Point,
to: Point,
pids: &mut PidPair,
) -> Result<(), Self::MotorError> {
let (frwdpidin, turnpidin) = Self::Config::go_to_pid_math(heading, init, to);
pids.0.add(frwdpidin);
pids.1.add(turnpidin);
let frwd = pids.0.get() as i32;
let turn = pids.1.get() as i32;
self.move_voltage(frwd - turn, frwd + turn)?;
Ok(())
}
/// blocks, drives the drivetrain forward to a point until the condition becomes false
fn go_to_while<F:FnMut()->bool>(
&mut self,
sensor:&Mutex<InertialSensor>,
position:&Mutex<Point>,
to:Point,
pids:&mut PidPair,
ctx:Context,
mut cond:F,
) -> Result<(), Self::MotorError> {
let mut l = Loop::new(Duration::from_millis(10));
while cond() {
self.go_to(
Angle::from_imu_read(sensor.lock().get_heading().warn_default()),
position.lock().clone(),
to.clone(),
pids
)?;
select! {
() = l.select() => continue,
() = ctx.done() => break,
}
}
self.move_voltage(0, 0);
Ok(())
}
/// one frame of a pid loop, turns twards the specified point
fn turn_to(
&mut self,
heading: Angle,
init: Point,
to: Point,
pid: &mut Pid,
reverse:bool
) -> Result<(), Self::MotorError> {
let delta_heading = match reverse {
false => init.angle_between(&to) - heading,
true => init.angle_between(&to) + Angle::from_rad(PI) - heading,
};
pid.add(delta_heading.as_rad_neg());
let mvolt = pid.get() as i32;
self.move_voltage(-mvolt, mvolt)
}
/// moves the sides of the drivetrain the specified voltadge, then waits for time
fn go_for(&mut self, left: i32, right: i32, time: Duration) -> Result<(), Self::MotorError> {
self.move_voltage(left, right)?;
Task::delay(time);
Ok(())
}
}
/// Represendts two pids controlling the forward (l, _), and turn (_, r) components of a drivetrain
pub type PidPair = (Pid, Pid);
/* /// Four wheeled holonomic drivetrain struct.
pub struct Holo<T:Motor>{
rightfronf:T,
leftfront:T,
rightback:T,
leftback:T,
}
/// WIP
pub trait Holonomic {
fn forward_math(&self, x:i8, y:i8, imu:Angle);
fn turn_math(&mut self, turn:i8);
} */
/// Anything with the ability to be configured as a driver profile.
pub trait Config {
///the math for how the drivetrain moves given stick input
fn drive_math(&self, y: i8, x: i8) -> (i8, i8);
/// the math for the values that the pids should be passed in when going to
/// point (frwd, turn).
fn go_to_pid_math(heading: Angle, init: Point, to: Point) -> (f64, f64) {
let change = to - init;
let relitive = change.rotate(-heading);
(relitive.x(), relitive.y())
}
}
pub struct DefaultConfig;
impl Config for DefaultConfig {
fn drive_math(&self, y: i8, x: i8) -> (i8, i8) {
//we want to truncate here
#[allow(clippy::cast_possible_truncation)]
let left = ((y as i16) + (x as i16)).clamp(-127, 127) as i8;
#[allow(clippy::cast_possible_truncation)]
let right = ((y as i16) - (x as i16)).clamp(-127, 127) as i8;
(left, right)
}
}
fn signum(n:f64)->f64{
if n<0.0{
-1.0
} else{
1.0
}
}
///Contains fuctionality for smooth acceleration to a destination
///
/// # examples
///
/// ```
/// #![no_std]
/// #![no_main]
///
/// struct MyRobot {
/// left_motor: Motor,
/// right_motor: Motor,
/// pid: Pid,
/// }
/// impl MyRobot {
/// ///moves the robot forward the specified number of ticks
/// fn move_dist(&mut self, distance: f64) -> Result<(), MotorError> {
/// self.left_motor.tare_position().unwrap();
/// self.right_motor.tare_position().unwrap();
/// self.pid.add(distance);
/// loop {
/// self.left_motor
/// .move_voltadge(self.pid.get_weight())
/// .unwrap();
/// self.right_motor
/// .move_voltadge(self.pid.get_weight())
/// .unwrap();
/// let err = dist - self.left_motor.get_position().unwrap();
/// self.pid.add(err);
/// if err == 0.0 {
/// break;
/// }
/// }
/// }
/// }
/// ```
#[derive(Debug, Clone)]
pub struct Pid {
kp: f64,
ki: f64,
kd: f64,
p: f64,
i: f64,
d: f64,
range: RangeInclusive<f64>,
max: Option<f64>,
}
impl Pid {
/// constructs new pid with the given weights, and the allowed range of the
/// internal values
pub const fn new(weights:PidWeights, range: RangeInclusive<f64>) -> Self {
Self {
kp: weights.kp,
ki: weights.ki,
kd: weights.kd,
p: 0.0,
i: 0.0,
d: 0.0,
range,
max: None,
}
}
pub fn add(&mut self, new: f64) {
self.d = self.p - new;
self.i += new;
self.p = new;
self.p = self.p.clamp(*self.range.start(), *self.range.end());
self.i = self.i.clamp(*self.range.start(), *self.range.end());
self.d = self.d.clamp(*self.range.start(), *self.range.end());
}
pub fn get(&self) -> f64 {
let max = self.max.unwrap_or(f64::INFINITY);
((self.p * self.kp) + (self.i * self.ki) + (self.d * self.kd)).clamp(-max, max)
}
pub const fn set_max(mut self, max: Option<f64>) -> Self {
self.max = max;
self
}
pub fn reset(&mut self) {
self.p = 0.0;
self.i = 0.0;
self.d = 0.0;
}
pub fn weights(&self) -> PidWeights {
PidWeights {
kp: self.kp,
ki: self.ki,
kd: self.kd,
}
}
pub fn set_weights(&mut self, weights:PidWeights) {
self.kp = weights.kp;
self.ki = weights.ki;
self.kd = weights.kd;
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct PidWeights {
pub kp: f64,
pub ki: f64,
pub kd: f64,
}
impl PidWeights {
fn positive(&self) ->Self{
Self{
kp: self.kp.max(0.0),
ki: self.ki.max(0.0),
kd: self.kd.max(0.0),
}
}
fn max(&self, rhs: &Self) ->Self{
Self{
kp: self.kp.max(-rhs.kp),
ki: self.ki.max(-rhs.ki),
kd: self.kd.max(-rhs.kd),
}
}
fn max_magnitude(&self, mag: f64) -> Self {
let self_mag = self.magnitude();
if self_mag > mag {
&(self*mag)/self_mag
} else {
self.clone()
}
}
fn magnitude(&self)->f64{
sqrt(pow(self.kp, 2.0) + pow(self.ki, 2.0) + pow(self.kd, 2.0))
}
/// # NOTE: self is three independent vectors, not one
fn gradient_acent(self, responce: (f64, f64, f64)) -> PidWeights {
PidWeights{
kp: responce.0/self.kp,
ki: responce.1/self.ki,
kd: responce.2/self.kd
}
}
}
impl Add for PidWeights {
type Output = Self;
fn add(self, rhs: Self) -> Self::Output {
Self {
kp: self.kp + rhs.kp,
ki: self.ki + rhs.ki,
kd: self.kd + rhs.kd
}
}
}
impl Sub for PidWeights {
type Output = Self;
fn sub(self, rhs: Self) -> Self::Output {
Self {
kp: self.kp - rhs.kp,
ki: self.ki - rhs.ki,
kd: self.kd - rhs.kd
}
}
}
impl Add for &PidWeights {
type Output = PidWeights;
fn add(self, rhs: Self) -> Self::Output {
PidWeights {
kp: self.kp + rhs.kp,
ki: self.ki + rhs.ki,
kd: self.kd + rhs.kd
}
}
}
impl Sub for &PidWeights {
type Output = PidWeights;
fn sub(self, rhs: Self) -> Self::Output {
PidWeights {
kp: self.kp - rhs.kp,
ki: self.ki - rhs.ki,
kd: self.kd - rhs.kd
}
}
}
impl Mul<f64> for &PidWeights {
type Output = PidWeights;
fn mul(self, rhs: f64) -> Self::Output {
PidWeights {
kp: self.kp * rhs,
ki: self.ki * rhs,
kd: self.kd * rhs
}
}
}
impl Div<f64> for &PidWeights {
type Output = PidWeights;
fn div(self, rhs: f64) -> Self::Output {
PidWeights {
kp: self.kp / rhs,
ki: self.ki / rhs,
kd: self.kd / rhs
}
}
}
impl AddAssign for PidWeights {
fn add_assign(&mut self, rhs: Self) {
*self = &*self + &rhs
}
}
impl SubAssign for PidWeights {
fn sub_assign(&mut self, rhs: Self) {
*self = &*self - &rhs
}
}
#[derive(Default, Clone, Debug)]
enum Weight {
All,
Kp,
Ki,
#[default]
Kd,
}
impl Weight {
fn next(&self) -> Self{
match self {
Self::All => Self::Kp,
Self::Kp => Self::Ki,
Self::Ki => Self::Kd,
Self::Kd => Self::All,
}
}
}
/// automagicaly tunes pids to maximize v
#[derive(Debug, Clone, Default)]
pub struct AutoTune<const N: usize>{
// keep track of all readings for human review
readings:Vec<(PidWeights, f64)>,
current:Vec<(PidWeights, f64)>,
/// the changes that was determened best (not indivudual values)
/// will only be none when algorithm hasnt run
last_target: Weight,
}
impl<const N: usize> AutoTune<N> {
pub fn new() -> Self{
assert_ne!(N, 0, "N must not be zero");
Self::default()
}
fn last_all(&self) -> &PidWeights {
let adjusted_len = self.readings.len() - self.last_target.clone() as usize - 1;
&self.readings[adjusted_len].0
}
fn last_change(&self) -> Option<PidWeights> {
// cycles 4 times in order [ kp, ki, kd, all ]
let adjusted_len = self.readings.len().checked_sub(self.last_target.clone() as usize)?.checked_sub(1)?;
Some(
&self.readings.get(adjusted_len)?.0
- &self.readings.get(adjusted_len.checked_sub(4)?)?.0
)
}
pub fn tune(&mut self, weight: PidWeights, dist: Distance, time: Duration, alpha: f64, max_magnitude: f64) -> PidWeights{
// GOAL: maximize velocity
let vel = dist/time.as_secs_f64(); // in cm/sec
if self.current.len() < N {
println!("averageing");
self.current.push((weight.clone(), vel));
return weight;
}
let ave = self.current.iter().fold((PidWeights {kp:0.0, ki:0.0, kd: 0.0}, 0.0), |acc, next| {
(&acc.0+&next.0, &acc.1+&next.1)
});
self.readings.push((&ave.0/N as f64, ave.1/N as f64));
self.current.clear();
self.last_target = self.last_target.next();
let last_change = self.last_change().unwrap_or_else(||(&weight * alpha).max_magnitude(max_magnitude));
let last_all = self.last_all().clone();
let out = match self.last_target {
Weight::All => {
PidWeights {
kp: last_all.kp + last_change.kp,
..last_all
}
},
Weight::Kp => {
PidWeights {
ki: last_all.ki + last_change.ki,
..last_all
}
},
Weight::Ki => {
PidWeights {
kd: last_all.kd + last_change.kd,
..last_all
}
},
Weight::Kd => {
let len = self.readings.len();
let last_vel = self.readings[len - 4].1;
let delta_reads = (self.readings[len - 3].1-last_vel, self.readings[len - 2].1-last_vel, self.readings[len - 1].1-last_vel);
let grad = (&last_change.clone().gradient_acent(delta_reads) * alpha).max_magnitude(max_magnitude);
println_blue!("grad={grad:?}\ndelta_reads={delta_reads:?}");
last_all + grad
}
};
println!("last_change={last_change:?}\nout={out:?}");
out
}
}]],
filetype = "rust",
}
}
}

View File

@ -1,13 +0,0 @@
return {
{
"ThePrimeagen/harpoon",
config = function ()
require("harpoon").setup({})
local map = require("helpers.keys").map
map("n", "<leader>ma", require("harpoon.mark").add_file, "New mark")
map("n", "<leader>ms", require("harpoon.ui").toggle_quick_menu, "List marks")
map("n", "<leader>mj", require("harpoon.ui").nav_next, "Next mark")
map("n", "<leader>mk", require("harpoon.ui").nav_prev, "Previous mark")
end,
},
}

View File

@ -1,185 +0,0 @@
-- LSP Configuration & Plugins
return {
{
"neovim/nvim-lspconfig",
dependencies = {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"j-hui/fidget.nvim",
"folke/neodev.nvim",
"RRethy/vim-illuminate",
"hrsh7th/cmp-nvim-lsp",
"kevinhwang91/nvim-ufo",
"kevinhwang91/promise-async",
-- "simrat39/rust-tools.nvim",
},
config = function()
-- Set up Mason before anything else
require("mason").setup()
require("mason-lspconfig").setup({
ensure_installed = {
"lua_ls",
"pylsp",
"rust_analyzer",
},
automatic_installation = true,
})
-- Quick access via keymap
require("helpers.keys").map("n", "<leader>M", "<cmd>Mason<cr>", "Show Mason")
-- Neodev setup before LSP config
require("neodev").setup()
-- Turn on LSP status information
require("fidget").setup({
progress = {
display = {
progress_icon = { "meter" }
}
}
})
-- Set up cool signs for diagnostics
local signs = { Error = "󰂭 ", Warn = "", Hint = "", Info = "" }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
end
-- Diagnostic config
local config = {
virtual_text = false,
signs = {
active = signs,
},
update_in_insert = true,
underline = true,
severity_sort = true,
float = {
focusable = true,
style = "minimal",
border = "rounded",
source = true,
header = "",
prefix = "",
},
}
vim.diagnostic.config(config)
-- This function gets run when an LSP connects to a particular buffer.
local on_attach = function(client, bufnr)
local lsp_map = require("helpers.keys").lsp_map
lsp_map("<leader>lr", vim.lsp.buf.rename, bufnr, "Rename symbol")
lsp_map("<leader>la", vim.lsp.buf.code_action, bufnr, "Code action")
lsp_map("<leader>ld", vim.lsp.buf.type_definition, bufnr, "Type definition")
lsp_map("<leader>ls", require("telescope.builtin").lsp_document_symbols, bufnr, "Document symbols")
lsp_map("gd", vim.lsp.buf.definition, bufnr, "Goto Definition")
lsp_map("gr", require("telescope.builtin").lsp_references, bufnr, "Goto References")
lsp_map("gI", vim.lsp.buf.implementation, bufnr, "Goto Implementation")
lsp_map("K", vim.lsp.buf.hover, bufnr, "Hover Documentation")
lsp_map("gD", vim.lsp.buf.declaration, bufnr, "Goto Declaration")
-- Create a command `:Format` local to the LSP buffer
vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_)
vim.lsp.buf.format()
end, { desc = "Format current buffer with LSP" })
lsp_map("<leader>ff", "<cmd>Format<cr>", bufnr, "Format")
-- Attach and configure vim-illuminate
require("illuminate").on_attach(client)
end
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
capabilities.textDocument.foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true,
}
-- Lua
require("lspconfig")["lua_ls"].setup({
on_attach = on_attach,
capabilities = capabilities,
settings = {
Lua = {
completion = {
callSnippet = "Replace",
},
diagnostics = {
globals = { "vim" },
},
workspace = {
library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
[vim.fn.stdpath("config") .. "/lua"] = true,
},
},
},
},
})
-- Python
require("lspconfig")["pylsp"].setup({
on_attach = on_attach,
capabilities = capabilities,
settings = {
pylsp = {
plugins = {
flake8 = {
enabled = true,
maxLineLength = 88, -- Black's line length
},
-- Disable plugins overlapping with flake8
pycodestyle = {
enabled = false,
},
mccabe = {
enabled = false,
},
pyflakes = {
enabled = false,
},
-- Use Black as the formatter
autopep8 = {
enabled = false,
},
},
},
},
})
-- Rust
require("lspconfig")["rust_analyzer"].setup({
on_attach = on_attach,
capabilities = capabilities,
settings = {
hover = {
show = {
structFields = 8,
traitAssocItems = 8,
}
}
}
})
require('ufo').setup({})
-- local rt = require("rust-tools")
-- rt.setup({
-- server = {
-- on_attach= function(_, bufnr)
-- vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, {buffer = bufnr})
-- vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, {buffer = bufnr})
-- end,
-- },
-- tools = {
-- inlay_hints = {
-- auto = false,
-- },
-- }
-- })
end,
},
}

View File

@ -1,19 +0,0 @@
-- Fancier statusline
return {
"nvim-lualine/lualine.nvim",
config = function()
local colorscheme = require("helpers.colorscheme")
local lualine_theme = colorscheme == "default" and "auto" or colorscheme
require("lualine").setup({
options = {
icons_enabled = true,
theme = lualine_theme,
component_separators = "|",
section_separators = "",
},
sections = {
lualine_x = { "require'wttr'.text", "encoding", "fileformat", "filetype" }
}
})
end,
}

View File

@ -1,72 +1,31 @@
-- Miscelaneous fun stuff
return {
-- Comment with haste
{
"numToStr/Comment.nvim",
opts = {},
},
-- Move stuff with <M-j> and <M-k> in both normal and visual mode
{
"echasnovski/mini.move",
config = function()
require("mini.move").setup()
end,
},
-- Better buffer closing actions. Available via the buffers helper.
{
"kazhala/close-buffers.nvim",
opts = {
preserve_window_layout = { "this", "nameless" },
},
},
"tpope/vim-sleuth", -- Detect tabstop and shiftwidth automatically
"tpope/vim-surround", -- Surround stuff with the ys-, cs-, ds- commands
"HiPhish/rainbow-delimiters.nvim",
{
"windwp/nvim-autopairs",
event = "InsertEnter",
opts = {},
},
{
"tamton-aquib/duck.nvim",
config = function ()
local duck = require("duck")
duck.hatch("🦀", 10)
vim.keymap.set('n', '<leader>dn', function () duck.hatch("🦀", 10) end, {})
vim.keymap.set('n', '<leader>dk', function () duck.cook() end, {})
end
},
{
"lukas-reineke/indent-blankline.nvim",
main = "ibl",
opts = {}
},
"rcarriga/nvim-notify",
{
"lazymaniac/wttr.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"MunifTnjim/nui.nvim",
},
opts = {
location = "las+vegas",
format = 2,
}
},
-- {
-- "felipec/vim-sanegx",
-- event = "BufRead",
-- },
{
'glacambre/firenvim',
-- Lazy load firenvim
-- Explanation: https://github.com/folke/lazy.nvim/discussions/463#discussioncomment-4819297
lazy = not vim.g.started_by_firenvim,
build = function()
vim.fn["firenvim#install"](0)
end
}
"tpope/vim-surround", -- Surround stuff with the ys-, cs-, ds- commands
{
"MeanderingProgrammer/render-markdown.nvim",
dependencies = { "nvim-treesitter/nvim-treesitter", "echasnovski/mini.icons" }, -- if you use standalone mini plugins
---@module 'render-markdown'
---@type render.md.UserConfig
opts = {},
},
{
"tamton-aquib/duck.nvim",
config = function()
local duck = require("duck")
duck.hatch("🦀", 10)
duck.hatch("🦀", 10)
vim.keymap.set("n", "<leader>dn", function()
duck.hatch("🦀", 10)
end, {})
vim.keymap.set("n", "<leader>dk", function()
duck.cook()
end, {})
end,
},
{
"m4xshen/hardtime.nvim",
lazy = false,
dependencies = { "MunifTanjim/nui.nvim" },
opts = {},
},
}

View File

@ -1,36 +0,0 @@
-- Nicer filetree than NetRW
return {
{
"nvim-neo-tree/neo-tree.nvim",
branch = "v2.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons",
"MunifTanjim/nui.nvim",
},
config = function()
require("neo-tree").setup({
default_component_configs = { git_status = { symbols = {
unstaged = "󰄱",
}}},
close_if_last_window=true,
filesystem = {
filtered_items = {
visible = true
},
follow_current_file = { enable=true },
use_libuv_file_watcher=true,
},
window = {
width = 34,
}
})
require("helpers.keys").map(
{ "n", "v" },
"<leader>e",
"<cmd>NeoTreeRevealToggle<cr>",
"Toggle file explorer"
)
end,
},
}

8
lua/plugins/neo_tree.lua Normal file
View File

@ -0,0 +1,8 @@
return {
{
"nvim-neo-tree/neo-tree.nvim",
opts = {
close_if_last_window = true,
},
},
}

View File

@ -1,19 +0,0 @@
return {
{
"jose-elias-alvarez/null-ls.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
},
config = function()
local null_ls = require("null-ls")
null_ls.setup({
sources = {
null_ls.builtins.formatting.stylua,
null_ls.builtins.formatting.clang_format,
null_ls.builtins.formatting.black,
null_ls.builtins.formatting.isort,
},
})
end,
},
}

View File

@ -1,49 +0,0 @@
-- Telescope fuzzy finding (all the things)
return {
{
"nvim-telescope/telescope.nvim",
branch = "0.1.x",
dependencies = {
"nvim-lua/plenary.nvim",
-- Fuzzy Finder Algorithm which requires local dependencies to be built. Only load if `make` is available
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make", cond = vim.fn.executable("make") == 1 },
},
config = function()
require("telescope").setup({
defaults = {
mappings = {
i = {
["<C-u>"] = false,
["<C-d>"] = false,
},
},
},
})
-- Enable telescope fzf native, if installed
pcall(require("telescope").load_extension, "fzf")
local map = require("helpers.keys").map
map("n", "<leader>fr", require("telescope.builtin").oldfiles, "Recently opened")
map("n", "<leader><space>", require("telescope.builtin").buffers, "Open buffers")
map("n", "<leader>/", function()
-- You can pass additional configuration to telescope to change theme, layout, etc.
require("telescope.builtin").current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({
winblend = 10,
previewer = false,
}))
end, "Search in current buffer")
map("n", "<leader>sf", require("telescope.builtin").find_files, "Files")
map("n", "<leader>sh", require("telescope.builtin").help_tags, "Help")
map("n", "<leader>sw", require("telescope.builtin").grep_string, "Current word")
map("n", "<leader>sg", require("telescope.builtin").live_grep, "Grep")
map("n", "<leader>sd", require("telescope.builtin").diagnostics, "Diagnostics")
map("n", "<leader>sC", require("telescope.builtin").colorscheme, "Colorscheme")
map("n", "<leader>sk", require("telescope.builtin").keymaps, "Keymaps")
map("n", "<leader>sH", require("telescope.builtin").highlights, "Highlight groups")
map("n", "<C-p>", require("telescope.builtin").keymaps, "Search keymaps")
end,
},
}

View File

@ -1,20 +0,0 @@
-- Themes
return {
"typicode/bg.nvim",
"ellisonleao/gruvbox.nvim",
{
"catppuccin/nvim",
name = "catppuccin",
},
{
"rose-pine/nvim",
name = "rose-pine",
},
"sainnhe/everforest",
"savq/melange-nvim"
}

View File

@ -1,12 +1,12 @@
return {
{
'akinsho/toggleterm.nvim',
version = "*",
config = {
direction = 'float',
shell = 'fish',
float_opts = { border = 'curved' },
open_mapping = [[<c-\>]],
}
}
{
"akinsho/toggleterm.nvim",
version = "*",
config = {
direction = "float",
shell = "fish",
float_opts = { border = "curved" },
open_mapping = [[<c-\>]],
},
},
}

View File

@ -1,66 +0,0 @@
-- Highlight, edit, and navigate code
return {
{
"nvim-treesitter/nvim-treesitter",
build = function()
pcall(require("nvim-treesitter.install").update({ with_sync = true }))
end,
dependencies = {
"nvim-treesitter/nvim-treesitter-textobjects",
},
config = function()
require("nvim-treesitter.configs").setup({
-- Add languages to be installed here that you want installed for treesitter
ensure_installed = { "c", "cpp", "go", "lua", "python", "rust", "vim", "make" },
highlight = { enable = true },
indent = { enable = true, disable = { "python" } },
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<c-space>",
node_incremental = "<c-space>",
scope_incremental = "<c-s>",
node_decremental = "<c-backspace>",
},
},
textobjects = {
select = {
enable = true,
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
keymaps = {
-- You can use the capture groups defined in textobjects.scm
["aa"] = "@parameter.outer",
["ia"] = "@parameter.inner",
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
},
},
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
["]m"] = "@function.outer",
["]]"] = "@class.outer",
},
goto_next_end = {
["]M"] = "@function.outer",
["]["] = "@class.outer",
},
goto_previous_start = {
["[m"] = "@function.outer",
["[["] = "@class.outer",
},
goto_previous_end = {
["[M"] = "@function.outer",
["[]"] = "@class.outer",
},
},
},
})
end,
},
}

View File

@ -1,26 +0,0 @@
return {
{
"folke/which-key.nvim",
config = function()
local wk = require("which-key")
wk.setup()
wk.register(
{
["<leader>"] = {
f = { name = "File" },
d = { name = "Delete/Close" },
q = { name = "Quit" },
s = { name = "Search" },
l = { name = "LSP" },
u = { name = "UI" },
b = { name = "Debugging" },
g = { name = "Git" },
N = { name = "Neovim" },
p = { name = "Plugins" },
m = { name = "Harpoon" },
}
}
)
end
}
}

3
stylua.toml Normal file
View File

@ -0,0 +1,3 @@
indent_type = "Spaces"
indent_width = 4
column_width = 120

0
test
View File