From 5ef2d0fcc4addd28c78bda6c4ebef7fe975c9aba Mon Sep 17 00:00:00 2001 From: PandeCode Date: Thu, 14 Dec 2023 12:47:01 -0500 Subject: [PATCH 01/11] Rust --- .gitignore | 4 +++- init.lua | 2 ++ lazy-lock.json | 14 +++++++------- lua/rust.lua | 5 +++++ rust/.cargo/config | 14 ++++++++++++++ rust/Cargo.toml | 10 ++++++++++ rust/build.sh | 4 ++++ rust/src/lib.rs | 19 +++++++++++++++++++ 8 files changed, 64 insertions(+), 8 deletions(-) create mode 100644 lua/rust.lua create mode 100644 rust/.cargo/config create mode 100644 rust/Cargo.toml create mode 100755 rust/build.sh create mode 100644 rust/src/lib.rs diff --git a/.gitignore b/.gitignore index 6ddd58e..f091df4 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ test tags tags.lock tags.temp -lazy-lock.jsonlazy-lock.json +lazy-lock.json +rust/Cargo.lock +rust/lua/* diff --git a/init.lua b/init.lua index b339921..57488d7 100644 --- a/init.lua +++ b/init.lua @@ -5,3 +5,5 @@ Prequire("config") Prequire("plugins") Prequire("etc") + +require("rust") diff --git a/lazy-lock.json b/lazy-lock.json index dad5040..fc37894 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,20 +1,20 @@ { "LuaSnip": { "branch": "master", "commit": "500981ff6cefc7343e3959ef0f939bd0bfd49ba9" }, - "SchemaStore.nvim": { "branch": "main", "commit": "6316dc88db89d97d190f24547adddd13569fb746" }, - "bufferline.nvim": { "branch": "main", "commit": "9e8d2f695dd50ab6821a6a53a840c32d2067a78a" }, + "SchemaStore.nvim": { "branch": "main", "commit": "177cae4f44ddf7c166ef263956378ae308ff77ff" }, + "bufferline.nvim": { "branch": "main", "commit": "e48ce1805697e4bb97bc171c081e849a65859244" }, "cellular-automaton.nvim": { "branch": "main", "commit": "b7d056dab963b5d3f2c560d92937cb51db61cb5b" }, "clangd_extensions.nvim": { "branch": "main", "commit": "34c8eaa12be192e83cd4865ce2375e9f53e728f2" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, "cmp-nvim-tags": { "branch": "main", "commit": "30bdc2eec86eb66730af541bb06d24d4a67e3eeb" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "dashboard-nvim": { "branch": "master", "commit": "63df28409d940f9cac0a925df09d3dc369db9841" }, - "dressing.nvim": { "branch": "master", "commit": "fe3071330a0720ce3695ac915820c8134b22d1b0" }, + "dressing.nvim": { "branch": "master", "commit": "8b7ae53d7f04f33be3439a441db8071c96092d19" }, "fidget.nvim": { "branch": "legacy", "commit": "2f7c08f45639a64a5c0abcf67321d52c3f499ae6" }, "flutter-tools.nvim": { "branch": "main", "commit": "7350750d46fbeb4d2bb4878157b658d435935299" }, - "go.nvim": { "branch": "master", "commit": "da48e6155d69a5602ae3b494ecbda9cda438c0a9" }, - "guihua.lua": { "branch": "master", "commit": "cd68996069abedffcd677ca7eee3a660b79e5b32" }, + "go.nvim": { "branch": "master", "commit": "7b7c20029a817ef51f6b498388488e9850fe45ac" }, + "guihua.lua": { "branch": "master", "commit": "9fb6795474918b492d9ab01b1ebaf85e8bf6fe0b" }, "impatient.nvim": { "branch": "main", "commit": "47302af74be7b79f002773011f0d8e85679a7618" }, - "indent-blankline.nvim": { "branch": "master", "commit": "29be0919b91fb59eca9e90690d76014233392bef" }, + "indent-blankline.nvim": { "branch": "master", "commit": "7206c77cb931f79885fc47f88ae18f99148392eb" }, diff --git a/lua/rust.lua b/lua/rust.lua new file mode 100644 index 0000000..70609ce --- /dev/null +++ b/lua/rust.lua @@ -0,0 +1,5 @@ +vim.cmd [[ set rtp+=~/.config/nvim/rust ]] + +local librust = require("librust") + +print( librust.add(1,2) ) diff --git a/rust/.cargo/config b/rust/.cargo/config new file mode 100644 index 0000000..2abfb9c --- /dev/null +++ b/rust/.cargo/config @@ -0,0 +1,14 @@ +[target.x86_64-apple-darwin] +rustflags = [ + "-C", "link-arg=-undefined", + "-C", "link-arg=dynamic_lookup", +] + +[target.aarch64-apple-darwin] +rustflags = [ + "-C", "link-arg=-undefined", + "-C", "link-arg=dynamic_lookup", +] + +[build] +target-dir = "lua" diff --git a/rust/Cargo.toml b/rust/Cargo.toml new file mode 100644 index 0000000..d77f9e8 --- /dev/null +++ b/rust/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "rust" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib"] + +[dependencies] +nvim-oxi = { version="0.4.0", features = ["neovim-0-9"]} diff --git a/rust/build.sh b/rust/build.sh new file mode 100755 index 0000000..0437593 --- /dev/null +++ b/rust/build.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +cargo build && +cp -r lua/debug/librust.so lua/ diff --git a/rust/src/lib.rs b/rust/src/lib.rs new file mode 100644 index 0000000..dbdc57f --- /dev/null +++ b/rust/src/lib.rs @@ -0,0 +1,19 @@ +use std::convert::Infallible; + +use nvim_oxi::{self as oxi, Dictionary, Function, Object}; + +#[oxi::module] +fn librust() -> oxi::Result { + let add = Function::from_fn(|(a, b): (i32, i32)| Ok::<_, Infallible>(a + b)); + + let multiply = Function::from_fn(|(a, b): (i32, i32)| Ok::<_, Infallible>(a * b)); + + let compute = + Function::from_fn(|(fun, a, b): (Function<(i32, i32), i32>, i32, i32)| fun.call((a, b))); + + Ok(Dictionary::from_iter([ + ("add", Object::from(add)), + ("multiply", Object::from(multiply)), + ("compute", Object::from(compute)), + ])) +} From 28e02f9cab4c671e15e3c801d12d494192765813 Mon Sep 17 00:00:00 2001 From: PandeCode Date: Thu, 14 Dec 2023 15:21:20 -0500 Subject: [PATCH 02/11] More bindings added --- lua/config/bindings.lua | 130 +++++++----------------------------- lua/rust.lua | 2 - lua/utils.lua | 1 + rust/build.sh | 4 +- rust/src/keymaps.rs | 141 ++++++++++++++++++++++++++++++++++++++++ rust/src/lib.rs | 15 +++-- 6 files changed, 178 insertions(+), 115 deletions(-) create mode 100644 rust/src/keymaps.rs diff --git a/lua/config/bindings.lua b/lua/config/bindings.lua index ac91f92..f15f401 100644 --- a/lua/config/bindings.lua +++ b/lua/config/bindings.lua @@ -1,115 +1,35 @@ vim.g.mapleader = " " + -- stylua: ignore start local keymaps = { { Keys.N, "sf", vim.cmd.write }, - - { Keys.V, "so", ":sort" }, - { Keys.N, "qa", ":noautocmd qall!" }, - { Keys.N, "me", vim.cmd.messages }, { Keys.N, "fe", vim.cmd.edit }, - - { Keys.N, "x+", function() - local filename = vim.fn.expand("%") - vim.fn.jobstart({ "chmod", "+x", filename }) - require("notify")("Given execution rights to '" .. filename .. "'", "info", { title = IDE.name }) - end }, - - { Keys.N, "x-", function() - local filename = vim.fn.expand("%") - vim.fn.jobstart({ "chmod", "-x", filename }) - require("notify")("Taken away execution rights from '" .. filename .. "'", "info", { title = IDE.name }) - end }, -- Buffer - { Keys.N, "bp", vim.cmd.bp }, - { Keys.N, "bn", vim.cmd.bn }, - { Keys.N, "bd", vim.cmd.bd }, - { Keys.N, "", vim.cmd.bd, Keys.Noremap }, - { Keys.N, "nw", "%s/\\s*$//" }, - { Keys.N, "`", "edit #" }, - { Keys.N, "p", "\"_dP" }, - { Keys.N, "gf", ":e " }, - { Keys.N, "", "*:%s//" }, - { Keys.A, "", "", Keys.Noremap }, -- increament - { Keys.A, "", "", Keys.Noremap }, -- decreament - - { Keys.N, "L", "$" }, - { Keys.N, "H", "^" }, - { Keys.N, "Q", "" }, -- Disable visual mode - - { Keys.N, "", "(col('.') == matchend(getline('.'), '^\\s*')+1 ? '0' : '^')", Keys.NoremapExpr }, - { Keys.N, "", "(col('.') == match(getline('.'), '\\s*$') ? '$' : 'g_')", Keys.NoremapExpr }, - { Keys.V, "", "(col('.') == match(getline('.'), '\\s*$') ? '$h' : 'g_')", Keys.NoremapExpr }, - { Keys.I, "", "" }, - { Keys.I, " ", "" }, - { Keys.N, "gg", "gg0", Keys.Noremap }, - { Keys.A, "G", "G", Keys.Noremap }, - { Keys.A, "Y", "y$", Keys.Noremap }, - { Keys.N, "w", "", Keys.Noremap }, - { Keys.N, "w|", "vsplit", Keys.Noremap }, - { Keys.N, "w_", "split", Keys.Noremap }, - - -- system clipboard - { Keys.N, "", "\"+y\"", Keys.Noremap }, - { Keys.V, "", "\"+y\"", Keys.Noremap }, - { Keys.N, "", "\"+p\"", Keys.Noremap }, - { Keys.I, "", "+", Keys.Noremap }, - { Keys.C, "", "+", Keys.Noremap }, - { Keys.N, "", "d" }, - { Keys.I, "", "d" }, - { Keys.C, "", "d" }, - - -- use to insert original character without triggering things like auto-pairs - { Keys.I, "", "", Keys.Noremap }, - { Keys.N, "fs", ":w", Keys.Noremap }, - { Keys.N, "", "", Keys.Noremap }, - { Keys.I, "", "", Keys.Noremap }, - { Keys.N, Keys.N, "nzzzv", Keys.Noremap }, - { Keys.N, "N", "Nzzzv", Keys.Noremap }, - { Keys.N, "J", "mzJ`z", Keys.Noremap }, - { Keys.I, ",", ",u", Keys.Noremap }, - { Keys.I, ".", ".u", Keys.Noremap }, - { Keys.I, "!", "!u", Keys.Noremap }, - { Keys.I, "?", "?u", Keys.Noremap }, - { Keys.I, "[", "[u", Keys.Noremap }, - { Keys.I, "]", "]u", Keys.Noremap }, - { Keys.I, "(", "(u", Keys.Noremap }, - { Keys.I, ")", ")u", Keys.Noremap }, - { Keys.I, "{", "{u", Keys.Noremap }, - { Keys.I, "}", "}u", Keys.Noremap }, - { Keys.I, "\"", "\"u", Keys.Noremap }, - { Keys.N, "k", "(v:count > 5 ? \"m'\" . v:count : \"\") . 'k'", Keys.NoremapExpr }, - { Keys.N, "j", "(v:count > 5 ? \"m'\" . v:count : \"\") . 'j'", Keys.NoremapExpr }, - { Keys.V, "", ":m '>+1gv=gv", Keys.Noremap }, - { Keys.V, "", ":m '<-2gv=gv", Keys.Noremap }, - { Keys.N, "", ":m .+1==", Keys.Noremap }, - { Keys.I, "", ":m .-2==i", Keys.Noremap }, - { Keys.N, "", ":m .-1==", Keys.Noremap }, - { Keys.I, "", ":m .+1==i", Keys.Noremap }, - - -- Add space bellow or above without leaving normal mode - { Keys.N, "[", ":put!=repeat([''],v:count)']+1", Keys.NoremapSilent }, - { Keys.N, "]", ":put =repeat([''],v:count)'[-1", Keys.NoremapSilent }, - - -- Use simple ; instead of shift + : - -- {Keys.N, ";", ":", Keys.Noremap}, - -- {Keys.V, ";", ":", Keys.Noremap}, - - -- Better tabbing - { Keys.N, "<", "v", Keys.Noremap }, - { Keys.N, ">", "v>gv", Keys.Noremap }, - { Keys.V, "<", "", ">gv", Keys.Noremap }, - { Keys.V, "`", "`>a``", Keys.Noremap }, - { Keys.V, "(", "`>a)`", Keys.Noremap }, - { Keys.V, "'", "`>a'`", Keys.Noremap }, - { Keys.V, "", "`>a}`", Keys.Noremap }, - { Keys.V, ")", "`>a)`", Keys.Noremap }, - { Keys.V, "]", "`>a]`", Keys.Noremap }, - { Keys.V, "", "`>a}`", Keys.Noremap }, - { Keys.N, "ne", ":set noexpandtab!", Keys.Noremap }, - { Keys.N, "et", ":set expandtab!", Keys.Noremap }, - + { Keys.N, "bp", vim.cmd.bp }, + { Keys.N, "bn", vim.cmd.bn }, + { Keys.N, "bd", vim.cmd.bd }, + { Keys.N, "", vim.cmd.bd, Keys.Noremap }, + + { + Keys.N, + "x+", + function() + local filename = vim.fn.expand("%") + vim.fn.jobstart({ "chmod", "+x", filename }) + require("notify")("Given execution rights to '" .. filename .. "'", "info", { title = IDE.name }) + end, + }, + + { + Keys.N, + "x-", + function() + local filename = vim.fn.expand("%") + vim.fn.jobstart({ "chmod", "-x", filename }) + require("notify")("Taken away execution rights from '" .. filename .. "'", "info", { title = IDE.name }) + end, + }, } for _, value in pairs(keymaps) do diff --git a/lua/rust.lua b/lua/rust.lua index 70609ce..f7908a3 100644 --- a/lua/rust.lua +++ b/lua/rust.lua @@ -1,5 +1,3 @@ vim.cmd [[ set rtp+=~/.config/nvim/rust ]] local librust = require("librust") - -print( librust.add(1,2) ) diff --git a/lua/utils.lua b/lua/utils.lua index df130d3..9382667 100644 --- a/lua/utils.lua +++ b/lua/utils.lua @@ -129,6 +129,7 @@ Keys = { expr = true, }, } + ---A helper function to print a table's contents. ---@param tbl table @The table to print. ---@param depth number @The depth of sub-tables to traverse through and print. diff --git a/rust/build.sh b/rust/build.sh index 0437593..92c719d 100755 --- a/rust/build.sh +++ b/rust/build.sh @@ -1,4 +1,4 @@ #!/bin/sh -cargo build && -cp -r lua/debug/librust.so lua/ +cargo build --release&& +cp -r lua/release/librust.so lua/ diff --git a/rust/src/keymaps.rs b/rust/src/keymaps.rs new file mode 100644 index 0000000..6b6286a --- /dev/null +++ b/rust/src/keymaps.rs @@ -0,0 +1,141 @@ +use nvim_oxi::api::{self, types::Mode}; +use nvim_oxi::{self as oxi}; +use oxi::api::opts::SetKeymapOpts; +use oxi::Result; + +pub fn keymaps() -> Result<()> { + api::set_var("mapleader", " ")?; + + let n = &Mode::Normal; + let v = &Mode::Visual; + let a = &Mode::NormalVisualOperator; + let i = &Mode::Insert; + let c = &Mode::CmdLine; + + let none = &SetKeymapOpts::default(); + + let noremap = &(SetKeymapOpts::builder().noremap(true).build()); + let noremap_expr = &(SetKeymapOpts::builder().noremap(true).expr(true).build()); + let noremap_silent = &(SetKeymapOpts::builder().noremap(true).silent(true).build()); + + let keymaps = [ + (v, "so", ":sort", none), + (n, "qa", ":noautocmd qall!", none), + (n, "sf", ":w", none), + (n, "fe", ":edit", none), + (n, "nw", "%s/\\s*$//", none), + (n, "`", "edit #", none), + (n, "p", "\"_dP", none), + (n, "gf", ":e ", none), + (n, "", "*:%s//", none), + (a, "", "", noremap), // increament + (a, "", "", noremap), // decreament + (n, "L", "$", none), + (n, "H", "^", none), + (n, "Q", "", none), // Disable visual mode + ( + n, + "", + "(col('.') == matchend(getline('.'), '^\\s*')+1 ? '0' : '^')", + noremap_expr, + ), + ( + n, + "", + "(col('.') == match(getline('.'), '\\s*$') ? '$' : 'g_')", + noremap_expr, + ), + ( + v, + "", + "(col('.') == match(getline('.'), '\\s*$') ? '$h' : 'g_')", + noremap_expr, + ), + (i, "", "", none), + (i, " ", "", none), + (n, "gg", "gg0", noremap), + (a, "G", "G", noremap), + (a, "Y", "y$", noremap), + (n, "w", "", noremap), + (n, "w|", "vsplit", noremap), + (n, "w_", "split", noremap), + // system clipboard + (n, "", "\"+y\"", noremap), + (v, "", "\"+y\"", noremap), + (n, "", "\"+p\"", noremap), + (i, "", "+", noremap), + (c, "", "+", noremap), + (n, "", "d", none), + (i, "", "d", none), + (c, "", "d", none), + // use to insert original character without triggering things like auto-pairs + (i, "", "", noremap), + (n, "fs", ":w", noremap), + (n, "", "", noremap), + (i, "", "", noremap), + (n, "n", "nzzzv", noremap), + (n, "N", "Nzzzv", noremap), + (n, "J", "mzJ`z", noremap), + (i, ",", ",u", noremap), + (i, ".", ".u", noremap), + (i, "!", "!u", noremap), + (i, "?", "?u", noremap), + (i, "[", "[u", noremap), + (i, "]", "]u", noremap), + (i, "(", "(u", noremap), + (i, ")", ")u", noremap), + (i, "{", "{u", noremap), + (i, "}", "}u", noremap), + (i, "\"", "\"u", noremap), + ( + n, + "k", + "(v:count > 5 ? \"m'\" . v:count : \"\") . 'k'", + noremap_expr, + ), + ( + n, + "j", + "(v:count > 5 ? \"m'\" . v:count : \"\") . 'j'", + noremap_expr, + ), + (v, "", ":m '>+1gv=gv", noremap), + (v, "", ":m '<-2gv=gv", noremap), + (n, "", ":m .+1==", noremap), + (i, "", ":m .-2==i", noremap), + (n, "", ":m .-1==", noremap), + (i, "", ":m .+1==i", noremap), + // Add space bellow or above without leaving normal mode + ( + n, + "[", + ":put!=repeat([''],v:count)']+1", + noremap_silent, + ), + ( + n, + "]", + ":put =repeat([''],v:count)'[-1", + noremap_silent, + ), + (n, "<", "v", noremap), + (n, ">", "v>gv", noremap), + (v, "<", "", ">gv", noremap), + (v, "`", "`>a``", noremap), + (v, "(", "`>a)`", noremap), + (v, "'", "`>a'`", noremap), + (v, "", "`>a}`", noremap), + (v, ")", "`>a)`", noremap), + (v, "]", "`>a]`", noremap), + (v, "", "`>a}`", noremap), + (n, "ne", ":set noexpandtab!", noremap), + (n, "et", ":set expandtab!", noremap), + ]; + + for keymap in keymaps { + api::set_keymap(*keymap.0, keymap.1, keymap.2, keymap.3)?; + } + + Ok(()) +} diff --git a/rust/src/lib.rs b/rust/src/lib.rs index dbdc57f..6bbfe81 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1,15 +1,17 @@ -use std::convert::Infallible; +mod keymaps; use nvim_oxi::{self as oxi, Dictionary, Function, Object}; +use oxi::Result; +use std::convert::Infallible; + #[oxi::module] -fn librust() -> oxi::Result { - let add = Function::from_fn(|(a, b): (i32, i32)| Ok::<_, Infallible>(a + b)); +fn librust() -> Result { + keymaps::keymaps()?; + let add = Function::from_fn(|(a, b): (i32, i32)| Ok::<_, Infallible>(a + b)); let multiply = Function::from_fn(|(a, b): (i32, i32)| Ok::<_, Infallible>(a * b)); - - let compute = - Function::from_fn(|(fun, a, b): (Function<(i32, i32), i32>, i32, i32)| fun.call((a, b))); + let compute = Function::from_fn(|(fun, a, b): (Function<(i32, i32), i32>, i32, i32)| fun.call((a, b))); Ok(Dictionary::from_iter([ ("add", Object::from(add)), @@ -17,3 +19,4 @@ fn librust() -> oxi::Result { ("compute", Object::from(compute)), ])) } + From 4deab182eb7a2b220229c6732e2674648721eae1 Mon Sep 17 00:00:00 2001 From: PandeCode Date: Tue, 19 Dec 2023 23:38:43 -0500 Subject: [PATCH 03/11] rs | vscode --- lazy-lock.json | 8 ++-- lua/config/init.lua | 9 +++- lua/config/neovide.lua | 34 +++++++-------- lua/config/vscode.lua | 11 +++++ lua/plugins/init.lua | 75 ++++++++++++++++++--------------- lua/plugins/rust_tools_conf.lua | 5 +-- lua/utils.lua | 7 +++ 7 files changed, 89 insertions(+), 60 deletions(-) create mode 100644 lua/config/vscode.lua diff --git a/lazy-lock.json b/lazy-lock.json index fc37894..2a9cf2e 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,6 +1,6 @@ { "LuaSnip": { "branch": "master", "commit": "500981ff6cefc7343e3959ef0f939bd0bfd49ba9" }, - "SchemaStore.nvim": { "branch": "main", "commit": "177cae4f44ddf7c166ef263956378ae308ff77ff" }, + "SchemaStore.nvim": { "branch": "main", "commit": "c23407de1f76df30ca197b69d78a11be5ce26009" }, "bufferline.nvim": { "branch": "main", "commit": "e48ce1805697e4bb97bc171c081e849a65859244" }, "cellular-automaton.nvim": { "branch": "main", "commit": "b7d056dab963b5d3f2c560d92937cb51db61cb5b" }, "clangd_extensions.nvim": { "branch": "main", "commit": "34c8eaa12be192e83cd4865ce2375e9f53e728f2" }, @@ -13,8 +13,8 @@ "dashboard-nvim": { "branch": "master", "commit": "63df28409d940f9cac0a925df09d3dc369db9841" }, "dressing.nvim": { "branch": "master", "commit": "8b7ae53d7f04f33be3439a441db8071c96092d19" }, "fidget.nvim": { "branch": "legacy", "commit": "2f7c08f45639a64a5c0abcf67321d52c3f499ae6" }, - "flutter-tools.nvim": { "branch": "main", "commit": "7350750d46fbeb4d2bb4878157b658d435935299" }, - "go.nvim": { "branch": "master", "commit": "7b7c20029a817ef51f6b498388488e9850fe45ac" }, + "flutter-tools.nvim": { "branch": "main", "commit": "7cb01c52ac9ece55118be71e0f7457783d5522a4" }, + "go.nvim": { "branch": "master", "commit": "1d140eec2a1ca90a0f2c685c7869724b2af72d26" }, "guihua.lua": { "branch": "master", "commit": "9fb6795474918b492d9ab01b1ebaf85e8bf6fe0b" }, "impatient.nvim": { "branch": "main", "commit": "47302af74be7b79f002773011f0d8e85679a7618" }, - "indent-blankline.nvim": { "branch": "master", "commit": "7206c77cb931f79885fc47f88ae18f99148392eb" }, + "indent-blankline.nvim": { "branch": "master", "commit": "f3eb33c04c3c5028b4efa7dbf8f68abdb6ab50ed" }, diff --git a/lua/config/init.lua b/lua/config/init.lua index c108466..6ff78d2 100644 --- a/lua/config/init.lua +++ b/lua/config/init.lua @@ -2,4 +2,11 @@ Prequire("config.autocmds") Prequire("config.bindings") Prequire("config.commands") Prequire("config.options") -Prequire("config.neovide") + +if vim.g.neovide then + Prequire("config.neovide") +end + +if vim.g.vscode then + Prequire("config.vscode") +end diff --git a/lua/config/neovide.lua b/lua/config/neovide.lua index 89c2be0..f539488 100644 --- a/lua/config/neovide.lua +++ b/lua/config/neovide.lua @@ -1,30 +1,28 @@ -if vim.g.neovide ~= nil then - vim.cmd("hi Normal guibg=NONE") +vim.cmd("hi Normal guibg=NONE") - local cursor_vfx = { "railgun", "torpedo", "pixiedust", "sonicboom", "ripple", "wireframe" } +local cursor_vfx = { "railgun", "torpedo", "pixiedust", "sonicboom", "ripple", "wireframe" } - vim.g.neovide_scale_factor = 0.78 -- 1 +vim.g.neovide_scale_factor = 0.78 -- 1 - vim.g.neovide_floating_blur_amount_x = 10.0 -- 2.0 - vim.g.neovide_floating_blur_amount_y = 10.0 -- 2.0 +vim.g.neovide_floating_blur_amount_x = 10.0 -- 2.0 +vim.g.neovide_floating_blur_amount_y = 10.0 -- 2.0 - vim.g.neovide_transparency = 0.9 -- 0 +vim.g.neovide_transparency = 0.9 -- 0 - -- vim.g.neovide_scroll_animation_length = -- 0.3 +-- vim.g.neovide_scroll_animation_length = -- 0.3 - vim.g.neovide_hide_mouse_when_typing = true -- false +vim.g.neovide_hide_mouse_when_typing = true -- false - vim.g.neovide_refresh_rate = 24 - vim.g.neovide_refresh_rate_idle = 1 - vim.g.neovide_no_idle = false +vim.g.neovide_refresh_rate = 24 +vim.g.neovide_refresh_rate_idle = 1 +vim.g.neovide_no_idle = false - vim.g.neovide_confirm_quit = false -- true +vim.g.neovide_confirm_quit = false -- true - -- vim.g.neovide_remember_window_size = -- true +-- vim.g.neovide_remember_window_size = -- true - -- vim.g.neovide_profiler = true -- false +-- vim.g.neovide_profiler = true -- false - -- let g:neovide_input_use_logo = v:false " v:true on macOS +-- let g:neovide_input_use_logo = v:false " v:true on macOS - vim.g.neovide_cursor_vfx_mode = RandFrom(cursor_vfx) -end +vim.g.neovide_cursor_vfx_mode = RandFrom(cursor_vfx) diff --git a/lua/config/vscode.lua b/lua/config/vscode.lua new file mode 100644 index 0000000..cbeb8f8 --- /dev/null +++ b/lua/config/vscode.lua @@ -0,0 +1,11 @@ +-- https://marketplace.visualstudio.com/items?itemName=asvetliakov.vscode-neovim#api +local vscode = require("vscode-neovim") + +local function f_vs_call(cmd) + return function() + vscode.call(cmd) + end +end + +vim.keymap.set(Keys.N, "nf", f_vs_call("editor.action.formartDocument.none"), Keys.None) +vim.keymap.set(Keys.V, "nf", f_vs_call("editor.action.formatSelection"), Keys.None) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index ccfeb71..f01ebb5 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -157,23 +157,13 @@ local refactoring_ft = { "typescript", } -local plugins = { +local vscode_enabled_plugins = { { "lewis6991/impatient.nvim", config = RequireFn("impatient") }, - { - "marko-cerovac/material.nvim", - config = RequireFn("plugins.material_conf"), - priority = 100, - }, - - "stevearc/dressing.nvim", - - "airblade/vim-gitgutter", - "ap/vim-css-color", "chaoren/vim-wordmotion", "itchyny/vim-cursorword", "mg979/vim-visual-multi", - "rcarriga/nvim-notify", + "romainl/vim-cool", "tpope/vim-repeat", "tpope/vim-sleuth", @@ -181,8 +171,6 @@ local plugins = { { "windwp/nvim-autopairs", config = RequireSetupFn("nvim-autopairs") }, { "kylechui/nvim-surround", config = RequireSetupFn("nvim-surround") }, { "chentoast/marks.nvim", config = RequireSetupFn("marks") }, - { "folke/todo-comments.nvim", config = RequireSetupFn("todo-comments") }, - { "Iron-E/nvim-libmodal", config = RequireFn("plugins.libmodal_conf") }, { "junegunn/vim-easy-align", config = RequireFn("plugins.easyalign_conf") }, { "mbbill/undotree", config = RequireFn("plugins.undotree_conf") }, { "preservim/nerdcommenter", config = RequireFn("plugins.nerdcommenter_conf") }, @@ -201,6 +189,39 @@ local plugins = { end, }, + { + "kevinhwang91/nvim-ufo", + config = RequireFn("plugins.ufo_conf"), + dependencies = { "kevinhwang91/promise-async" }, + priority = 48, + }, + + { "danymat/neogen", config = RequireFn("plugins.neogen_conf"), ft = neogen_ft }, + "wakatime/vim-wakatime", +} +local vscode_disabled_plugins = { + + { + "ThePrimeagen/refactoring.nvim", + config = RequireFn("plugins.refactoring_conf"), + ft = refactoring_ft, + priority = 0, + }, + + { + "marko-cerovac/material.nvim", + config = RequireFn("plugins.material_conf"), + priority = 100, + }, + + "stevearc/dressing.nvim", + + "airblade/vim-gitgutter", + "ap/vim-css-color", + "rcarriga/nvim-notify", + + { "folke/todo-comments.nvim", config = RequireSetupFn("todo-comments") }, + { "Iron-E/nvim-libmodal", config = RequireFn("plugins.libmodal_conf") }, { "nvim-tree/nvim-web-devicons" }, { "akinsho/bufferline.nvim", @@ -278,7 +299,7 @@ local plugins = { }, { "neovim/nvim-lspconfig", ft = lsp_ft, config = RequireFn("plugins.lsp"), priority = 50 }, - { "j-hui/fidget.nvim", branch = "legacy",config = RequireFn("plugins.fidget_conf"), priority = 49, ft = lsp_ft }, + { "j-hui/fidget.nvim", branch = "legacy", config = RequireFn("plugins.fidget_conf"), priority = 49, ft = lsp_ft }, { "simrat39/symbols-outline.nvim", config = RequireSetupFn("symbols-outline"), @@ -288,13 +309,6 @@ local plugins = { keys = { { "so", ":SymbolsOutline", desc = "SymbolsOutline" } }, }, - { - "kevinhwang91/nvim-ufo", - config = RequireFn("plugins.ufo_conf"), - dependencies = { "kevinhwang91/promise-async" }, - priority = 48, - }, - { "folke/neodev.nvim", ft = { "lua" }, @@ -329,6 +343,7 @@ local plugins = { ft = { "rust" }, config = RequireFn("plugins.rust_tools_conf"), priority = 0, + dependencies = { "neovim/nvim-lspconfig", ft = lsp_ft, config = RequireFn("plugins.lsp"), priority = 50 }, }, { @@ -355,17 +370,6 @@ local plugins = { priority = 49, }, - { "danymat/neogen", config = RequireFn("plugins.neogen_conf"), ft = neogen_ft }, - - { - "ThePrimeagen/refactoring.nvim", - config = RequireFn("plugins.refactoring_conf"), - ft = refactoring_ft, - priority = 0, - }, - - "wakatime/vim-wakatime", - { "folke/which-key.nvim", commnad = "WhichKey", @@ -394,4 +398,9 @@ local plugins = { }, } +local plugins = vscode_enabled_plugins +if not vim.g.vscode then + plugins = TableConcat(plugins, vscode_disabled_plugins) +end + require("lazy").setup(plugins, opt) diff --git a/lua/plugins/rust_tools_conf.lua b/lua/plugins/rust_tools_conf.lua index 8b48437..4354ce1 100644 --- a/lua/plugins/rust_tools_conf.lua +++ b/lua/plugins/rust_tools_conf.lua @@ -153,13 +153,10 @@ rt.setup({ }, }, }, - -- all the opts to send to nvim-lspconfig - -- these override the defaults set by rust-tools.nvim -- see https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rust_analyzer server = { - -- standalone file support - -- setting it to false may improve startup time standalone = false, + -- cmd = { "ra-multiplex" }, on_attach = function(client, bufnr) LSP.on_attach(client, bufnr) diff --git a/lua/utils.lua b/lua/utils.lua index 9382667..c76f293 100644 --- a/lua/utils.lua +++ b/lua/utils.lua @@ -4,6 +4,13 @@ function RandFrom(list) return list[math.random(1, #list)] end +function TableConcat(t1,t2) + for i=1,#t2 do + t1[#t1+1] = t2[i] + end + return t1 +end + function RandStr(length) local res = "" for _ = 1, length do From 62361e2f757b120ca2fa01242449e0b8b71d1dfa Mon Sep 17 00:00:00 2001 From: PandeCode Date: Wed, 20 Dec 2023 10:33:32 -0500 Subject: [PATCH 04/11] fmt --- rust/src/keymaps.rs | 69 +++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/rust/src/keymaps.rs b/rust/src/keymaps.rs index 6b6286a..16be52b 100644 --- a/rust/src/keymaps.rs +++ b/rust/src/keymaps.rs @@ -18,21 +18,26 @@ pub fn keymaps() -> Result<()> { let noremap_expr = &(SetKeymapOpts::builder().noremap(true).expr(true).build()); let noremap_silent = &(SetKeymapOpts::builder().noremap(true).silent(true).build()); + #[rustfmt::skip] let keymaps = [ - (v, "so", ":sort", none), - (n, "qa", ":noautocmd qall!", none), - (n, "sf", ":w", none), - (n, "fe", ":edit", none), - (n, "nw", "%s/\\s*$//", none), - (n, "`", "edit #", none), - (n, "p", "\"_dP", none), - (n, "gf", ":e ", none), - (n, "", "*:%s//", none), - (a, "", "", noremap), // increament - (a, "", "", noremap), // decreament - (n, "L", "$", none), - (n, "H", "^", none), - (n, "Q", "", none), // Disable visual mode + + (v, "so", ":sort", none), + (n, "ne", ":set noexpandtab!", noremap), + (n, "et", ":set expandtab!", noremap), + (n, "qa", ":noautocmd qall!", none), + (n, "sf", ":w", none), + (n, "fe", ":edit", none), + (n, "nw", "%s/\\s*$//", none), + (n, "`", "edit #", none), + (n, "p", "\"_dP", none), + (n, "gf", ":e ", none), + (n, "", "*:%s//", none), + (a, "", "", noremap), // increament + (a, "", "", noremap), // decreament + (n, "L", "$", none), + (n, "H", "^", none), + (n, "Q", "", none), // Disable visual mode + ( n, "", @@ -51,23 +56,25 @@ pub fn keymaps() -> Result<()> { "(col('.') == match(getline('.'), '\\s*$') ? '$h' : 'g_')", noremap_expr, ), - (i, "", "", none), - (i, " ", "", none), - (n, "gg", "gg0", noremap), - (a, "G", "G", noremap), - (a, "Y", "y$", noremap), - (n, "w", "", noremap), + + (i, "", "", none), + (i, " ", "", none), + (n, "gg", "gg0", noremap), + (a, "G", "G", noremap), + (a, "Y", "y$", noremap), + (n, "w", "", noremap), (n, "w|", "vsplit", noremap), - (n, "w_", "split", noremap), + (n, "w_", "split", noremap), // system clipboard - (n, "", "\"+y\"", noremap), - (v, "", "\"+y\"", noremap), - (n, "", "\"+p\"", noremap), - (i, "", "+", noremap), - (c, "", "+", noremap), - (n, "", "d", none), - (i, "", "d", none), - (c, "", "d", none), + (n, "", "\"+y\"", noremap), + (v, "", "\"+y\"", noremap), + (n, "", "\"+p\"", noremap), + (i, "", "+", noremap), + (c, "", "+", noremap), + (n, "", "d", none), + (i, "", "d", none), + (c, "", "d", none), + // use to insert original character without triggering things like auto-pairs (i, "", "", noremap), (n, "fs", ":w", noremap), @@ -87,6 +94,7 @@ pub fn keymaps() -> Result<()> { (i, "{", "{u", noremap), (i, "}", "}u", noremap), (i, "\"", "\"u", noremap), + ( n, "k", @@ -99,6 +107,7 @@ pub fn keymaps() -> Result<()> { "(v:count > 5 ? \"m'\" . v:count : \"\") . 'j'", noremap_expr, ), + (v, "", ":m '>+1gv=gv", noremap), (v, "", ":m '<-2gv=gv", noremap), (n, "", ":m .+1==", noremap), @@ -129,8 +138,6 @@ pub fn keymaps() -> Result<()> { (v, ")", "`>a)`", noremap), (v, "]", "`>a]`", noremap), (v, "", "`>a}`", noremap), - (n, "ne", ":set noexpandtab!", noremap), - (n, "et", ":set expandtab!", noremap), ]; for keymap in keymaps { From 923ad26910abf730fec2dfc415bc3dc328e86cde Mon Sep 17 00:00:00 2001 From: PandeCode Date: Wed, 20 Dec 2023 12:32:46 -0500 Subject: [PATCH 05/11] autocmds start --- lua/config/autocmds.lua | 17 ----------------- rust/Cargo.toml | 4 +++- rust/build.sh | 6 +++++- rust/src/autocmds.rs | 25 +++++++++++++++++++++++++ rust/src/keymaps.rs | 6 ++++-- rust/src/lib.rs | 12 ++++++++---- 6 files changed, 45 insertions(+), 25 deletions(-) create mode 100644 rust/src/autocmds.rs diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua index 944092b..6dc9cea 100644 --- a/lua/config/autocmds.lua +++ b/lua/config/autocmds.lua @@ -1,20 +1,3 @@ --- assumes set ignorecase smartcase; -vim.api.nvim_create_autocmd("CmdLineEnter", { - pattern = { ":" }, - group = vim.api.nvim_create_augroup("dynamic_smartcase", {}), - callback = function() - vim.o.smartcase = false - end, -}) - -vim.api.nvim_create_autocmd("CmdLineLeave", { - pattern = { ":" }, - group = vim.api.nvim_create_augroup("dynamic_smartcase", {}), - callback = function() - vim.o.smartcase = true - end, -}) - vim.api.nvim_create_autocmd({ "BufWritePre" }, { pattern = "*", callback = function() diff --git a/rust/Cargo.toml b/rust/Cargo.toml index d77f9e8..847b52e 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -7,4 +7,6 @@ edition = "2021" crate-type = ["cdylib"] [dependencies] -nvim-oxi = { version="0.4.0", features = ["neovim-0-9"]} +miette = { version = "5.10.0", features = ["fancy"] } +mlua = { version = "0.9.2", features = ["luajit"] } +nvim-oxi = { version = "0.4.0", features = ["neovim-0-9", "mlua"] } diff --git a/rust/build.sh b/rust/build.sh index 92c719d..96b1b8a 100755 --- a/rust/build.sh +++ b/rust/build.sh @@ -1,4 +1,8 @@ #!/bin/sh +owd=$CWD -cargo build --release&& +cd ~/.config/nvim/rust +cargo build --release && cp -r lua/release/librust.so lua/ + +cd $owd diff --git a/rust/src/autocmds.rs b/rust/src/autocmds.rs new file mode 100644 index 0000000..2f1fdc4 --- /dev/null +++ b/rust/src/autocmds.rs @@ -0,0 +1,25 @@ +use nvim_oxi::api; +use nvim_oxi::{self as oxi}; +use oxi::api::opts::{CreateAutocmdOpts, OptionValueOpts}; + +use miette::Result; +use oxi::api::types::Mode; +use oxi::Error; + +pub fn autocmds() -> Result<(), Error> { + let mk_dyn_case = |b| { + CreateAutocmdOpts::builder() + .desc("Dynamic Smartcase") + .patterns([":"]) + // .group("dynamic_smartcase") + .callback(move |_| { + api::set_option("smartcase", b)?; + Ok::(false) + }) + .build() + }; + + api::create_autocmd(["CmdLineEnter"], &mk_dyn_case(false))?; + api::create_autocmd(["CmdLineLeave"], &mk_dyn_case(true))?; + Ok(()) +} diff --git a/rust/src/keymaps.rs b/rust/src/keymaps.rs index 16be52b..3d6c812 100644 --- a/rust/src/keymaps.rs +++ b/rust/src/keymaps.rs @@ -1,9 +1,11 @@ use nvim_oxi::api::{self, types::Mode}; use nvim_oxi::{self as oxi}; use oxi::api::opts::SetKeymapOpts; -use oxi::Result; -pub fn keymaps() -> Result<()> { +use miette::Result; +use oxi::Error; + +pub fn keymaps() -> Result<(), Error> { api::set_var("mapleader", " ")?; let n = &Mode::Normal; diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 6bbfe81..075af95 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1,18 +1,22 @@ mod keymaps; +mod autocmds; use nvim_oxi::{self as oxi, Dictionary, Function, Object}; -use oxi::Result; use std::convert::Infallible; +use miette::Result; +use oxi::Error; -#[oxi::module] -fn librust() -> Result { - keymaps::keymaps()?; +#[oxi::module] +fn librust() -> Result { let add = Function::from_fn(|(a, b): (i32, i32)| Ok::<_, Infallible>(a + b)); let multiply = Function::from_fn(|(a, b): (i32, i32)| Ok::<_, Infallible>(a * b)); let compute = Function::from_fn(|(fun, a, b): (Function<(i32, i32), i32>, i32, i32)| fun.call((a, b))); + keymaps::keymaps()?; + autocmds::autocmds()?; + Ok(Dictionary::from_iter([ ("add", Object::from(add)), ("multiply", Object::from(multiply)), From 8e7a2860a3bf2433713814e96072baad39ee7491 Mon Sep 17 00:00:00 2001 From: PandeCode Date: Thu, 28 Dec 2023 21:55:06 -0500 Subject: [PATCH 06/11] snippets --- snippets/go.json | 268 +++++++++++++++++++++++++++++++++++++++++++-- snippets/rust.json | 45 ++++++++ 2 files changed, 306 insertions(+), 7 deletions(-) diff --git a/snippets/go.json b/snippets/go.json index 16ae95d..a68eb8b 100644 --- a/snippets/go.json +++ b/snippets/go.json @@ -1,10 +1,264 @@ { - "Print to console": { - "prefix": "print", - "body": [ - "fmt.Printf(\"$1\"$2);", - "$3" - ], - "description": "Output to console" + "Print to console": { + "prefix": "print", + "body": ["fmt.Printf(\"$1\"$2);", "$3"], + "description": "Output to console" + }, + ".source.go": { + "single import": { + "prefix": "im", + "body": "import \"${1:package}\"", + "description": "Snippet for import statement" + }, + "multiple imports": { + "prefix": "ims", + "body": "import (\n\t\"${1:package}\"\n)", + "description": "Snippet for a import block" + }, + "single constant": { + "prefix": "co", + "body": "const ${1:name} = ${2:value}", + "description": "Snippet for a constant" + }, + "multiple constants": { + "prefix": "cos", + "body": "const (\n\t${1:name} = ${2:value}\n)", + "description": "Snippet for a constant block" + }, + "type interface declaration": { + "prefix": "tyi", + "body": "type ${1:name} interface {\n\t$0\n}", + "description": "Snippet for a type interface" + }, + "type struct declaration": { + "prefix": "tys", + "body": "type ${1:name} struct {\n\t$0\n}", + "description": "Snippet for a struct declaration" + }, + "package main and main function": { + "prefix": "pkgm", + "body": "package main\n\nfunc main() {\n\t$0\n}", + "description": "Snippet for main package & function" + }, + "function declaration": { + "prefix": "func", + "body": "func $1($2) $3 {\n\t$0\n}", + "description": "Snippet for function declaration" + }, + "variable declaration": { + "prefix": "var", + "body": "var ${1:name} ${2:type}", + "description": "Snippet for a variable" + }, + "switch statement": { + "prefix": "switch", + "body": "switch ${1:expression} {\ncase ${2:condition}:\n\t$0\n}", + "description": "Snippet for switch statement" + }, + "select statement": { + "prefix": "sel", + "body": "select {\ncase ${1:condition}:\n\t$0\n}", + "description": "Snippet for select statement" + }, + "case clause": { + "prefix": "cs", + "body": "case ${1:condition}:$0", + "description": "Snippet for case clause" + }, + "for statement": { + "prefix": "for", + "body": "for ${1:i} := 0; $1 < ${2:count}; $1${3:++} {\n\t$0\n}", + "description": "Snippet for a for loop" + }, + "for range statement": { + "prefix": "forr", + "body": "for ${1:_, }${2:var} := range ${3:var} {\n\t$0\n}", + "description": "Snippet for a for range loop" + }, + "channel declaration": { + "prefix": "ch", + "body": "chan ${1:type}", + "description": "Snippet for a channel" + }, + "map declaration": { + "prefix": "map", + "body": "map[${1:type}]${2:type}", + "description": "Snippet for a map" + }, + "empty interface": { + "prefix": "in", + "body": "interface{}", + "description": "Snippet for empty interface" + }, + "if statement": { + "prefix": "if", + "body": "if ${1:condition} {\n\t$0\n}", + "description": "Snippet for if statement" + }, + "else branch": { + "prefix": "el", + "body": "else {\n\t$0\n}", + "description": "Snippet for else branch" + }, + "if else statement": { + "prefix": "ie", + "body": "if ${1:condition} {\n\t$2\n} else {\n\t$0\n}", + "description": "Snippet for if else" + }, + "if err != nil": { + "prefix": "iferr", + "body": "if err != nil {\n\t${1:return ${2:nil, }${3:err}}\n}", + "description": "Snippet for if err != nil" + }, + "fmt.Println": { + "prefix": "fp", + "body": "fmt.Println(\"$1\")", + "description": "Snippet for fmt.Println()" + }, + "fmt.Printf": { + "prefix": "ff", + "body": "fmt.Printf(\"$1\", ${2:var})", + "description": "Snippet for fmt.Printf()" + }, + "log.Println": { + "prefix": "lp", + "body": "log.Println(\"$1\")", + "description": "Snippet for log.Println()" + }, + "log.Printf": { + "prefix": "lf", + "body": "log.Printf(\"$1\", ${2:var})", + "description": "Snippet for log.Printf()" + }, + "log variable content": { + "prefix": "lv", + "body": "log.Printf(\"${1:var}: %#+v\\\\n\", ${1:var})", + "description": "Snippet for log.Printf() with variable content" + }, + "t.Log": { + "prefix": "tl", + "body": "t.Log(\"$1\")", + "description": "Snippet for t.Log()" + }, + "t.Logf": { + "prefix": "tlf", + "body": "t.Logf(\"$1\", ${2:var})", + "description": "Snippet for t.Logf()" + }, + "t.Logf variable content": { + "prefix": "tlv", + "body": "t.Logf(\"${1:var}: %#+v\\\\n\", ${1:var})", + "description": "Snippet for t.Logf() with variable content" + }, + "make(...)": { + "prefix": "make", + "body": "make(${1:type}, ${2:0})", + "description": "Snippet for make statement" + }, + "new(...)": { + "prefix": "new", + "body": "new(${1:type})", + "description": "Snippet for new statement" + }, + "panic(...)": { + "prefix": "pn", + "body": "panic(\"$0\")", + "description": "Snippet for panic" + }, + "http ResponseWriter *Request": { + "prefix": "wr", + "body": "${1:w} http.ResponseWriter, ${2:r} *http.Request", + "description": "Snippet for http Response" + }, + "http.HandleFunc": { + "prefix": "hf", + "body": "${1:http}.HandleFunc(\"${2:/}\", ${3:handler})", + "description": "Snippet for http.HandleFunc()" + }, + "http handler declaration": { + "prefix": "hand", + "body": "func $1(${2:w} http.ResponseWriter, ${3:r} *http.Request) {\n\t$0\n}", + "description": "Snippet for http handler declaration" + }, + "http.Redirect": { + "prefix": "rd", + "body": "http.Redirect(${1:w}, ${2:r}, \"${3:/}\", ${4:http.StatusFound})", + "description": "Snippet for http.Redirect()" + }, + "http.Error": { + "prefix": "herr", + "body": "http.Error(${1:w}, ${2:err}.Error(), ${3:http.StatusInternalServerError})", + "description": "Snippet for http.Error()" + }, + "http.ListenAndServe": { + "prefix": "las", + "body": "http.ListenAndServe(\"${1::8080}\", ${2:nil})", + "description": "Snippet for http.ListenAndServe" + }, + "http.Serve": { + "prefix": "sv", + "body": "http.Serve(\"${1::8080}\", ${2:nil})", + "description": "Snippet for http.Serve" + }, + "goroutine anonymous function": { + "prefix": "go", + "body": "go func($1) {\n\t$0\n}($2)", + "description": "Snippet for anonymous goroutine declaration" + }, + "goroutine function": { + "prefix": "gf", + "body": "go ${1:func}($0)", + "description": "Snippet for goroutine declaration" + }, + "defer statement": { + "prefix": "df", + "body": "defer ${1:func}($0)", + "description": "Snippet for defer statement" + }, + "test function": { + "prefix": "tf", + "body": "func Test$1(t *testing.T) {\n\t$0\n}", + "description": "Snippet for Test function" + }, + "benchmark function": { + "prefix": "bf", + "body": "func Benchmark$1(b *testing.B) {\n\tfor ${2:i} := 0; ${2:i} < b.N; ${2:i}++ {\n\t\t$0\n\t}\n}", + "description": "Snippet for Benchmark function" + }, + "example function": { + "prefix": "ef", + "body": "func Example$1() {\n\t$2\n\t//Output:\n\t$3\n}", + "description": "Snippet for Example function" + }, + "table driven test": { + "prefix": "tdt", + "body": "func Test$1(t *testing.T) {\n\ttestCases := []struct {\n\t\tdesc\tstring\n\t\t$2\n\t}{\n\t\t{\n\t\t\tdesc: \"$3\",\n\t\t\t$4\n\t\t},\n\t}\n\tfor _, tC := range testCases {\n\t\tt.Run(tC.desc, func(t *testing.T) {\n\t\t\t$0\n\t\t})\n\t}\n}", + "description": "Snippet for table driven test" + }, + "init function": { + "prefix": "finit", + "body": "func init() {\n\t$1\n}", + "description": "Snippet for init function" + }, + "main function": { + "prefix": "fmain", + "body": "func main() {\n\t$1\n}", + "description": "Snippet for main function" + }, + "method declaration": { + "prefix": "meth", + "body": "func (${1:receiver} ${2:type}) ${3:method}($4) $5 {\n\t$0\n}", + "description": "Snippet for method declaration" + }, + "hello world web app": { + "prefix": "helloweb", + "body": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"time\"\n)\n\nfunc greet(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, \"Hello World! %s\", time.Now())\n}\n\nfunc main() {\n\thttp.HandleFunc(\"/\", greet)\n\thttp.ListenAndServe(\":8080\", nil)\n}", + "description": "Snippet for sample hello world webapp" + }, + "sort implementation": { + "prefix": "sort", + "body": "type ${1:SortBy} []${2:Type}\n\nfunc (a $1) Len() int { return len(a) }\nfunc (a $1) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a $1) Less(i, j int) bool { ${3:return a[i] < a[j]} }", + "description": "Snippet for a custom sort.Sort interface implementation, for a given slice type." } + } } diff --git a/snippets/rust.json b/snippets/rust.json index ac12bcd..be9d988 100644 --- a/snippets/rust.json +++ b/snippets/rust.json @@ -177,5 +177,50 @@ "\t}", "}" ] + }, + "extern crate": { + "prefix": "extern crate", + "body": ["extern crate ${1:name};"], + "description": "Insert extern crate" + }, + "for": { + "prefix": "for", + "body": ["for ${1:elem} in ${2:iter} {", "\t$0", "}"], + "description": "Insert for loop" + }, + "macro_rules": { + "prefix": "macro_rules", + "body": ["macro_rules! $1 {", "\t($2) => {", "\t\t$0", "\t};", "}"], + "description": "Insert macro_rules!" + }, + "if let": { + "prefix": "if let", + "body": ["if let ${1:pattern} = ${2:value} {", "\t$3", "}"], + "description": "Insert if to match a specific pattern, useful for enum variants e.g. `Some(inner)`" + }, + "spawn": { + "prefix": ["thread_spawn", "spawn"], + "body": ["std::thread::spawn(move || {", "\t$1", "})"], + "description": "Wrap code in thread::spawn" + }, + "derive": { + "prefix": "derive", + "body": ["#[derive(${1})]"], + "description": "#[derive(…)]" + }, + "cfg": { + "prefix": "cfg", + "body": ["#[cfg(${1})]"], + "description": "#[cfg(…)]" + }, + "test": { + "prefix": "test", + "body": [ + "#[test]", + "fn ${1:name}() {", + " ${2:unimplemented!();}", + "}" + ], + "description": "#[test]" } } From 01b6c2fcf311d5504b7c6f031186b15b7e15ba15 Mon Sep 17 00:00:00 2001 From: PandeCode Date: Thu, 28 Dec 2023 22:23:25 -0500 Subject: [PATCH 07/11] Obsidian --- lua/plugins/init.lua | 20 ++++++++++++++++++++ lua/plugins/obsidian_plugin.lua | 0 lua/plugins/treesitter_conf.lua | 6 ++++-- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 lua/plugins/obsidian_plugin.lua diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index f01ebb5..2263fdd 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -262,6 +262,26 @@ local vscode_disabled_plugins = { { "lukas-reineke/indent-blankline.nvim", config = RequireFn("plugins.indent_blankline_conf"), priority = 49 }, + { + "epwalsh/obsidian.nvim", + version = "*", + lazy = true, + ft = "markdown", + event = { + "BufReadPre /mnt/g/My Drive/Vault/School/**.md", + "BufNewFile /mnt/g/My Drive/Vault/School/**.md", + "BufReadPre /mnt/g/My Drive/Vault/Jorunal/**.md", + "BufNewFile /mnt/g/My Drive/Vault/Jorunal/**.md", + }, + dependencies = { "nvim-lua/plenary.nvim" }, + opts = { + workspaces = { + { name = "School", path = "/mnt/g/My Drive/Vault/School" }, + { name = "Jorunal", path = "/mnt/g/My Drive/Vault/Jorunal" }, + }, + }, + }, + { "nvim-treesitter/nvim-treesitter-textobjects", priority = 49, diff --git a/lua/plugins/obsidian_plugin.lua b/lua/plugins/obsidian_plugin.lua new file mode 100644 index 0000000..e69de29 diff --git a/lua/plugins/treesitter_conf.lua b/lua/plugins/treesitter_conf.lua index bd628d9..a3ef743 100644 --- a/lua/plugins/treesitter_conf.lua +++ b/lua/plugins/treesitter_conf.lua @@ -1,6 +1,6 @@ require("orgmode").setup_ts_grammar() -local ts_repeat_move = require "nvim-treesitter.textobjects.repeatable_move" +local ts_repeat_move = require("nvim-treesitter.textobjects.repeatable_move") -- Repeat movement with ; and , -- ensure ; goes forward and , goes backward regardless of the last direction @@ -97,7 +97,7 @@ require("nvim-treesitter.configs").setup({ }, goto_previous = { ["[d"] = "@conditional.outer", - } + }, }, }, ensure_installed = { @@ -123,6 +123,8 @@ require("nvim-treesitter.configs").setup({ "json5", "kotlin", "lua", + "markdown", + "markdown_inline", "org", "python", "query", From fe28ab3d42f72faae865b3da7d3269b80c64db95 Mon Sep 17 00:00:00 2001 From: PandeCode Date: Sun, 10 Mar 2024 12:39:39 -0600 Subject: [PATCH 08/11] Obsidian | Rust | FMT --- lazy-lock.json | 14 +- lua/config/options.lua | 1 + lua/plugins/init.lua | 62 +- lua/plugins/rust_tools_conf.lua | 24 +- snippets/cmake.json | 9 +- snippets/global.json | 12 + snippets/glsl.json | 1388 +++++++++++++++---------------- snippets/lua.json | 14 +- snippets/rust.json | 87 ++ 9 files changed, 882 insertions(+), 729 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 2a9cf2e..ad0a7e9 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,7 +1,7 @@ { "LuaSnip": { "branch": "master", "commit": "500981ff6cefc7343e3959ef0f939bd0bfd49ba9" }, - "SchemaStore.nvim": { "branch": "main", "commit": "c23407de1f76df30ca197b69d78a11be5ce26009" }, - "bufferline.nvim": { "branch": "main", "commit": "e48ce1805697e4bb97bc171c081e849a65859244" }, + "SchemaStore.nvim": { "branch": "main", "commit": "b788bde023f9fbc2eb86e89d32c0bf98a60ae406" }, + "bufferline.nvim": { "branch": "main", "commit": "64e2c5def50dfd6b6f14d96a45fa3d815a4a1eef" }, "cellular-automaton.nvim": { "branch": "main", "commit": "b7d056dab963b5d3f2c560d92937cb51db61cb5b" }, "clangd_extensions.nvim": { "branch": "main", "commit": "34c8eaa12be192e83cd4865ce2375e9f53e728f2" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, @@ -10,11 +10,11 @@ "cmp-nvim-tags": { "branch": "main", "commit": "30bdc2eec86eb66730af541bb06d24d4a67e3eeb" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "dashboard-nvim": { "branch": "master", "commit": "63df28409d940f9cac0a925df09d3dc369db9841" }, - "dressing.nvim": { "branch": "master", "commit": "8b7ae53d7f04f33be3439a441db8071c96092d19" }, + "dashboard-nvim": { "branch": "master", "commit": "413442b12d85315fc626c44a0ce4929b213ef604" }, + "dressing.nvim": { "branch": "master", "commit": "6f212262061a2120e42da0d1e87326e8a41c0478" }, "fidget.nvim": { "branch": "legacy", "commit": "2f7c08f45639a64a5c0abcf67321d52c3f499ae6" }, - "flutter-tools.nvim": { "branch": "main", "commit": "7cb01c52ac9ece55118be71e0f7457783d5522a4" }, - "go.nvim": { "branch": "master", "commit": "1d140eec2a1ca90a0f2c685c7869724b2af72d26" }, + "flutter-tools.nvim": { "branch": "main", "commit": "01d72d9c1bdf2d454a60c5ba450f83e5ea783f6a" }, + "go.nvim": { "branch": "master", "commit": "d217a74fa823d0adef1a3680c3af562ae14e6854" }, "guihua.lua": { "branch": "master", "commit": "9fb6795474918b492d9ab01b1ebaf85e8bf6fe0b" }, "impatient.nvim": { "branch": "main", "commit": "47302af74be7b79f002773011f0d8e85679a7618" }, - "indent-blankline.nvim": { "branch": "master", "commit": "f3eb33c04c3c5028b4efa7dbf8f68abdb6ab50ed" }, + "indent-blankline.nvim": { "branch": "master", "commit": "821a7acd88587d966f7e464b0b3031dfe7f5680c" }, diff --git a/lua/config/options.lua b/lua/config/options.lua index 04a4851..390cf37 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -70,3 +70,4 @@ vim.o.wildignore = "*.pyc" .. ",**/.git/*" vim.cmd("source $HOME/.config/nvim/vimscript/options.vim") +vim.cmd("source $HOME/.config/nvim/vimscript/autosave.vim") diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 2263fdd..9ccdff5 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -7,7 +7,7 @@ if not vim.loop.fs_stat(lazypath) then "--filter=blob:none", "--depth=1", "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release + "--branch=stable", lazypath, }) end @@ -197,9 +197,22 @@ local vscode_enabled_plugins = { }, { "danymat/neogen", config = RequireFn("plugins.neogen_conf"), ft = neogen_ft }, + "wakatime/vim-wakatime", } + local vscode_disabled_plugins = { + { + "folke/zen-mode.nvim", + keys = { { "zm", ":ZenMode", desc = "ZenMode" } }, + priority = 0, + }, + + { + "folke/twilight.nvim", + keys = { { "tl", ":Twilight", desc = "Twilight" } }, + priority = 0, + }, { "ThePrimeagen/refactoring.nvim", @@ -268,16 +281,51 @@ local vscode_disabled_plugins = { lazy = true, ft = "markdown", event = { - "BufReadPre /mnt/g/My Drive/Vault/School/**.md", - "BufNewFile /mnt/g/My Drive/Vault/School/**.md", - "BufReadPre /mnt/g/My Drive/Vault/Jorunal/**.md", - "BufNewFile /mnt/g/My Drive/Vault/Jorunal/**.md", + "BufReadPre /mnt/c/Users/pande/Vault/**.md", + "BufNewFile /mnt/c/Users/pande/Vault/**.md", + "BufReadPre /mnt/c/Users/pande/Vault/**.md", + "BufNewFile /mnt/c/Users/pande/Vault/**.md", + }, + keys = { + { + "ob", + function() + vim.ui.select({ + "QuickSwitch", + "Search", + "New", + "Link", + "Open", + "Check", + "Today", + "Rename", + "LinkNew", + "PasteImg", + "Template", + "Tomorrow", + "Backlinks", + "Workspace", + "Yesterday", + "FollowLink", + }, { + prompt = "Obsidian:", + format_item = function(item) + return "Obsidian" .. item + end, + }, function(choice) + vim.schedule(function() + vim.cmd("Obsidian" .. choice) + end) + end) + end, + }, + desc = "Obsidian", }, dependencies = { "nvim-lua/plenary.nvim" }, opts = { workspaces = { - { name = "School", path = "/mnt/g/My Drive/Vault/School" }, - { name = "Jorunal", path = "/mnt/g/My Drive/Vault/Jorunal" }, + { name = "School", path = "/mnt/c/Users/pande/Vault/School" }, + { name = "Jorunal", path = "/mnt/c/Users/pande/Vault/Jorunal" }, }, }, }, diff --git a/lua/plugins/rust_tools_conf.lua b/lua/plugins/rust_tools_conf.lua index 4354ce1..43d4ed2 100644 --- a/lua/plugins/rust_tools_conf.lua +++ b/lua/plugins/rust_tools_conf.lua @@ -156,7 +156,20 @@ rt.setup({ -- see https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rust_analyzer server = { standalone = false, - -- cmd = { "ra-multiplex" }, + settings = { + ["rust-analyzer"] = { + cargo = { buildScripts = { useRustcWrapper = false } }, + }, + }, + -- cmd = { + -- (function() + -- if string.sub(vim.fn.getcwd() or "", 1, 7) == "/mnt/c/" then + -- return "/mnt/c/Users/pande/.cargo/bin/rust-analyzer.exe" + -- else + -- return "/usr/lib/rustup/bin/rust-analyzer" + -- end + -- end)(), + -- }, on_attach = function(client, bufnr) LSP.on_attach(client, bufnr) @@ -193,7 +206,7 @@ rt.setup({ "EnableInlayHints", "OpenExternalDocs", "DisableInlayHints", - "StartStandaloneServerForBuffer" + "StartStandaloneServerForBuffer", }, { prompt = "Rust:", format_item = function(item) @@ -202,12 +215,9 @@ rt.setup({ }, function(choice) vim.schedule(function() vim.cmd("Rust" .. choice) - end - ) + end) end) - end - , opts) - + end, opts) vim.keymap.del("n", "K", opts) vim.keymap.del("n", "ca", opts) diff --git a/snippets/cmake.json b/snippets/cmake.json index 768334e..4f56124 100644 --- a/snippets/cmake.json +++ b/snippets/cmake.json @@ -68,7 +68,7 @@ "set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT \"-Os -DNDEBUG\")", "set(CMAKE_CXX_FLAGS_RELEASE_INIT \"-O3 -DNDEBUG\")", "set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT \"-O2 -g\")", - "", + "", "set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY \\${CMAKE_BINARY_DIR}/lib)", "set(CMAKE_LIBRARY_OUTPUT_DIRECTORY \\${CMAKE_BINARY_DIR}/lib)", "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \\${CMAKE_BINARY_DIR}/bin)", @@ -168,7 +168,7 @@ "set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT \"-Os -DNDEBUG\")", "set(CMAKE_CXX_FLAGS_RELEASE_INIT \"-O3 -DNDEBUG\")", "set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT \"-O2 -g\")", - "", + "", "find_package(Threads REQUIRED)", "", "file(GLOB_RECURSE SRC_FILES src/*)", @@ -187,7 +187,6 @@ ] }, - "Lib Project LINK_DIR": { "prefix": "cmake_lib_link_dir", "description": "Setup Library", @@ -260,7 +259,7 @@ "set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT \"-Os -DNDEBUG\")", "set(CMAKE_CXX_FLAGS_RELEASE_INIT \"-O3 -DNDEBUG\")", "set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT \"-O2 -g\")", - "", + "", "set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY \\${CMAKE_BINARY_DIR}/lib)", "set(CMAKE_LIBRARY_OUTPUT_DIRECTORY \\${CMAKE_BINARY_DIR}/lib)", "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \\${CMAKE_BINARY_DIR}/bin)", @@ -366,7 +365,7 @@ "set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT \"-Os -DNDEBUG\")", "set(CMAKE_CXX_FLAGS_RELEASE_INIT \"-O3 -DNDEBUG\")", "set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT \"-O2 -g\")", - "", + "", "find_package(Threads REQUIRED)", "", "file(GLOB_RECURSE SRC_FILES src/*)", diff --git a/snippets/global.json b/snippets/global.json index 05f0187..0a8e3e9 100644 --- a/snippets/global.json +++ b/snippets/global.json @@ -1,4 +1,16 @@ { + "mathjax": { + "prefix": "math", + "body": [ + "$$", + "\\begin{align}", + "& Hello \\\\\\\\", + "& World \\\\\\\\", + "& End", + "\\end{align}", + "$$" + ] + }, "HEADER COLOR": { "description": "HEADER Color", "prefix": "__HEADER", diff --git a/snippets/glsl.json b/snippets/glsl.json index 6218700..22042d5 100644 --- a/snippets/glsl.json +++ b/snippets/glsl.json @@ -1,696 +1,696 @@ { - "for": { - "prefix": "for", - "body": ["for(int $2 = 0; $2 < $3; $2++){", "\t", "}"], - "description": "for( ; ; ){\n\t//code\n}\n\nThe keyword for is used to describe a loop that is controlled by a counter. The parentheses enclose three expressions that initialize, check and update the variable used as counter. The body defined by curly braces encloses the statements that are executed at each pass of the loop.\n\nfor(int i = 0; i <= 99; i++){\n\taFunction();\n}\n\nThe execution of a single pass or the whole loop can be aborted by using a continue or a break statement respectively." - }, - - "while": { - "prefix": "while", - "body": ["while($2){", "\t", "}"], - "description": "while(){\n\t//code\n}\n\nThe keyword while is used to describe a loop that is controlled by a condition. The parentheses enclose the expression that defines the condition. The body defined by curly braces encloses the statements that are executed at each pass of the loop.\n\nwhile(i <= 99){\n\taFunction();\n}\n\nThe execution of a single pass or the whole loop can be aborted by using a continue or a break statement respectively." - }, - - "dowhile": { - "prefix": "dowhile", - "body": ["do{", "\t", "} while($2){", "\t", "}"], - "description": "do {\n\t//code\n}while();\n\nThe keyword do is used in combination with while to describe a loop that is controlled by a condition. The body defined by curly braces encloses the statements that are executed at each pass of the loop. The parentheses enclose the expression that defines the condition.\n\ndo {\n\taFunction();\n} while(i <= 99);\n\nThe execution of a single pass or the whole loop can be aborted by using a continue or a break statement respectively.\n\nIn contrast to a simple while loop the body is always executed at least one time even if the expression evaluates to false from the beginning." - }, - - "continue": { - "prefix": "continue", - "body": "continue;", - "description": "The keyword continue is used inside the body of a loop to abort a single pass of the loop. All statements in the body after the continue statement are ignored and the next iteration of the loop is executed immediately." - }, - - "break": { - "prefix": "break", - "body": "break;", - "description": "The keyword break is used inside the body of a loop to abort the whole loop. All statements in the body after the break statement are ignored and the loop is exited without executing any further iteration." - }, - - "if": { - "prefix": "if", - "body": ["if($2){", "\t", "}"], - "description": "if(){\n\t//code\n}\n\nThe keyword if is used to describe the conditional execution of a statement. The parentheses enclose the expression that defines the condition. The curly braces enclose the statements that are executed if the condition evaluates as true.\n\nif(i != 0){\n\taFunction();\n}\n\nIn contrast to a loop the statements in curly braces are executed only one time or not at all." - }, - - "ifelse": { - "prefix": "ifelse", - "body": ["if($2){", "\t", "} else {", "\t", "}"], - "description": "if(){\n\t//code\n} else {\n\t//code\n}\n\nThe keyword else is used in conjunction with the keyword if to describe the alternative execution of a statement. The parentheses enclose the expression that defines the condition. The curly braces after the if statement enclose the statements that are executed if the condition evaluates as true. The curly braces after the else statement enclose the statements that are executed if the condition evaluates as false.\n\nif(i != 0){\n\taFunction();\n} else {\n\tbFunction();\n}\n\nDepending on the condition either the statements in the first curly braces or the statements in the second curly braces are executed." - }, - - "ifdef": { - "prefix": "ifdef", - "body": ["#ifdef GL_ES", "precision mediump float;", "#endif"], - "description": "A check defining if GLES is available" - }, - - "return": { - "prefix": "return", - "body": "return;", - "description": "The keyword return is used to define a proper exit for a function. If the function has the return type void no value is passed back to the caller of the function.\n\nreturn aValue;\n\nIf the function has a non-void return type a parameter of the same type has to be included in the statement. The value is passed back to the caller of the function." - }, - - "discard": { - "prefix": "discard", - "body": "discard;", - "description": "The keyword discard is used to define an exceptionally exit for a fragment shader. It is used exit the fragment shader immediately and to signal the OpenGL ES 2.0 pipeline that the respective fragment should not be drawn." - }, - - "vec2": { - "prefix": "vec2", - "body": "vec2($2, $3)", - "description": "The data type vec2 is used for floating point vectors with two components. There are several ways to initialize a vector:\n• Components are specified by providing a scalar value for each component (first example).\n• Components are specified by providing one scalar value. This value is used for all components (the second example is equivalent to the first).\n• Components are specified by providing a vector of higher dimension. The respective values are used to initialize the components (the second and third example are equivalent).\n\nSide note: The vector constructors can be used to cast between different vector types since type conversions are done automatically for each component." - }, - - "vec3": { - "prefix": "vec3", - "body": "vec3($2, $3, $4)", - "description": "The data type vec3 is used for floating point vectors with three components. There are several ways to initialize a vector:\n• Components are specified by providing a scalar value for each component (first example).\n• Components are specified by providing one scalar value. This value is used for all components (the second example is equivalent to the first).\nComponents are specified by providing a vector of higher dimension. The respective values are used to initialize the components (the second and third example are equivalent).• Components are specified by providing a combination of vectors and/or scalars. The respective values are used to initialize the vector (the fifth and sixth example are equivalent). The arguments of the constructor must have at least as many components as the vector that is initialized.\n\nSide note: The vector constructors can be used to cast between different vector types since type conversions are done automatically for each component." - }, - - "vec4": { - "prefix": "vec4", - "body": "vec4($2, $3, $4, $5)", - "description": "The data type vec4 is used for floating point vectors with four components. There are several ways to initialize a vector:\n• Components are specified by providing a scalar value for each component (first example).\n• Components are specified by providing one scalar value. This value is used for all components (the second example is equivalent to the first).\n• Components are specified by providing a combination of vectors and scalars. The respective values are used to initialize the components (the third and fourth example are equivalent). The arguments of the constructor must have at least as many components as the vector that is initialized.\n\nSide note: The vector constructors can be used to cast between different vector types since type conversions are done automatically for each component." - }, - - "mat2": { - "prefix": "mat2", - "body": "mat2($2, $3)", - "description": "The data type mat2 is used for floating point matrices with two times two components in column major order. There are several ways to initialize a matrix:\n• Components are specified by providing a scalar value for each component (first example). The matrix is filled column by column.\n• Components are specified by providing one scalar value. This value is used for the components on the main diagonal (the second example is equivalent to the first).\n• Components are specified by providing a combination of vectors and scalars. The respective values are used to initialize the components column by column. The arguments of the constructor must have at least as many components as the matrix that is initialized." - }, - - "mat3": { - "prefix": "mat3", - "body": "mat3($2, $3, $4)", - "description": "The data type mat3 is used for floating point matrices with three times three components in column major order. There are several ways to initialize a matrix:\n• Components are specified by providing a scalar value for each component (first example). The matrix is filled column by column.\n• Components are specified by providing one scalar value. This value is used for the components on the main diagonal (the second example is equivalent to the first).\n• Components are specified by providing a combination of vectors and scalars. The respective values are used to initialize the components column by column. The arguments of the constructor must have at least as many components as the matrix that is initialized." - }, - - "mat4": { - "prefix": "mat4", - "body": "mat4($2, $3, $4, $5)", - "description": "The data type mat4 is used for floating point matrices with four times four components in column major order. There are several ways to initialize a matrix:\n• Components are specified by providing a scalar value for each component (first example). The matrix is filled column by column.\n• Components are specified by providing one scalar value. This value is used for the components on the main diagonal (the second example is equivalent to the first).\n• Components are specified by providing a combination of vectors and scalars. The respective values are used to initialize the components column by column. The arguments of the constructor must have at least as many components as the matrix that is initialized." - }, - - "sampler2D": { - "prefix": "sampler2D", - "body": "uniform sampler2D ${NAME};", - "description": "uniform sampler2D texture;\n\nThe data type sampler2D is used to provide access to a 2D texture. It can only be declared as a uniform variable since it is a reference to data that has been loaded to a texture unit.\n\nSide note: On iOS devices this data type can only be used in the fragment shader since they don't have texture image units that can be accessed by the vertex shader." - }, - - "samplerCube": { - "prefix": "samplerCube", - "body": "uniform samplerCube ${NAME};", - "description": "uniform samplerCube texture;\n\nThe data type samplerCube is used to provide access to a cubemap texture. It can only be declared as a uniform variable since it is a reference to data that has been loaded to a texture unit.\n\nSide note: On iOS devices this data type can only be used in the fragment shader since they don't have texture image units that can be accessed by the vertex shader." - }, - - "sin": { - "prefix": "sin", - "body": "sin($2)", - "description": "float sin(float angle)\nvec2 sin(vec2 angle)\nvec3 sin(vec3 angle)\nvec4 sin(vec4 angle)\n\nThe sin function returns the sine of an angle in radians. The input parameter can be a floating scalar or a float vector. In case of a float vector the sine is calculated separately for every component." - }, - - "asin": { - "prefix": "asin", - "body": "asin($2)", - "description": "float asin(float x)\nvec2 asin(vec2 x)\nvec3 asin(vec3 x)\nvec4 asin(vec4 x)\n\nThe asin function returns the arcsine of an angle in radians. It is the inverse function of sine. The input parameter can be a floating scalar or a float vector. In case of a float vector the arcsine is calculated separately for every component." - }, - - "asinh": { - "prefix": "asinh", - "body": "asinh($2)", - "description": "return the arc hyperbolic sine of the parameter - inverse of sinh" - }, - - "sinh": { - "prefix": "sinh", - "body": "sinh($2)", - "description": "return the hyperbolic sine of the parameter" - }, - - "cos": { - "prefix": "cos", - "body": "cos($2)", - "description": "float cos(float angle)\nvec2 cos(vec2 angle)\nvec3 cos(vec3 angle)\nvec4 cos(vec4 angle)\n\nThe cos function returns the cosine of an angle in radians. The input parameter can be a floating scalar or a float vector. In case of a float vector the cosine is calculated separately for every component." - }, - - "cosh": { - "prefix": "cosh", - "body": "cosh($2)", - "description": "return the hyperbolic cosine of the parameter" - }, - - "acos": { - "prefix": "acos", - "body": "acos($2)", - "description": "float acos(float x)\nvec2 acos(vec2 x)\nvec3 acos(vec3 x)\nvec4 acos(vec4 x)\n\nThe acos function returns the arccosine of an angle in radians. It is the inverse function of cosine. The input parameter can be a floating scalar or a float vector. In case of a float vector the arccosine is calculated separately for every component." - }, - - "acosh": { - "prefix": "acosh", - "body": "acosh($2)", - "description": "return the arc hyperbolic cosine of the parameter" - }, - - "tan": { - "prefix": "tan", - "body": "tan($2)", - "description": "float tan(float angle)\nvec2 tan(vec2 angle)\nvec3 tan(vec3 angle)\nvec4 tan(vec4 angle)\n\nThe tan function returns the tangent of an angle in radians. The input parameter can be a floating scalar or a float vector. In case of a float vector the tangent is calculated separately for every component." - }, - - "tanh": { - "prefix": "tanh", - "body": "tanh($2)", - "description": "return the hyperbolic tangent of the parameter" - }, - - "atan": { - "prefix": "atan", - "body": "atan($2, $3)", - "description": "float atan(float y_over_x)\nvec2 atan(vec2 y_over_x)\nvec3 atan(vec3 y_over_x)\nvec4 atan(vec4 y_over_x)\n\nThe atan function returns the arctangent of an angle in radians. It is the inverse function of tangent. The input parameter can be a floating scalar or a float vector. In case of a float vector the arctangent is calculated separately for every component.\n\nfloat atan(float y, float x)\nvec2 atan(vec2 y, vec2 x)\nvec3 atan(vec3 y, vec3 x)\nvec4 atan(vec4 y, vec4 x)\n\nThere is also a two-argument variation of the atan function (in other programming languages often called atan2). For a point with Cartesian coordinates (x, y) the function returns the angle θ of the same point with polar coordinates (r, θ)." - }, - - "radians": { - "prefix": "radians", - "body": "radians($2)", - "description": "float radians(float degrees)\nvec2 radians(vec2 degrees)\nvec3 radians(vec3 degrees)\nvec4 radians(vec4 degrees)\n\nThe radians function converts degrees to radians. The input parameter can be a floating scalar or a float vector. In case of a float vector all components are converted from degrees to radians separately." - }, - - "degrees": { - "prefix": "degrees", - "body": "degrees($2)", - "description": "float degrees(float radians)\nvec2 degrees(vec2 radians)\nvec3 degrees(vec3 radians)\nvec4 degrees(vec4 radians)\n\nThe degrees function converts radians to degrees. The input parameter can be a floating scalar or a float vector. In case of a float vector every component is converted from radians to degrees separately." - }, - - "pow": { - "prefix": "pow", - "body": "pow($2, $3)", - "description": "float pow(float x, float y)\nvec2 pow(vec2 x, vec2 y)\nvec3 pow(vec3 x, vec3 y)\nvec4 pow(vec4 x, vec4 y)\n\nThe power function returns x raised to the power of y. The input parameters can be floating scalars or float vectors. In case of float vectors the operation is done component-wise." - }, - - "exp": { - "prefix": "exp", - "body": "exp($2);", - "description": "float exp(float x)\nvec2 exp(vec2 x)\nvec3 exp(vec3 x)\nvec4 exp(vec4 x)\n\nThe exp function returns the constant e raised to the power of x. The input parameter can be a floating scalar or a float vector. In case of a float vector the operation is done component-wise." - }, - - "exp2": { - "prefix": "exp2", - "body": "exp2($2)", - "description": "float exp2(float x)\nvec2 exp2(vec2 x)\nvec3 exp2(vec3 x)\nvec4 exp2(vec4 x)\n\nThe exp2 function returns 2 raised to the power of x. The input parameter can be a floating scalar or a float vector. In case of a float vector the operation is done component-wise." - }, - - "ldexp": { - "prefix": "ldexp", - "body": "ldexp($2, $3)", - "description": "assemble a floating point number from a value and exponent" - }, - - "frexp": { - "prefix": "frexp", - "body": "frexp($2, $3)", - "description": "split a floating point number" - }, - - "log": { - "prefix": "log", - "body": "log($2)", - "description": "float log(float x)\nvec2 log(vec2 x)\nvec3 log(vec3 x)\nvec4 log(vec4 x)\n\nThe log function returns the power to which the constant e has to be raised to produce x. The input parameter can be a floating scalar or a float vector. In case of a float vector the operation is done component-wise." - }, - - "log2": { - "prefix": "log2", - "body": "log2($2)", - "description": "float log2(float x)\nvec2 log2(vec2 x)\nvec3 log2(vec3 x)\nvec4 log2(vec4 x)\n\nThe log2 function returns the power to which 2 has to be raised to produce x. The input parameter can be a floating scalar or a float vector. In case of a float vector the operation is done component-wise." - }, - - "sqrt": { - "prefix": "sqrt", - "body": "sqrt($2)", - "description": "float sqrt(float x)\nvec2 sqrt(vec2 x)\nvec3 sqrt(vec3 x)\nvec4 sqrt(vec4 x)\n\nThe sqrt function returns the square root of x. The input parameter can be a floating scalar or a float vector. In case of a float vector the operation is done component-wise." - }, - - "inversesqrt": { - "prefix": "inversesqrt", - "body": "inversesqrt($2)", - "description": "float inversesqrt(float x)\nvec2 inversesqrt(vec2 x)\nvec3 inversesqrt(vec3 x)\nvec4 inversesqrt(vec4 x)\n\nThe inversesqrt function returns the inverse square root of x, i.e. the reciprocal of the square root. The input parameter can be a floating scalar or a float vector. In case of a float vector the operation is done component-wise." - }, - - "abs": { - "prefix": "abs", - "body": "abs($2)", - "description": "float abs(float x)\nvec2 abs(vec2 x)\nvec3 abs(vec3 x)\nvec4 abs(vec4 x)\n\nThe abs function returns the absolute value of x, i.e. x when x is positive or zero and -x for negative x. The input parameter can be a floating scalar or a float vector. In case of a float vector the operation is done component-wise." - }, - - "ceil": { - "prefix": "ceil", - "body": "ceil($2)", - "description": "float ceil(float x)\nvec2 ceil(vec2 x)\nvec3 ceil(vec3 x)\nvec4 ceil(vec4 x)\n\nThe ceiling function returns the smallest number that is larger or equal to x. The input parameter can be a floating scalar or a float vector. In case of a float vector the operation is done component-wise.\n\nSide note: The return value is of type floating scalar or float vector although the result of the operation is an integer." - }, - - "clamp": { - "prefix": "clamp", - "body": "clamp($2, $3, $4)", - "description": "float clamp(float x, float minVal, float maxVal)\nvec2 clamp(vec2 x, vec2 minVal, vec2 maxVal)\nvec3 clamp(vec3 x, vec3 minVal, vec3 maxVal)\nvec4 clamp(vec4 x, vec4 minVal, vec4 maxVal)\n\nThe clamp function returns x if it is larger than minVal and smaller than maxVal. In case x is smaller than minVal, minVal is returned. If x is larger than maxVal, maxVal is returned. The input parameters can be floating scalars or float vectors. In case of float vectors the operation is done component-wise.\n\nfloat clamp(float x, float minVal, float maxVal)\nvec2 clamp(vec2 x, float minVal, float maxVal)\nvec3 clamp(vec3 x, float minVal, float maxVal)\nvec4 clamp(vec4 x, flfloat minVal, float maxVal)\n\nThere is also a variation of the clamp function where the second and third parameters are always a floating scalars." - }, - - "floor": { - "prefix": "floor", - "body": "floor($2)", - "description": "float floor(float x)\nvec2 floor(vec2 x)\nvec3 floor(vec3 x)\nvec4 floor(vec4 x)\n\nThe floor function returns the largest integer number that is smaller or equal to x. The input parameter can be a floating scalar or a float vector. In case of a float vector the operation is done component-wise.\n\nSide note: The return value is of type floating scalar or float vector although the result of the operation is an integer." - }, - - "equal": { - "prefix": "equal", - "body": "equal($2, $3)", - "description": "perform a component-wise equal-to comparison of two vectors" - }, - - "fract": { - "prefix": "fract", - "body": "fract($2)", - "description": "float fract(float x)\nvec2 fract(vec2 x)\nvec3 fract(vec3 x)\nvec4 fract(vec4 x)\n\nThe fract function returns the fractional part of x, i.e. x minus floor(x). The input parameter can be a floating scalar or a float vector. In case of a float vector the operation is done component-wise." - }, - - "min": { - "prefix": "min", - "body": "min($2, $3)", - "description": "float min(float x, float y)\nvec2 min(vec2 x, vec2 y)\nvec3 min(vec3 x, vec3 y)\nvec4 min(vec4 x, vec4 y)\n\nThe min function returns the smaller of the two arguments. The input parameters can be floating scalars or float vectors. In case of float vectors the operation is done component-wise.\nfloat min(float x, float y)\nvec2 min(vec2 x, float y)\nvec3 min(vec3 x, float y)\nvec4 min(vec4 x, float y)\n\nThere is also a variation of the min function where the second parameter is always a floating scalar." - }, - - "max": { - "prefix": "max", - "body": "max($2, $3)", - "description": "float max(float x, float y)\nvec2 max(vec2 x, vec2 y)\nvec3 max(vec3 x, vec3 y)\nvec4 max(vec4 x, vec4 y)\n\nThe max function returns the larger of the two arguments. The input parameters can be floating scalars or float vectors. In case of float vectors the operation is done component-wise.\n\nfloat max(float x, float y)\nvec2 max(vec2 x, float y)\nvec3 max(vec3 x, float y)\nvec4 max(vec4 x, float y)\n\nThere is also a variation of the max function where the second parameter is always a floating scalar." - }, - - "mix": { - "prefix": "mix", - "body": "mix($2, $3, $4)", - "description": "float mix(float x, float y, float a)\nvec2 mix(vec2 x, vec2 y, vec2 a)\nvec3 mix(vec3 x, vec3 y, vec3 a)\nvec4 mix(vec4 x, vec4 y, vec4 a)\n\nThe mix function returns the linear blend of x and y, i.e. the product of x and (1 - a) plus the product of y and a. The input parameters can be floating scalars or float vectors. In case of float vectors the operation is done component-wise.\n\nfloat mix(float x, float y, float a)\nvec2 mix(vec2 x, vec2 y, float a)\nvec3 mix(vec3 x, vec3 y, float a)\nvec4 mix(vec4 x, vec4 y, float a)\n\nThere is also a variation of the mix function where the third parameter is always a floating scalar." - }, - - "mod": { - "prefix": "mod", - "body": "mod($2, $3)", - "description": "float mod(float x, float y)\nvec2 mod(vec2 x, vec2 y)\nvec3 mod(vec3 x, vec3 y)\nvec4 mod(vec4 x, vec4 y)\n\nThe mod function returns x minus the product of y and floor(x/y). The input parameters can be floating scalars or float vectors. In case of float vectors the operation is done component-wise.\n\nSide note: If x and y are integers the return value is the remainder of the division of x by y as expected.\n\nfloat mod(float x, float y)\nvec2 mod(vec2 x, float y)\nvec3 mod(vec3 x, float y)\nvec4 mod(vec4 x, float y)\n\nThere is also a variation of the mod function where the second parameter is always a floating scalar." - }, - - "modf": { - "prefix": "modf", - "body": "modf($2, $3)", - "description": "separate a value into its integer and fractional components" - }, - - "sign": { - "prefix": "sign", - "body": "sign($2)", - "description": "float sign(float x)\nvec2 sign(vec2 x)\nvec3 sign(vec3 x)\nvec4 sign(vec4 x)\n\nThe sign function returns 1.0 when x is positive, 0.0 when x is zero and -1.0 when x is negative. The input parameter can be a floating scalar or a float vector. In case of a float vector the operation is done component-wise." - }, - - "step": { - "prefix": "step", - "body": "step($2, $3)", - "description": "float step(float edge, float x)\nvec2 step(vec2 edge, vec2 x)\nvec3 step(vec3 edge, vec3 x)\nvec4 step(vec4 edge, vec4 x)\n\nThe step function returns 0.0 if x is smaller then edge and otherwise 1.0. The input parameters can be floating scalars or float vectors. In case of float vectors the operation is done component-wise.\n\nfloat step(float edge, float x)\nvec2 step(float edge, vec2 x)\nvec3 step(float edge, vec3 x)\nvec4 step(float edge, vec4 x)\n\nThere is also a variation of the step function where the edge parameter is always a floating scalar." - }, - - "smoothstep": { - "prefix": "smoothstep", - "body": "smoothstep($2, $3, $4)", - "description": "float smoothstep(float edge0, float edge1, float x)\nvec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x)\nvec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x)\nvec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x)\n\nThe smoothstep function returns 0.0 if x is smaller then edge0 and 1.0 if x is larger than edge1. Otherwise the return value is interpolated between 0.0 and 1.0 using Hermite polynomials. The input parameters can be floating scalars or float vectors. In case of float vectors the operation is done component-wise.\n\nfloat smoothstep(float edge0, float edge1, float x)\nvec2 smoothstep(float edge0, float edge1, vec2 x)\nvec3 smoothstep(float edge0, float edge1, vec3 x)\nvec4 smoothstep(float edge0, float edge1, vec4 x)\n\nThere is also a variation of the smoothstep function where the edge0 and edge1 parameters are always floating scalars." - }, - - "cross": { - "prefix": "cross", - "body": "cross($2, $3, $4)", - "description": "vec3 cross(vec3 x, vec3 y)\n\nThe cross function returns the cross product of the two input parameters, i.e. a vector that is perpendicular to the plane containing x and y and has a magnitude that is equal to the area of the parallelogram that x and y span. The input parameters can only be 3-component floating vectors. The cross product is equivalent to the product of the length of the vectors times the sinus of the(smaller) angle between x and y." - }, - - "distance": { - "prefix": "distance", - "body": "distance($2, $3)", - "description": "float distance(float p0, float p1)\nfloat distance(vec2 p0, vec2 p1)\nfloat distance(vec3 p0, vec3 p1)\nfloat distance(vec4 p0, vec4 p1)\n\nThe distance function returns the distance between two points. The distance of two points is the length of the vector d = p0 - p1, that starts at p1 and points to p0. The input parameters can be floating scalars or float vectors. In case of floating scalars the distance function is trivial and returns the absolute value of d." - }, - - "dot": { - "prefix": "dot", - "body": "dot($2, $3)", - "description": "float dot(float x, float y)\nfloat dot(vec2 x, vec2 y)\nfloat dot(vec3 x, vec3 y)\nfloat dot(vec4 x, vec4 y)\n\nThe dot function returns the dot product of the two input parameters, i.e. the sum of the component-wise products. If x and y are the same the square root of the dot product is equivalent to the length of the vector. The input parameters can be floating scalars or float vectors. In case of floating scalars the dot function is trivial and returns the product of x and y." - }, - - "faceforward": { - "prefix": "faceforward", - "body": "faceforward($2, $3, $4)", - "description": "float faceforward(float N, float I, float Nref)\nvec2 faceforward(vec2 N, vec2 I, vec2 Nref)\nvec3 faceforward(vec3 N, vec3 I, vec3 Nref)\nvec4 faceforward(vec4 N, vec4 I, vec4 Nref)\n\nThe faceforward function returns a vector that points in the same direction as a reference vector. The function has three input parameters of the type floating scalar or float vector: N, the vector to orient, I, the incident vector, and Nref, the reference vector. If the dot product of I and Nref is smaller than zero the return value is N. Otherwise -N is returned." - }, - - "length": { - "prefix": "length", - "body": "length($2)", - "description": "float length(float x)\nfloat length(vec2 x)\nfloat length(vec3 x)\nfloat length(vec4 x)\n\nThe length function returns the length of a vector defined by the Euclidean norm, i.e. the square root of the sum of the squared components. The input parameter can be a floating scalar or a float vector. In case of a floating scalar the length function is trivial and returns the absolute value." - }, - - "normalize": { - "prefix": "normalize", - "body": "normalize($2)", - "description": "float normalize(float x)\nvec2 normalize(vec2 x)\nvec3 normalize(vec3 x)\nvec4 normalize(vec4 x)\n\nThe normalize function returns a vector with length 1.0 that is parallel to x, i.e. x divided by its length. The input parameter can be a floating scalar or a float vector. In case of a floating scalar the normalize function is trivial and returns 1.0." - }, - - "reflect": { - "prefix": "reflect", - "body": "reflect($2, $3)", - "description": "float reflect(float I, float N)\nvec2 reflect(vec2 I, vec2 N)\nvec3 reflect(vec3 I, vec3 N)\nvec4 reflect(vec4 I, vec4 N)\n\nThe reflect function returns a vector that points in the direction of reflection. The function has two input parameters of the type floating scalar or float vector: I, the incident vector, and N, the normal vector of the reflecting surface.\n\nSide note: To obtain the desired result the vector N has to be normalized. The reflection vector always has the same length as the incident vector. From this it follows that the reflection vector is normalized if N and I are both normalized." - }, - - "refract": { - "prefix": "refract", - "body": "refract($2, $3, $4)", - "description": "float refract(float I, float N, float eta)\nvec2 refract(vec2 I, vec2 N, float eta)\nvec3 refract(vec3 I, vec3 N, float eta)\nvec4 refract(vec4 I, vec4 N, float eta)\n\nThe refract function returns a vector that points in the direction of refraction. The function has two input parameters of the type floating scalar or float vector and one input parameter of the type floating scalar: I, the incident vector, N, the normal vector of the refracting surface, and eta, the ratio of indices of refraction.\n\nSide note: To obtain the desired result the vectors I and N have to be normalized." - }, - - "trunc": { - "prefix": "trunc", - "body": "trunc($2)", - "description": "find the nearest integer less than or equal to the parameter" - }, - - "round": { - "prefix": "round", - "body": "round($2)", - "description": "find the nearest integer less than or equal to the parameter - The fraction 0.5 will round in a direction chosen by the implementation, presumably the direction that is fastest. This includes the possibility that round(x) returns the same value as roundEven(x) for all values of x" - }, - - "roundEven": { - "prefix": "roundEven", - "body": "roundEven($2)", - "description": "find the nearest even integer to the parameter - The fractional part of 0.5 will round toward the nearest even integer. For example, both 3.5 and 4.5 will round to 4.0." - }, - - "const": { - "prefix": "const", - "body": "const", - "description": "The qualifier const is used for variables that are compile-time constants or for function parameters that are read-only." - }, - - "attribute": { - "prefix": "attribute", - "body": "attribute", - "description": "The qualifier attribute is used to declare variables that are shared between a vertex shader and the OpenGL ES environment.\nSince the vertex shader is executed one time for each vertex attributes are used to specify per vertex data. They typically provide data such as the object space position, the normal direction and the texture coordinates of a vertex. Attributes are read-only variables, i.e. their value can not be changed in the vertex shader.\nSide note: Since an attribute is never initialized in the shader it has to be loaded with data by the application executing the shader." - }, - - "uniform": { - "prefix": "uniform", - "body": "uniform", - "description": "The qualifier uniform is used to declare variables that are shared between a shader and the OpenGL ES environment.\nUniforms can be used in the vertex shader and the fragment shader and they must have global scope. The same uniform variable can be used in the vertex and the fragment shader, but since both shaders share the same name space the declaration has to be identical. Uniforms are used to specify properties of the object that is rendered. Examples are the projection matrix, the light position or the material color of the object. Uniforms are read-only variables, i.e. their value can not be changed in the shader.\nSide note: Since a uniform is never initialized in the shader it has to be loaded with data by the application executing the shader." - }, - - "varying": { - "prefix": "varying", - "body": "varying", - "description": "The qualifier varying is used to declare variables that are shared between the vertex shader and the fragment shader.\nVarying are used for information that is calculated in the vertex shader and should be handed over to the fragment shader. Both shaders have to declare the varying and the declarations must be identical. The vertex shader initializes the varying for each vertex. After that the per vertex data of the varying is interpolated during rasterization before being handed over to the fragment shader.\nThe varying qualifier can only be used with floating point scalar, floating point vectors and (floating point) matrices as well as arrays containing these types." - }, - - "highp": { - "prefix": "highp", - "body": "highp", - "description": "The qualifier highp is used to specify the highest available precision for a variable. The variable has to be an integer or a floating point scalar or a vector or matrix based on these types. The precision qualifier precedes the type in the variable declaration.\nIn the vertex shader the use of a precision qualifier is optional. If no qualifier is given all variables are of highest precision. In the fragment shader a precision qualifier has to be used when declaring a variable unless a default precision has been defined for the specific type.\n\nuniform highp vec3 lightDirection;\n\nThe actual range corresponding to a precision qualifier is dependent on the specific OpenGL ES implementation. Using a lower precision might have a positive effect on performance (frame rates) and power efficiency but might also cause a loss in rendering quality. The appropriate trade-off can only be determined by testing different precision configurations." - }, - - "mediump": { - "prefix": "mediump", - "body": "mediump", - "description": "The qualifier mediump is used to specify a precision between the highest and lowest available precision for a variable. The variable has to be an integer or a floating point scalar or a vector or matrix based on these types. The precision qualifier precedes the type in the variable declaration.\nIn the vertex shader the use of a precision qualifier is optional. If no qualifier is given all variables are of highest precision. In the fragment shader a precision qualifier has to be used when declaring a variable unless a default precision has been defined for the specific type.\n\nvarying mediump vec2 textureCoordinate;\n\nThe actual range corresponding to a precision qualifier is dependent on the specific OpenGL ES implementation. Using a lower precision might have a positive effect on performance (frame rates) and power efficiency but might also cause a loss in rendering quality. The appropriate trade-off can only be determined by testing different precision configurations." - }, - - "lowp": { - "prefix": "lowp", - "body": "lowp", - "description": "The qualifier lowp is used to specify the lowest available precision for a variable. The variable has to be an integer or a floating point scalar or a vector or matrix based on these types. The precision qualifier precedes the type in the variable declaration.\nIn the vertex shader the use of a precision qualifier is optional. If no qualifier is given all variables are of highest precision. In the fragment shader a precision qualifier has to be used when declaring a variable unless a default precision has been defined for the specific type.\n\nvarying lowp vec4 colorVarying;\n\nThe actual range corresponding to a precision qualifier is dependent on the specific OpenGL ES implementation. Using a lower precision might have a positive effect on performance (frame rates) and power efficiency but might also cause a loss in rendering quality. The appropriate trade-off can only be determined by testing different precision configurations." - }, - - "precision": { - "prefix": "precision", - "body": "precision", - "description": "The keyword precision is used in conjunction with a precision qualifier and a data type to specify the default precision for that data type. The type has to be an integer or a floating point scalar or a vector or matrix based on these types.\nIn the vertex shader all variables are of highest precision by default. The default can be changed defining another default precision. In the fragment shader a precision qualifier has to be used when declaring a variable unless a default precision has been defined for the specific type.\n\nprecision highp float;\n\nThe actual range corresponding to a precision qualifier is dependent on the specific OpenGL ES implementation. Using a lower precision might have a positive effect on performance (frame rates) and power efficiency but might also cause a loss in rendering quality. The appropriate trade-off can only be determined by testing different precision configurations." - }, - - "in": { - "prefix": "in", - "body": "in", - "description": "The qualifier in is used to mark a parameter as read-only when a function is declared. The parameter will be passed by value to the function and the value can not be modified by the function.\nThe above function declaration shows the three possible parameter qualifiers. The usage of the read-only qualifier is not necessary since this is the default if no qualifier is specified." - }, - - "out": { - "prefix": "out", - "body": "out", - "description": "The qualifier out is used to mark a parameter as write-only when a function is declared. The parameter will be passed by reference to the function but it is not initialized, i.e. the value can not be read. The value can be modified by the function and the changes are preserved after the function exits.\nThe above function declaration shows the three possible parameter qualifiers. The usage of the read-only qualifier is not necessary since this is the default if no qualifier is specified." - }, - - "inout": { - "prefix": "inout", - "body": "inout", - "description": "The qualifier inout is used to mark a parameter as read-write when a function is declared. The parameter will be passed by reference to the function and is initialized, i.e. the value can be read. The value can be modified by the function and the changes are preserved after the function exits.\nThe above function declaration shows the three possible parameter qualifiers. The usage of the read-only qualifier is not necessary since this is the default if no qualifier is specified." - }, - - "gl_FragCoord": { - "prefix": "gl_FragCoord", - "body": "gl_FragCoord", - "description": "mediump vec4 gl_FragCoord;\n\nbool gl_FrontFacing;\n\nThe built-in variable gl_FragCoord is used by the OpenGL ES 2.0 pipeline to hand over the coordinates of the fragment to the fragment shader. The variable is read-only and the value is assigned by the OpenGL ES 2.0 pipeline.\nThe values of the fragment coordinate vector are given in the window coordinate system." - }, - - "gl_FrontFacing": { - "prefix": "gl_FrontFacing", - "body": "gl_FrontFacing", - "description": "The built-in variable gl_FrontFacing is used by the OpenGL ES 2.0 pipeline to hand over the information to the fragment shader if the fragment is part of a front-facing primitive (triangle). The variable is read-only and the value is assigned by the OpenGL ES 2.0 pipeline.\nThe front-facing variable has a boolean value." - }, - - "gl_PointCoord": { - "prefix": "gl_PointCoord", - "body": "gl_PointCoord", - "description": "mediump int gl_PointCoord;\n\nThe built-in variable gl_PointCoord is used by the OpenGL ES 2.0 pipeline to hand over the coordinates of a point sprite to the fragment shader. The variable is read-only and the value is calculated and assigned by the OpenGL ES 2.0 pipeline based on the position and radius of the point sprite.\nSide note: A value for this variable is provided by the OpenGL ES 2.0 pipeline only if the rendered primitives are points." - }, - - "gl_FragColor": { - "prefix": "gl_FragColor", - "body": "gl_FragColor", - "description": "mediump vec4 gl_FragColor;\n\nThe built-in variable gl_FragColor is used by the fragment shader to hand over the color of the fragment to the OpenGL ES 2.0 pipeline. The variable is pre-declared as shown above that way the variable can be used in the fragment shader for an assignment without prior declaration.\nThe values of the color vector are interpreted in the RGBA color space.\nThe assignment of values to this variable is mandatory for the fragment shader." - }, - - "gl_MaxTextureImageUnits": { - "prefix": "gl_MaxTextureImageUnits", - "body": "gl_MaxTextureImageUnits", - "description": "const mediump int gl_MaxTextureImageUnits >= 8\n\nThe built-in constant gl_MaxTextureImageUnits provides the maximum number of texture units that can be used by the fragment shader. The value of this variable is dependent on the OpenGL ES 2.0 implementation but has to be at least 8." - }, - - "gl_MaxFragmentUniformVectors": { - "prefix": "gl_MaxFragmentUniformVectors", - "body": "gl_MaxFragmentUniformVectors", - "description": "const mediump int gl_MaxFragmentUniformVectors >= 16\n\nThe built-in constant gl_MaxFragmentUniformVectors provides the maximum number of uniform vectors that can be used by the fragment shader. The value of this variable is dependent on the OpenGL ES 2.0 implementation but has to be at least 16." - }, - - "gl_MaxDrawBuffers": { - "prefix": "gl_MaxDrawBuffers", - "body": "gl_MaxDrawBuffers", - "description": "const mediump int gl_MaxDrawBuffers = 1\n\nThe built-in constant gl_MaxDrawBuffers provides the maximum number of the available draw buffers. The value of this variable is 1 for all OpenGL ES 2.0 implementations." - }, - - "function float": { - "prefix": "float", - "body": ["float ${NAME}(){", "\t", "}"], - "description": "A standard function that would need a return of a float value for it to work" - }, - - "function void": { - "prefix": "void", - "body": ["void ${NAME}(){", "\t", "}"], - "description": "A standard function that can be named whatever you so wish" - }, - - "function main": { - "prefix": "void main", - "body": ["void main(){", "\t", "}"], - "description": "void main(void){\n\t//code\n}\n\nThe keyword main is used to define the main function of a shader. This function is the entry point for the execution of every vertex and fragment shader. The main function takes no parameters and does not return a value." - }, - - "void": { - "prefix": "void", - "body": "void main(void);", - "description": "void main(void);\nint aFunction(void);\nvoid bFunction(float);\n\nThe data type void is used when the parameter list of a function is empty and when a function does not return a value." - }, - - "int": { - "prefix": "int", - "body": "int ${NAME} = $3;", - "description": "int aInt = 42;\nint bInt = int(aBool);\nint cInt = int(aFloat);\n\nThe data type int is used for integer values.\n\nSide note: Implicit type conversions are not supported. Type conversions can be done using constructors as shown in the second and third example." - }, - - "float": { - "prefix": "float", - "body": "float ${NAME} = $3;", - "description": "float aFloat = 1.0;\nfloat bFloat = float(aBool);\nfloat cFloat = float(aInt);\n\nThe data type bool is used for boolean values (true or false).\n\nSide note: Implicit type conversions are not supported. Type conversions can be done using constructors as shown in the second and third example." - }, - - "bool": { - "prefix": "bool", - "body": "bool ${NAME} = $3;", - "description": "bool aBool = true;\nbool bBool = bool(aInt);\nbool cBool = bool(aFloat);\n\nThe data type bool is used for boolean values (true or false).\n\nSide note: Implicit type conversions are not supported. Type conversions can be done using constructors as shown in the second and third example." - }, - - "texture2D": { - "prefix": "texture2D", - "body": "texture2D", - "description": "vec4 texture2D(sampler2D sampler, vec2 coord)\nvec4 texture2D(sampler2D sampler, vec2 coord, float bias)\n\nThe texture2D function returns a texel, i.e. the (color) value of the texture for the given coordinates. The function has one input parameter of the type sampler2D and one input parameter of the type vec2 : sampler, the uniform the texture is bound to, and coord, the 2-dimensional coordinates of the texel to look up.\n\nThere is an optional third input parameter of the type float: bias. After calculating the appropriate level of detail for a texture with mipmaps the bias is added before the actual texture lookup operation is executed.\n\nSide note: On iOS devices texture lookup functionality is only available in the fragment shader." - }, - - "textureCube": { - "prefix": "textureCube", - "body": "textureCube", - "description": "vec4 textureCube(samplerCube sampler, vec3 coord)\nvec4 textureCube(samplerCube sampler, vec3 coord, float bias)\n\nThe textureCube function returns a texel, i.e. the (color) value of the texture for the given coordinates. The function has one input parameter of the type samplerCube and one input parameter of the type vec3 : sampler, the uniform the texture is bound to, and coord, the 3-dimensional coordinates of the texel to look up.\n\nThere is an optional third input parameter of the type float: bias. After calculating the appropriate level of detail for a texture with mipmaps the bias is added before the actual texture lookup operation is executed.\n\nSide note: On iOS devices texture lookup functionality is only available in the fragment shader." - }, - - "PI": { - "prefix": "PI", - "body": ["const float PI = 3.14159265359;"], - "description": "PI setup" - }, - - "random2d": { - "prefix": "random2d", - "body": [ - "float random2d(vec2 coord){", - "\treturn fract(sin(dot(coord.xy, vec2(12.9898, 78.233))) * 43758.5453);", - "}" - ], - "description": "random 2d function" - }, - - "noise1d": { - "prefix": "noise1d", - "body": [ - "float noise1d(float v){", - "\treturn cos(v + cos(v * 90.1415) * 100.1415) * 0.5 + 0.5;", - "}" - ], - "description": "noise1d function" - }, - - "simple setup": { - "prefix": "simple setup", - "body": [ - "#ifdef GL_ES", - "precision mediump float;", - "#endif", - "", - "uniform float u_time;", - "uniform vec2 u_resolution;", - "uniform vec2 u_mouse;", - "", - "void main(){", - "\tvec2 coord = gl_FragCoord.xy;", - "\tvec3 color = vec3(0.0);", - "", - "\tgl_FragColor = vec4(color, 1.0);", - "}" - ], - "description": "Starter code including 'ifdef' check, u_ methods & the main" - }, - - "circle shape": { - "prefix": "circle shape", - "body": [ - "float ${NAME}(vec2 position, float radius){", - "\treturn step(radius, length(position - vec2(0.5)));", - "}" - ], - "description": "circle shape" - }, - - "rectangle shape": { - "prefix": "rectangle shape", - "body": [ - "float ${NAME}(vec2 position, vec2 scale){", - "\tscale = vec2(0.5) - scale * 0.5;", - "\tvec2 shaper = vec2(step(scale.x, position.x), step(scale.y, position.y));", - "\tshaper *= vec2(step(scale.x, 1.0 - position.x), step(scale.y, 1.0 - position.y));", - "\treturn shaper.x * shaper.y;", - "}" - ], - "description": "rectangle shape" - }, - - "polygon shape": { - "prefix": "polygon shape", - "body": [ - "float ${NAME}(vec2 position, float radius, float sides){", - "\tposition = position * 2.0 - 1.0;", - "\tfloat angle = atan(position.x, position.y);", - "\tfloat slice = PI * 2.0 / sides;", - "\treturn step(radius, cos(floor(0.5 + angle / slice) * slice - angle) * length(position));", - "}" - ], - "description": "polygon shape" - }, - - "scale": { - "prefix": "scale", - "body": [ - "mat2 scale(vec2 scale){", - "\treturn mat2(scale.x, 0.0, 0.0, scale.y);", - "}" - ], - "description": "scale" - }, - - "rotate": { - "prefix": "rotate", - "body": [ - "mat2 rotate(float angle){", - "\treturn mat2(cos(angle), -sin(angle), sin(angle), cos(angle));", - "}" - ], - "description": "rotate" - }, - - "random": { - "prefix": "random", - "body": [ - "float random (vec2 st) {", - "\treturn fract(", - "\t\tsin(", - "\t\t\tdot(", - "\t\t\t\tst.xy,", - "\t\t\t\tvec2(st.xy * 1000.0)", - "\t\t\t)", - "\t\t) * 1000.0", - "\t);", - "}" - ], - "description": "" - }, - - "function circleshape": { - "prefix": "circleshape", - "body": [ - "float circleshape(vec2 position, float radius) {", - "\treturn step(radius, length(position - vec2(0.5)));", - "}" - ], - "description": "A function that draw a circle from center." - }, - - "function polygonshape": { - "prefix": "polygonshape", - "body": [ - "float polygonshape(vec2 position, float radius, float sides) {", - "\tposition = position * 2.0 - 1.0;", - "\tfloat angle = atan(position.x, position.y); ", - "\tfloat slice = PI * 2.0 / sides; //外角度数", - "\treturn step(radius, cos(floor(0.5 + angle / slice) * slice - angle) * length(position));", - "}" - ], - "description": "A function that draw a polygon from center." - } + "for": { + "prefix": "for", + "body": ["for(int $2 = 0; $2 < $3; $2++){", "\t", "}"], + "description": "for( ; ; ){\n\t//code\n}\n\nThe keyword for is used to describe a loop that is controlled by a counter. The parentheses enclose three expressions that initialize, check and update the variable used as counter. The body defined by curly braces encloses the statements that are executed at each pass of the loop.\n\nfor(int i = 0; i <= 99; i++){\n\taFunction();\n}\n\nThe execution of a single pass or the whole loop can be aborted by using a continue or a break statement respectively." + }, + + "while": { + "prefix": "while", + "body": ["while($2){", "\t", "}"], + "description": "while(){\n\t//code\n}\n\nThe keyword while is used to describe a loop that is controlled by a condition. The parentheses enclose the expression that defines the condition. The body defined by curly braces encloses the statements that are executed at each pass of the loop.\n\nwhile(i <= 99){\n\taFunction();\n}\n\nThe execution of a single pass or the whole loop can be aborted by using a continue or a break statement respectively." + }, + + "dowhile": { + "prefix": "dowhile", + "body": ["do{", "\t", "} while($2){", "\t", "}"], + "description": "do {\n\t//code\n}while();\n\nThe keyword do is used in combination with while to describe a loop that is controlled by a condition. The body defined by curly braces encloses the statements that are executed at each pass of the loop. The parentheses enclose the expression that defines the condition.\n\ndo {\n\taFunction();\n} while(i <= 99);\n\nThe execution of a single pass or the whole loop can be aborted by using a continue or a break statement respectively.\n\nIn contrast to a simple while loop the body is always executed at least one time even if the expression evaluates to false from the beginning." + }, + + "continue": { + "prefix": "continue", + "body": "continue;", + "description": "The keyword continue is used inside the body of a loop to abort a single pass of the loop. All statements in the body after the continue statement are ignored and the next iteration of the loop is executed immediately." + }, + + "break": { + "prefix": "break", + "body": "break;", + "description": "The keyword break is used inside the body of a loop to abort the whole loop. All statements in the body after the break statement are ignored and the loop is exited without executing any further iteration." + }, + + "if": { + "prefix": "if", + "body": ["if($2){", "\t", "}"], + "description": "if(){\n\t//code\n}\n\nThe keyword if is used to describe the conditional execution of a statement. The parentheses enclose the expression that defines the condition. The curly braces enclose the statements that are executed if the condition evaluates as true.\n\nif(i != 0){\n\taFunction();\n}\n\nIn contrast to a loop the statements in curly braces are executed only one time or not at all." + }, + + "ifelse": { + "prefix": "ifelse", + "body": ["if($2){", "\t", "} else {", "\t", "}"], + "description": "if(){\n\t//code\n} else {\n\t//code\n}\n\nThe keyword else is used in conjunction with the keyword if to describe the alternative execution of a statement. The parentheses enclose the expression that defines the condition. The curly braces after the if statement enclose the statements that are executed if the condition evaluates as true. The curly braces after the else statement enclose the statements that are executed if the condition evaluates as false.\n\nif(i != 0){\n\taFunction();\n} else {\n\tbFunction();\n}\n\nDepending on the condition either the statements in the first curly braces or the statements in the second curly braces are executed." + }, + + "ifdef": { + "prefix": "ifdef", + "body": ["#ifdef GL_ES", "precision mediump float;", "#endif"], + "description": "A check defining if GLES is available" + }, + + "return": { + "prefix": "return", + "body": "return;", + "description": "The keyword return is used to define a proper exit for a function. If the function has the return type void no value is passed back to the caller of the function.\n\nreturn aValue;\n\nIf the function has a non-void return type a parameter of the same type has to be included in the statement. The value is passed back to the caller of the function." + }, + + "discard": { + "prefix": "discard", + "body": "discard;", + "description": "The keyword discard is used to define an exceptionally exit for a fragment shader. It is used exit the fragment shader immediately and to signal the OpenGL ES 2.0 pipeline that the respective fragment should not be drawn." + }, + + "vec2": { + "prefix": "vec2", + "body": "vec2($2, $3)", + "description": "The data type vec2 is used for floating point vectors with two components. There are several ways to initialize a vector:\n• Components are specified by providing a scalar value for each component (first example).\n• Components are specified by providing one scalar value. This value is used for all components (the second example is equivalent to the first).\n• Components are specified by providing a vector of higher dimension. The respective values are used to initialize the components (the second and third example are equivalent).\n\nSide note: The vector constructors can be used to cast between different vector types since type conversions are done automatically for each component." + }, + + "vec3": { + "prefix": "vec3", + "body": "vec3($2, $3, $4)", + "description": "The data type vec3 is used for floating point vectors with three components. There are several ways to initialize a vector:\n• Components are specified by providing a scalar value for each component (first example).\n• Components are specified by providing one scalar value. This value is used for all components (the second example is equivalent to the first).\nComponents are specified by providing a vector of higher dimension. The respective values are used to initialize the components (the second and third example are equivalent).• Components are specified by providing a combination of vectors and/or scalars. The respective values are used to initialize the vector (the fifth and sixth example are equivalent). The arguments of the constructor must have at least as many components as the vector that is initialized.\n\nSide note: The vector constructors can be used to cast between different vector types since type conversions are done automatically for each component." + }, + + "vec4": { + "prefix": "vec4", + "body": "vec4($2, $3, $4, $5)", + "description": "The data type vec4 is used for floating point vectors with four components. There are several ways to initialize a vector:\n• Components are specified by providing a scalar value for each component (first example).\n• Components are specified by providing one scalar value. This value is used for all components (the second example is equivalent to the first).\n• Components are specified by providing a combination of vectors and scalars. The respective values are used to initialize the components (the third and fourth example are equivalent). The arguments of the constructor must have at least as many components as the vector that is initialized.\n\nSide note: The vector constructors can be used to cast between different vector types since type conversions are done automatically for each component." + }, + + "mat2": { + "prefix": "mat2", + "body": "mat2($2, $3)", + "description": "The data type mat2 is used for floating point matrices with two times two components in column major order. There are several ways to initialize a matrix:\n• Components are specified by providing a scalar value for each component (first example). The matrix is filled column by column.\n• Components are specified by providing one scalar value. This value is used for the components on the main diagonal (the second example is equivalent to the first).\n• Components are specified by providing a combination of vectors and scalars. The respective values are used to initialize the components column by column. The arguments of the constructor must have at least as many components as the matrix that is initialized." + }, + + "mat3": { + "prefix": "mat3", + "body": "mat3($2, $3, $4)", + "description": "The data type mat3 is used for floating point matrices with three times three components in column major order. There are several ways to initialize a matrix:\n• Components are specified by providing a scalar value for each component (first example). The matrix is filled column by column.\n• Components are specified by providing one scalar value. This value is used for the components on the main diagonal (the second example is equivalent to the first).\n• Components are specified by providing a combination of vectors and scalars. The respective values are used to initialize the components column by column. The arguments of the constructor must have at least as many components as the matrix that is initialized." + }, + + "mat4": { + "prefix": "mat4", + "body": "mat4($2, $3, $4, $5)", + "description": "The data type mat4 is used for floating point matrices with four times four components in column major order. There are several ways to initialize a matrix:\n• Components are specified by providing a scalar value for each component (first example). The matrix is filled column by column.\n• Components are specified by providing one scalar value. This value is used for the components on the main diagonal (the second example is equivalent to the first).\n• Components are specified by providing a combination of vectors and scalars. The respective values are used to initialize the components column by column. The arguments of the constructor must have at least as many components as the matrix that is initialized." + }, + + "sampler2D": { + "prefix": "sampler2D", + "body": "uniform sampler2D ${NAME};", + "description": "uniform sampler2D texture;\n\nThe data type sampler2D is used to provide access to a 2D texture. It can only be declared as a uniform variable since it is a reference to data that has been loaded to a texture unit.\n\nSide note: On iOS devices this data type can only be used in the fragment shader since they don't have texture image units that can be accessed by the vertex shader." + }, + + "samplerCube": { + "prefix": "samplerCube", + "body": "uniform samplerCube ${NAME};", + "description": "uniform samplerCube texture;\n\nThe data type samplerCube is used to provide access to a cubemap texture. It can only be declared as a uniform variable since it is a reference to data that has been loaded to a texture unit.\n\nSide note: On iOS devices this data type can only be used in the fragment shader since they don't have texture image units that can be accessed by the vertex shader." + }, + + "sin": { + "prefix": "sin", + "body": "sin($2)", + "description": "float sin(float angle)\nvec2 sin(vec2 angle)\nvec3 sin(vec3 angle)\nvec4 sin(vec4 angle)\n\nThe sin function returns the sine of an angle in radians. The input parameter can be a floating scalar or a float vector. In case of a float vector the sine is calculated separately for every component." + }, + + "asin": { + "prefix": "asin", + "body": "asin($2)", + "description": "float asin(float x)\nvec2 asin(vec2 x)\nvec3 asin(vec3 x)\nvec4 asin(vec4 x)\n\nThe asin function returns the arcsine of an angle in radians. It is the inverse function of sine. The input parameter can be a floating scalar or a float vector. In case of a float vector the arcsine is calculated separately for every component." + }, + + "asinh": { + "prefix": "asinh", + "body": "asinh($2)", + "description": "return the arc hyperbolic sine of the parameter - inverse of sinh" + }, + + "sinh": { + "prefix": "sinh", + "body": "sinh($2)", + "description": "return the hyperbolic sine of the parameter" + }, + + "cos": { + "prefix": "cos", + "body": "cos($2)", + "description": "float cos(float angle)\nvec2 cos(vec2 angle)\nvec3 cos(vec3 angle)\nvec4 cos(vec4 angle)\n\nThe cos function returns the cosine of an angle in radians. The input parameter can be a floating scalar or a float vector. In case of a float vector the cosine is calculated separately for every component." + }, + + "cosh": { + "prefix": "cosh", + "body": "cosh($2)", + "description": "return the hyperbolic cosine of the parameter" + }, + + "acos": { + "prefix": "acos", + "body": "acos($2)", + "description": "float acos(float x)\nvec2 acos(vec2 x)\nvec3 acos(vec3 x)\nvec4 acos(vec4 x)\n\nThe acos function returns the arccosine of an angle in radians. It is the inverse function of cosine. The input parameter can be a floating scalar or a float vector. In case of a float vector the arccosine is calculated separately for every component." + }, + + "acosh": { + "prefix": "acosh", + "body": "acosh($2)", + "description": "return the arc hyperbolic cosine of the parameter" + }, + + "tan": { + "prefix": "tan", + "body": "tan($2)", + "description": "float tan(float angle)\nvec2 tan(vec2 angle)\nvec3 tan(vec3 angle)\nvec4 tan(vec4 angle)\n\nThe tan function returns the tangent of an angle in radians. The input parameter can be a floating scalar or a float vector. In case of a float vector the tangent is calculated separately for every component." + }, + + "tanh": { + "prefix": "tanh", + "body": "tanh($2)", + "description": "return the hyperbolic tangent of the parameter" + }, + + "atan": { + "prefix": "atan", + "body": "atan($2, $3)", + "description": "float atan(float y_over_x)\nvec2 atan(vec2 y_over_x)\nvec3 atan(vec3 y_over_x)\nvec4 atan(vec4 y_over_x)\n\nThe atan function returns the arctangent of an angle in radians. It is the inverse function of tangent. The input parameter can be a floating scalar or a float vector. In case of a float vector the arctangent is calculated separately for every component.\n\nfloat atan(float y, float x)\nvec2 atan(vec2 y, vec2 x)\nvec3 atan(vec3 y, vec3 x)\nvec4 atan(vec4 y, vec4 x)\n\nThere is also a two-argument variation of the atan function (in other programming languages often called atan2). For a point with Cartesian coordinates (x, y) the function returns the angle θ of the same point with polar coordinates (r, θ)." + }, + + "radians": { + "prefix": "radians", + "body": "radians($2)", + "description": "float radians(float degrees)\nvec2 radians(vec2 degrees)\nvec3 radians(vec3 degrees)\nvec4 radians(vec4 degrees)\n\nThe radians function converts degrees to radians. The input parameter can be a floating scalar or a float vector. In case of a float vector all components are converted from degrees to radians separately." + }, + + "degrees": { + "prefix": "degrees", + "body": "degrees($2)", + "description": "float degrees(float radians)\nvec2 degrees(vec2 radians)\nvec3 degrees(vec3 radians)\nvec4 degrees(vec4 radians)\n\nThe degrees function converts radians to degrees. The input parameter can be a floating scalar or a float vector. In case of a float vector every component is converted from radians to degrees separately." + }, + + "pow": { + "prefix": "pow", + "body": "pow($2, $3)", + "description": "float pow(float x, float y)\nvec2 pow(vec2 x, vec2 y)\nvec3 pow(vec3 x, vec3 y)\nvec4 pow(vec4 x, vec4 y)\n\nThe power function returns x raised to the power of y. The input parameters can be floating scalars or float vectors. In case of float vectors the operation is done component-wise." + }, + + "exp": { + "prefix": "exp", + "body": "exp($2);", + "description": "float exp(float x)\nvec2 exp(vec2 x)\nvec3 exp(vec3 x)\nvec4 exp(vec4 x)\n\nThe exp function returns the constant e raised to the power of x. The input parameter can be a floating scalar or a float vector. In case of a float vector the operation is done component-wise." + }, + + "exp2": { + "prefix": "exp2", + "body": "exp2($2)", + "description": "float exp2(float x)\nvec2 exp2(vec2 x)\nvec3 exp2(vec3 x)\nvec4 exp2(vec4 x)\n\nThe exp2 function returns 2 raised to the power of x. The input parameter can be a floating scalar or a float vector. In case of a float vector the operation is done component-wise." + }, + + "ldexp": { + "prefix": "ldexp", + "body": "ldexp($2, $3)", + "description": "assemble a floating point number from a value and exponent" + }, + + "frexp": { + "prefix": "frexp", + "body": "frexp($2, $3)", + "description": "split a floating point number" + }, + + "log": { + "prefix": "log", + "body": "log($2)", + "description": "float log(float x)\nvec2 log(vec2 x)\nvec3 log(vec3 x)\nvec4 log(vec4 x)\n\nThe log function returns the power to which the constant e has to be raised to produce x. The input parameter can be a floating scalar or a float vector. In case of a float vector the operation is done component-wise." + }, + + "log2": { + "prefix": "log2", + "body": "log2($2)", + "description": "float log2(float x)\nvec2 log2(vec2 x)\nvec3 log2(vec3 x)\nvec4 log2(vec4 x)\n\nThe log2 function returns the power to which 2 has to be raised to produce x. The input parameter can be a floating scalar or a float vector. In case of a float vector the operation is done component-wise." + }, + + "sqrt": { + "prefix": "sqrt", + "body": "sqrt($2)", + "description": "float sqrt(float x)\nvec2 sqrt(vec2 x)\nvec3 sqrt(vec3 x)\nvec4 sqrt(vec4 x)\n\nThe sqrt function returns the square root of x. The input parameter can be a floating scalar or a float vector. In case of a float vector the operation is done component-wise." + }, + + "inversesqrt": { + "prefix": "inversesqrt", + "body": "inversesqrt($2)", + "description": "float inversesqrt(float x)\nvec2 inversesqrt(vec2 x)\nvec3 inversesqrt(vec3 x)\nvec4 inversesqrt(vec4 x)\n\nThe inversesqrt function returns the inverse square root of x, i.e. the reciprocal of the square root. The input parameter can be a floating scalar or a float vector. In case of a float vector the operation is done component-wise." + }, + + "abs": { + "prefix": "abs", + "body": "abs($2)", + "description": "float abs(float x)\nvec2 abs(vec2 x)\nvec3 abs(vec3 x)\nvec4 abs(vec4 x)\n\nThe abs function returns the absolute value of x, i.e. x when x is positive or zero and -x for negative x. The input parameter can be a floating scalar or a float vector. In case of a float vector the operation is done component-wise." + }, + + "ceil": { + "prefix": "ceil", + "body": "ceil($2)", + "description": "float ceil(float x)\nvec2 ceil(vec2 x)\nvec3 ceil(vec3 x)\nvec4 ceil(vec4 x)\n\nThe ceiling function returns the smallest number that is larger or equal to x. The input parameter can be a floating scalar or a float vector. In case of a float vector the operation is done component-wise.\n\nSide note: The return value is of type floating scalar or float vector although the result of the operation is an integer." + }, + + "clamp": { + "prefix": "clamp", + "body": "clamp($2, $3, $4)", + "description": "float clamp(float x, float minVal, float maxVal)\nvec2 clamp(vec2 x, vec2 minVal, vec2 maxVal)\nvec3 clamp(vec3 x, vec3 minVal, vec3 maxVal)\nvec4 clamp(vec4 x, vec4 minVal, vec4 maxVal)\n\nThe clamp function returns x if it is larger than minVal and smaller than maxVal. In case x is smaller than minVal, minVal is returned. If x is larger than maxVal, maxVal is returned. The input parameters can be floating scalars or float vectors. In case of float vectors the operation is done component-wise.\n\nfloat clamp(float x, float minVal, float maxVal)\nvec2 clamp(vec2 x, float minVal, float maxVal)\nvec3 clamp(vec3 x, float minVal, float maxVal)\nvec4 clamp(vec4 x, flfloat minVal, float maxVal)\n\nThere is also a variation of the clamp function where the second and third parameters are always a floating scalars." + }, + + "floor": { + "prefix": "floor", + "body": "floor($2)", + "description": "float floor(float x)\nvec2 floor(vec2 x)\nvec3 floor(vec3 x)\nvec4 floor(vec4 x)\n\nThe floor function returns the largest integer number that is smaller or equal to x. The input parameter can be a floating scalar or a float vector. In case of a float vector the operation is done component-wise.\n\nSide note: The return value is of type floating scalar or float vector although the result of the operation is an integer." + }, + + "equal": { + "prefix": "equal", + "body": "equal($2, $3)", + "description": "perform a component-wise equal-to comparison of two vectors" + }, + + "fract": { + "prefix": "fract", + "body": "fract($2)", + "description": "float fract(float x)\nvec2 fract(vec2 x)\nvec3 fract(vec3 x)\nvec4 fract(vec4 x)\n\nThe fract function returns the fractional part of x, i.e. x minus floor(x). The input parameter can be a floating scalar or a float vector. In case of a float vector the operation is done component-wise." + }, + + "min": { + "prefix": "min", + "body": "min($2, $3)", + "description": "float min(float x, float y)\nvec2 min(vec2 x, vec2 y)\nvec3 min(vec3 x, vec3 y)\nvec4 min(vec4 x, vec4 y)\n\nThe min function returns the smaller of the two arguments. The input parameters can be floating scalars or float vectors. In case of float vectors the operation is done component-wise.\nfloat min(float x, float y)\nvec2 min(vec2 x, float y)\nvec3 min(vec3 x, float y)\nvec4 min(vec4 x, float y)\n\nThere is also a variation of the min function where the second parameter is always a floating scalar." + }, + + "max": { + "prefix": "max", + "body": "max($2, $3)", + "description": "float max(float x, float y)\nvec2 max(vec2 x, vec2 y)\nvec3 max(vec3 x, vec3 y)\nvec4 max(vec4 x, vec4 y)\n\nThe max function returns the larger of the two arguments. The input parameters can be floating scalars or float vectors. In case of float vectors the operation is done component-wise.\n\nfloat max(float x, float y)\nvec2 max(vec2 x, float y)\nvec3 max(vec3 x, float y)\nvec4 max(vec4 x, float y)\n\nThere is also a variation of the max function where the second parameter is always a floating scalar." + }, + + "mix": { + "prefix": "mix", + "body": "mix($2, $3, $4)", + "description": "float mix(float x, float y, float a)\nvec2 mix(vec2 x, vec2 y, vec2 a)\nvec3 mix(vec3 x, vec3 y, vec3 a)\nvec4 mix(vec4 x, vec4 y, vec4 a)\n\nThe mix function returns the linear blend of x and y, i.e. the product of x and (1 - a) plus the product of y and a. The input parameters can be floating scalars or float vectors. In case of float vectors the operation is done component-wise.\n\nfloat mix(float x, float y, float a)\nvec2 mix(vec2 x, vec2 y, float a)\nvec3 mix(vec3 x, vec3 y, float a)\nvec4 mix(vec4 x, vec4 y, float a)\n\nThere is also a variation of the mix function where the third parameter is always a floating scalar." + }, + + "mod": { + "prefix": "mod", + "body": "mod($2, $3)", + "description": "float mod(float x, float y)\nvec2 mod(vec2 x, vec2 y)\nvec3 mod(vec3 x, vec3 y)\nvec4 mod(vec4 x, vec4 y)\n\nThe mod function returns x minus the product of y and floor(x/y). The input parameters can be floating scalars or float vectors. In case of float vectors the operation is done component-wise.\n\nSide note: If x and y are integers the return value is the remainder of the division of x by y as expected.\n\nfloat mod(float x, float y)\nvec2 mod(vec2 x, float y)\nvec3 mod(vec3 x, float y)\nvec4 mod(vec4 x, float y)\n\nThere is also a variation of the mod function where the second parameter is always a floating scalar." + }, + + "modf": { + "prefix": "modf", + "body": "modf($2, $3)", + "description": "separate a value into its integer and fractional components" + }, + + "sign": { + "prefix": "sign", + "body": "sign($2)", + "description": "float sign(float x)\nvec2 sign(vec2 x)\nvec3 sign(vec3 x)\nvec4 sign(vec4 x)\n\nThe sign function returns 1.0 when x is positive, 0.0 when x is zero and -1.0 when x is negative. The input parameter can be a floating scalar or a float vector. In case of a float vector the operation is done component-wise." + }, + + "step": { + "prefix": "step", + "body": "step($2, $3)", + "description": "float step(float edge, float x)\nvec2 step(vec2 edge, vec2 x)\nvec3 step(vec3 edge, vec3 x)\nvec4 step(vec4 edge, vec4 x)\n\nThe step function returns 0.0 if x is smaller then edge and otherwise 1.0. The input parameters can be floating scalars or float vectors. In case of float vectors the operation is done component-wise.\n\nfloat step(float edge, float x)\nvec2 step(float edge, vec2 x)\nvec3 step(float edge, vec3 x)\nvec4 step(float edge, vec4 x)\n\nThere is also a variation of the step function where the edge parameter is always a floating scalar." + }, + + "smoothstep": { + "prefix": "smoothstep", + "body": "smoothstep($2, $3, $4)", + "description": "float smoothstep(float edge0, float edge1, float x)\nvec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x)\nvec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x)\nvec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x)\n\nThe smoothstep function returns 0.0 if x is smaller then edge0 and 1.0 if x is larger than edge1. Otherwise the return value is interpolated between 0.0 and 1.0 using Hermite polynomials. The input parameters can be floating scalars or float vectors. In case of float vectors the operation is done component-wise.\n\nfloat smoothstep(float edge0, float edge1, float x)\nvec2 smoothstep(float edge0, float edge1, vec2 x)\nvec3 smoothstep(float edge0, float edge1, vec3 x)\nvec4 smoothstep(float edge0, float edge1, vec4 x)\n\nThere is also a variation of the smoothstep function where the edge0 and edge1 parameters are always floating scalars." + }, + + "cross": { + "prefix": "cross", + "body": "cross($2, $3, $4)", + "description": "vec3 cross(vec3 x, vec3 y)\n\nThe cross function returns the cross product of the two input parameters, i.e. a vector that is perpendicular to the plane containing x and y and has a magnitude that is equal to the area of the parallelogram that x and y span. The input parameters can only be 3-component floating vectors. The cross product is equivalent to the product of the length of the vectors times the sinus of the(smaller) angle between x and y." + }, + + "distance": { + "prefix": "distance", + "body": "distance($2, $3)", + "description": "float distance(float p0, float p1)\nfloat distance(vec2 p0, vec2 p1)\nfloat distance(vec3 p0, vec3 p1)\nfloat distance(vec4 p0, vec4 p1)\n\nThe distance function returns the distance between two points. The distance of two points is the length of the vector d = p0 - p1, that starts at p1 and points to p0. The input parameters can be floating scalars or float vectors. In case of floating scalars the distance function is trivial and returns the absolute value of d." + }, + + "dot": { + "prefix": "dot", + "body": "dot($2, $3)", + "description": "float dot(float x, float y)\nfloat dot(vec2 x, vec2 y)\nfloat dot(vec3 x, vec3 y)\nfloat dot(vec4 x, vec4 y)\n\nThe dot function returns the dot product of the two input parameters, i.e. the sum of the component-wise products. If x and y are the same the square root of the dot product is equivalent to the length of the vector. The input parameters can be floating scalars or float vectors. In case of floating scalars the dot function is trivial and returns the product of x and y." + }, + + "faceforward": { + "prefix": "faceforward", + "body": "faceforward($2, $3, $4)", + "description": "float faceforward(float N, float I, float Nref)\nvec2 faceforward(vec2 N, vec2 I, vec2 Nref)\nvec3 faceforward(vec3 N, vec3 I, vec3 Nref)\nvec4 faceforward(vec4 N, vec4 I, vec4 Nref)\n\nThe faceforward function returns a vector that points in the same direction as a reference vector. The function has three input parameters of the type floating scalar or float vector: N, the vector to orient, I, the incident vector, and Nref, the reference vector. If the dot product of I and Nref is smaller than zero the return value is N. Otherwise -N is returned." + }, + + "length": { + "prefix": "length", + "body": "length($2)", + "description": "float length(float x)\nfloat length(vec2 x)\nfloat length(vec3 x)\nfloat length(vec4 x)\n\nThe length function returns the length of a vector defined by the Euclidean norm, i.e. the square root of the sum of the squared components. The input parameter can be a floating scalar or a float vector. In case of a floating scalar the length function is trivial and returns the absolute value." + }, + + "normalize": { + "prefix": "normalize", + "body": "normalize($2)", + "description": "float normalize(float x)\nvec2 normalize(vec2 x)\nvec3 normalize(vec3 x)\nvec4 normalize(vec4 x)\n\nThe normalize function returns a vector with length 1.0 that is parallel to x, i.e. x divided by its length. The input parameter can be a floating scalar or a float vector. In case of a floating scalar the normalize function is trivial and returns 1.0." + }, + + "reflect": { + "prefix": "reflect", + "body": "reflect($2, $3)", + "description": "float reflect(float I, float N)\nvec2 reflect(vec2 I, vec2 N)\nvec3 reflect(vec3 I, vec3 N)\nvec4 reflect(vec4 I, vec4 N)\n\nThe reflect function returns a vector that points in the direction of reflection. The function has two input parameters of the type floating scalar or float vector: I, the incident vector, and N, the normal vector of the reflecting surface.\n\nSide note: To obtain the desired result the vector N has to be normalized. The reflection vector always has the same length as the incident vector. From this it follows that the reflection vector is normalized if N and I are both normalized." + }, + + "refract": { + "prefix": "refract", + "body": "refract($2, $3, $4)", + "description": "float refract(float I, float N, float eta)\nvec2 refract(vec2 I, vec2 N, float eta)\nvec3 refract(vec3 I, vec3 N, float eta)\nvec4 refract(vec4 I, vec4 N, float eta)\n\nThe refract function returns a vector that points in the direction of refraction. The function has two input parameters of the type floating scalar or float vector and one input parameter of the type floating scalar: I, the incident vector, N, the normal vector of the refracting surface, and eta, the ratio of indices of refraction.\n\nSide note: To obtain the desired result the vectors I and N have to be normalized." + }, + + "trunc": { + "prefix": "trunc", + "body": "trunc($2)", + "description": "find the nearest integer less than or equal to the parameter" + }, + + "round": { + "prefix": "round", + "body": "round($2)", + "description": "find the nearest integer less than or equal to the parameter - The fraction 0.5 will round in a direction chosen by the implementation, presumably the direction that is fastest. This includes the possibility that round(x) returns the same value as roundEven(x) for all values of x" + }, + + "roundEven": { + "prefix": "roundEven", + "body": "roundEven($2)", + "description": "find the nearest even integer to the parameter - The fractional part of 0.5 will round toward the nearest even integer. For example, both 3.5 and 4.5 will round to 4.0." + }, + + "const": { + "prefix": "const", + "body": "const", + "description": "The qualifier const is used for variables that are compile-time constants or for function parameters that are read-only." + }, + + "attribute": { + "prefix": "attribute", + "body": "attribute", + "description": "The qualifier attribute is used to declare variables that are shared between a vertex shader and the OpenGL ES environment.\nSince the vertex shader is executed one time for each vertex attributes are used to specify per vertex data. They typically provide data such as the object space position, the normal direction and the texture coordinates of a vertex. Attributes are read-only variables, i.e. their value can not be changed in the vertex shader.\nSide note: Since an attribute is never initialized in the shader it has to be loaded with data by the application executing the shader." + }, + + "uniform": { + "prefix": "uniform", + "body": "uniform", + "description": "The qualifier uniform is used to declare variables that are shared between a shader and the OpenGL ES environment.\nUniforms can be used in the vertex shader and the fragment shader and they must have global scope. The same uniform variable can be used in the vertex and the fragment shader, but since both shaders share the same name space the declaration has to be identical. Uniforms are used to specify properties of the object that is rendered. Examples are the projection matrix, the light position or the material color of the object. Uniforms are read-only variables, i.e. their value can not be changed in the shader.\nSide note: Since a uniform is never initialized in the shader it has to be loaded with data by the application executing the shader." + }, + + "varying": { + "prefix": "varying", + "body": "varying", + "description": "The qualifier varying is used to declare variables that are shared between the vertex shader and the fragment shader.\nVarying are used for information that is calculated in the vertex shader and should be handed over to the fragment shader. Both shaders have to declare the varying and the declarations must be identical. The vertex shader initializes the varying for each vertex. After that the per vertex data of the varying is interpolated during rasterization before being handed over to the fragment shader.\nThe varying qualifier can only be used with floating point scalar, floating point vectors and (floating point) matrices as well as arrays containing these types." + }, + + "highp": { + "prefix": "highp", + "body": "highp", + "description": "The qualifier highp is used to specify the highest available precision for a variable. The variable has to be an integer or a floating point scalar or a vector or matrix based on these types. The precision qualifier precedes the type in the variable declaration.\nIn the vertex shader the use of a precision qualifier is optional. If no qualifier is given all variables are of highest precision. In the fragment shader a precision qualifier has to be used when declaring a variable unless a default precision has been defined for the specific type.\n\nuniform highp vec3 lightDirection;\n\nThe actual range corresponding to a precision qualifier is dependent on the specific OpenGL ES implementation. Using a lower precision might have a positive effect on performance (frame rates) and power efficiency but might also cause a loss in rendering quality. The appropriate trade-off can only be determined by testing different precision configurations." + }, + + "mediump": { + "prefix": "mediump", + "body": "mediump", + "description": "The qualifier mediump is used to specify a precision between the highest and lowest available precision for a variable. The variable has to be an integer or a floating point scalar or a vector or matrix based on these types. The precision qualifier precedes the type in the variable declaration.\nIn the vertex shader the use of a precision qualifier is optional. If no qualifier is given all variables are of highest precision. In the fragment shader a precision qualifier has to be used when declaring a variable unless a default precision has been defined for the specific type.\n\nvarying mediump vec2 textureCoordinate;\n\nThe actual range corresponding to a precision qualifier is dependent on the specific OpenGL ES implementation. Using a lower precision might have a positive effect on performance (frame rates) and power efficiency but might also cause a loss in rendering quality. The appropriate trade-off can only be determined by testing different precision configurations." + }, + + "lowp": { + "prefix": "lowp", + "body": "lowp", + "description": "The qualifier lowp is used to specify the lowest available precision for a variable. The variable has to be an integer or a floating point scalar or a vector or matrix based on these types. The precision qualifier precedes the type in the variable declaration.\nIn the vertex shader the use of a precision qualifier is optional. If no qualifier is given all variables are of highest precision. In the fragment shader a precision qualifier has to be used when declaring a variable unless a default precision has been defined for the specific type.\n\nvarying lowp vec4 colorVarying;\n\nThe actual range corresponding to a precision qualifier is dependent on the specific OpenGL ES implementation. Using a lower precision might have a positive effect on performance (frame rates) and power efficiency but might also cause a loss in rendering quality. The appropriate trade-off can only be determined by testing different precision configurations." + }, + + "precision": { + "prefix": "precision", + "body": "precision", + "description": "The keyword precision is used in conjunction with a precision qualifier and a data type to specify the default precision for that data type. The type has to be an integer or a floating point scalar or a vector or matrix based on these types.\nIn the vertex shader all variables are of highest precision by default. The default can be changed defining another default precision. In the fragment shader a precision qualifier has to be used when declaring a variable unless a default precision has been defined for the specific type.\n\nprecision highp float;\n\nThe actual range corresponding to a precision qualifier is dependent on the specific OpenGL ES implementation. Using a lower precision might have a positive effect on performance (frame rates) and power efficiency but might also cause a loss in rendering quality. The appropriate trade-off can only be determined by testing different precision configurations." + }, + + "in": { + "prefix": "in", + "body": "in", + "description": "The qualifier in is used to mark a parameter as read-only when a function is declared. The parameter will be passed by value to the function and the value can not be modified by the function.\nThe above function declaration shows the three possible parameter qualifiers. The usage of the read-only qualifier is not necessary since this is the default if no qualifier is specified." + }, + + "out": { + "prefix": "out", + "body": "out", + "description": "The qualifier out is used to mark a parameter as write-only when a function is declared. The parameter will be passed by reference to the function but it is not initialized, i.e. the value can not be read. The value can be modified by the function and the changes are preserved after the function exits.\nThe above function declaration shows the three possible parameter qualifiers. The usage of the read-only qualifier is not necessary since this is the default if no qualifier is specified." + }, + + "inout": { + "prefix": "inout", + "body": "inout", + "description": "The qualifier inout is used to mark a parameter as read-write when a function is declared. The parameter will be passed by reference to the function and is initialized, i.e. the value can be read. The value can be modified by the function and the changes are preserved after the function exits.\nThe above function declaration shows the three possible parameter qualifiers. The usage of the read-only qualifier is not necessary since this is the default if no qualifier is specified." + }, + + "gl_FragCoord": { + "prefix": "gl_FragCoord", + "body": "gl_FragCoord", + "description": "mediump vec4 gl_FragCoord;\n\nbool gl_FrontFacing;\n\nThe built-in variable gl_FragCoord is used by the OpenGL ES 2.0 pipeline to hand over the coordinates of the fragment to the fragment shader. The variable is read-only and the value is assigned by the OpenGL ES 2.0 pipeline.\nThe values of the fragment coordinate vector are given in the window coordinate system." + }, + + "gl_FrontFacing": { + "prefix": "gl_FrontFacing", + "body": "gl_FrontFacing", + "description": "The built-in variable gl_FrontFacing is used by the OpenGL ES 2.0 pipeline to hand over the information to the fragment shader if the fragment is part of a front-facing primitive (triangle). The variable is read-only and the value is assigned by the OpenGL ES 2.0 pipeline.\nThe front-facing variable has a boolean value." + }, + + "gl_PointCoord": { + "prefix": "gl_PointCoord", + "body": "gl_PointCoord", + "description": "mediump int gl_PointCoord;\n\nThe built-in variable gl_PointCoord is used by the OpenGL ES 2.0 pipeline to hand over the coordinates of a point sprite to the fragment shader. The variable is read-only and the value is calculated and assigned by the OpenGL ES 2.0 pipeline based on the position and radius of the point sprite.\nSide note: A value for this variable is provided by the OpenGL ES 2.0 pipeline only if the rendered primitives are points." + }, + + "gl_FragColor": { + "prefix": "gl_FragColor", + "body": "gl_FragColor", + "description": "mediump vec4 gl_FragColor;\n\nThe built-in variable gl_FragColor is used by the fragment shader to hand over the color of the fragment to the OpenGL ES 2.0 pipeline. The variable is pre-declared as shown above that way the variable can be used in the fragment shader for an assignment without prior declaration.\nThe values of the color vector are interpreted in the RGBA color space.\nThe assignment of values to this variable is mandatory for the fragment shader." + }, + + "gl_MaxTextureImageUnits": { + "prefix": "gl_MaxTextureImageUnits", + "body": "gl_MaxTextureImageUnits", + "description": "const mediump int gl_MaxTextureImageUnits >= 8\n\nThe built-in constant gl_MaxTextureImageUnits provides the maximum number of texture units that can be used by the fragment shader. The value of this variable is dependent on the OpenGL ES 2.0 implementation but has to be at least 8." + }, + + "gl_MaxFragmentUniformVectors": { + "prefix": "gl_MaxFragmentUniformVectors", + "body": "gl_MaxFragmentUniformVectors", + "description": "const mediump int gl_MaxFragmentUniformVectors >= 16\n\nThe built-in constant gl_MaxFragmentUniformVectors provides the maximum number of uniform vectors that can be used by the fragment shader. The value of this variable is dependent on the OpenGL ES 2.0 implementation but has to be at least 16." + }, + + "gl_MaxDrawBuffers": { + "prefix": "gl_MaxDrawBuffers", + "body": "gl_MaxDrawBuffers", + "description": "const mediump int gl_MaxDrawBuffers = 1\n\nThe built-in constant gl_MaxDrawBuffers provides the maximum number of the available draw buffers. The value of this variable is 1 for all OpenGL ES 2.0 implementations." + }, + + "function float": { + "prefix": "float", + "body": ["float ${NAME}(){", "\t", "}"], + "description": "A standard function that would need a return of a float value for it to work" + }, + + "function void": { + "prefix": "void", + "body": ["void ${NAME}(){", "\t", "}"], + "description": "A standard function that can be named whatever you so wish" + }, + + "function main": { + "prefix": "void main", + "body": ["void main(){", "\t", "}"], + "description": "void main(void){\n\t//code\n}\n\nThe keyword main is used to define the main function of a shader. This function is the entry point for the execution of every vertex and fragment shader. The main function takes no parameters and does not return a value." + }, + + "void": { + "prefix": "void", + "body": "void main(void);", + "description": "void main(void);\nint aFunction(void);\nvoid bFunction(float);\n\nThe data type void is used when the parameter list of a function is empty and when a function does not return a value." + }, + + "int": { + "prefix": "int", + "body": "int ${NAME} = $3;", + "description": "int aInt = 42;\nint bInt = int(aBool);\nint cInt = int(aFloat);\n\nThe data type int is used for integer values.\n\nSide note: Implicit type conversions are not supported. Type conversions can be done using constructors as shown in the second and third example." + }, + + "float": { + "prefix": "float", + "body": "float ${NAME} = $3;", + "description": "float aFloat = 1.0;\nfloat bFloat = float(aBool);\nfloat cFloat = float(aInt);\n\nThe data type bool is used for boolean values (true or false).\n\nSide note: Implicit type conversions are not supported. Type conversions can be done using constructors as shown in the second and third example." + }, + + "bool": { + "prefix": "bool", + "body": "bool ${NAME} = $3;", + "description": "bool aBool = true;\nbool bBool = bool(aInt);\nbool cBool = bool(aFloat);\n\nThe data type bool is used for boolean values (true or false).\n\nSide note: Implicit type conversions are not supported. Type conversions can be done using constructors as shown in the second and third example." + }, + + "texture2D": { + "prefix": "texture2D", + "body": "texture2D", + "description": "vec4 texture2D(sampler2D sampler, vec2 coord)\nvec4 texture2D(sampler2D sampler, vec2 coord, float bias)\n\nThe texture2D function returns a texel, i.e. the (color) value of the texture for the given coordinates. The function has one input parameter of the type sampler2D and one input parameter of the type vec2 : sampler, the uniform the texture is bound to, and coord, the 2-dimensional coordinates of the texel to look up.\n\nThere is an optional third input parameter of the type float: bias. After calculating the appropriate level of detail for a texture with mipmaps the bias is added before the actual texture lookup operation is executed.\n\nSide note: On iOS devices texture lookup functionality is only available in the fragment shader." + }, + + "textureCube": { + "prefix": "textureCube", + "body": "textureCube", + "description": "vec4 textureCube(samplerCube sampler, vec3 coord)\nvec4 textureCube(samplerCube sampler, vec3 coord, float bias)\n\nThe textureCube function returns a texel, i.e. the (color) value of the texture for the given coordinates. The function has one input parameter of the type samplerCube and one input parameter of the type vec3 : sampler, the uniform the texture is bound to, and coord, the 3-dimensional coordinates of the texel to look up.\n\nThere is an optional third input parameter of the type float: bias. After calculating the appropriate level of detail for a texture with mipmaps the bias is added before the actual texture lookup operation is executed.\n\nSide note: On iOS devices texture lookup functionality is only available in the fragment shader." + }, + + "PI": { + "prefix": "PI", + "body": ["const float PI = 3.14159265359;"], + "description": "PI setup" + }, + + "random2d": { + "prefix": "random2d", + "body": [ + "float random2d(vec2 coord){", + "\treturn fract(sin(dot(coord.xy, vec2(12.9898, 78.233))) * 43758.5453);", + "}" + ], + "description": "random 2d function" + }, + + "noise1d": { + "prefix": "noise1d", + "body": [ + "float noise1d(float v){", + "\treturn cos(v + cos(v * 90.1415) * 100.1415) * 0.5 + 0.5;", + "}" + ], + "description": "noise1d function" + }, + + "simple setup": { + "prefix": "simple setup", + "body": [ + "#ifdef GL_ES", + "precision mediump float;", + "#endif", + "", + "uniform float u_time;", + "uniform vec2 u_resolution;", + "uniform vec2 u_mouse;", + "", + "void main(){", + "\tvec2 coord = gl_FragCoord.xy;", + "\tvec3 color = vec3(0.0);", + "", + "\tgl_FragColor = vec4(color, 1.0);", + "}" + ], + "description": "Starter code including 'ifdef' check, u_ methods & the main" + }, + + "circle shape": { + "prefix": "circle shape", + "body": [ + "float ${NAME}(vec2 position, float radius){", + "\treturn step(radius, length(position - vec2(0.5)));", + "}" + ], + "description": "circle shape" + }, + + "rectangle shape": { + "prefix": "rectangle shape", + "body": [ + "float ${NAME}(vec2 position, vec2 scale){", + "\tscale = vec2(0.5) - scale * 0.5;", + "\tvec2 shaper = vec2(step(scale.x, position.x), step(scale.y, position.y));", + "\tshaper *= vec2(step(scale.x, 1.0 - position.x), step(scale.y, 1.0 - position.y));", + "\treturn shaper.x * shaper.y;", + "}" + ], + "description": "rectangle shape" + }, + + "polygon shape": { + "prefix": "polygon shape", + "body": [ + "float ${NAME}(vec2 position, float radius, float sides){", + "\tposition = position * 2.0 - 1.0;", + "\tfloat angle = atan(position.x, position.y);", + "\tfloat slice = PI * 2.0 / sides;", + "\treturn step(radius, cos(floor(0.5 + angle / slice) * slice - angle) * length(position));", + "}" + ], + "description": "polygon shape" + }, + + "scale": { + "prefix": "scale", + "body": [ + "mat2 scale(vec2 scale){", + "\treturn mat2(scale.x, 0.0, 0.0, scale.y);", + "}" + ], + "description": "scale" + }, + + "rotate": { + "prefix": "rotate", + "body": [ + "mat2 rotate(float angle){", + "\treturn mat2(cos(angle), -sin(angle), sin(angle), cos(angle));", + "}" + ], + "description": "rotate" + }, + + "random": { + "prefix": "random", + "body": [ + "float random (vec2 st) {", + "\treturn fract(", + "\t\tsin(", + "\t\t\tdot(", + "\t\t\t\tst.xy,", + "\t\t\t\tvec2(st.xy * 1000.0)", + "\t\t\t)", + "\t\t) * 1000.0", + "\t);", + "}" + ], + "description": "" + }, + + "function circleshape": { + "prefix": "circleshape", + "body": [ + "float circleshape(vec2 position, float radius) {", + "\treturn step(radius, length(position - vec2(0.5)));", + "}" + ], + "description": "A function that draw a circle from center." + }, + + "function polygonshape": { + "prefix": "polygonshape", + "body": [ + "float polygonshape(vec2 position, float radius, float sides) {", + "\tposition = position * 2.0 - 1.0;", + "\tfloat angle = atan(position.x, position.y); ", + "\tfloat slice = PI * 2.0 / sides; //外角度数", + "\treturn step(radius, cos(floor(0.5 + angle / slice) * slice - angle) * length(position));", + "}" + ], + "description": "A function that draw a polygon from center." + } } diff --git a/snippets/lua.json b/snippets/lua.json index d204675..30c68c5 100644 --- a/snippets/lua.json +++ b/snippets/lua.json @@ -1,11 +1,7 @@ { - "Print": { - "prefix": "pr", - "body": [ - "print(\"$1\"$2);", - "$3" - ], - "description": "Output to console" - } - + "Print": { + "prefix": "pr", + "body": ["print(\"$1\"$2);", "$3"], + "description": "Output to console" + } } diff --git a/snippets/rust.json b/snippets/rust.json index be9d988..7f65092 100644 --- a/snippets/rust.json +++ b/snippets/rust.json @@ -222,5 +222,92 @@ "}" ], "description": "#[test]" + }, + + "Query Param": { + "prefix": "query", + "body": "${1:query}: Query<${0}>" + }, + "Mutable Query Param": { + "prefix": "query mut", + "body": "mut ${1:query}: Query<${0}>" + }, + "Commands Param": { + "prefix": "commands", + "body": "mut ${0:commands}: Commands" + }, + "Res Param": { + "prefix": "res", + "body": "${1:res}: Res<${0}>" + }, + "ResMut Param": { + "prefix": "res mut", + "body": "mut ${1:res}: ResMut<${0}>" + }, + "EventWriter Param": { + "prefix": "event writer", + "body": "mut ${1:events}: EventWriter<${0}>" + }, + "EventReader Param": { + "prefix": "event reader", + "body": "mut ${1:events}: EventReader<${0}>" + }, + "Local Param": { + "prefix": "local", + "body": "mut ${1:local}: Local<${0}>" + }, + "Exclusive System Template": { + "prefix": "exclusive system", + "description": "Exclusive systems run on the main thread and have mutable (exclusive) access to the ECS world.", + "body": ["fn ${1}(world: &mut World) {", "\t${0}", "}"] + }, + "App Template": { + "prefix": "app", + "body": [ + "use bevy::prelude::*;", + "", + "fn main() {", + " App::new()", + " .add_plugins(DefaultPlugins)${0}", + " .run();", + "}" + ] + }, + "Plugin Template": { + "prefix": "plugin", + "body": [ + "pub struct ${1};", + "", + "impl Plugin for ${1} {", + "\tfn build(&self, app: &mut App) {", + "\t\t${0}", + "\t}", + "}" + ] + }, + "Component Struct": { + "prefix": "component", + "body": ["#[derive(Component)]", "struct ${0}"] + }, + "Resource Struct": { + "prefix": "resource", + "body": ["#[derive(Resource)]", "struct ${0}"] + }, + "Bundle Struct": { + "prefix": "bundle", + "body": ["#[derive(Bundle)]", "struct ${1} {", "\t${0}", "}"] + }, + "Bevy: New PluginGroup": { + "prefix": "bevy plugin group", + "body": [ + "struct ${1:AwesomePlugins};", + "", + "impl PluginGroup for ${1:AwesomePlugins} {", + "\tfn build(&mut self, group: &mut bevy::app::PluginGroupBuilder) {", + "\t\ttodo!()", + "\t}", + "}" + ], + "description": "Create a new PluginGroup" } } From 6d821ebd53f656c7670c321de6d927f042c80c44 Mon Sep 17 00:00:00 2001 From: PandeCode Date: Sun, 10 Mar 2024 12:40:02 -0600 Subject: [PATCH 09/11] Markdown | Autosave --- snippets/markdown.json | 14 +++++ vimscript/autosave.vim | 140 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+) create mode 100644 snippets/markdown.json create mode 100644 vimscript/autosave.vim diff --git a/snippets/markdown.json b/snippets/markdown.json new file mode 100644 index 0000000..81fcc51 --- /dev/null +++ b/snippets/markdown.json @@ -0,0 +1,14 @@ +{ + "mathjax": { + "prefix": "math", + "body": [ + "$$", + "\\begin{align}", + "& Hello \\\\\\\\", + "& World \\\\\\\\", + "& End", + "\\end{align}", + "$$" + ] + } +} diff --git a/vimscript/autosave.vim b/vimscript/autosave.vim new file mode 100644 index 0000000..3194769 --- /dev/null +++ b/vimscript/autosave.vim @@ -0,0 +1,140 @@ +"====================================== +" Script Name: vim-auto-save (http://www.vim.org/scripts/script.php?script_id=4521) +" Plugin Name: AutoSave +" Version: 0.1.12 +"====================================== + +if exists("g:auto_save_loaded") + finish +else + let g:auto_save_loaded = 1 +endif + +let s:save_cpo = &cpo +set cpo&vim + +if !exists("g:auto_save") + let g:auto_save = 0 +endif + +if !exists("g:auto_save_silent") + let g:auto_save_silent = 0 +endif + +if !exists("g:auto_save_write_all_buffers") + let g:auto_save_write_all_buffers = 0 +endif + +if !exists("g:auto_save_events") + let g:auto_save_events = ["InsertLeave", "TextChanged"] +endif + +" Check all used events exist +for event in g:auto_save_events + if !exists("##" . event) + let eventIndex = index(g:auto_save_events, event) + if (eventIndex >= 0) + call remove(g:auto_save_events, eventIndex) + echo "(AutoSave) Save on " . event . " event is not supported for your Vim version!" + echo "(AutoSave) " . event . " was removed from g:auto_save_events variable." + echo "(AutoSave) Please, upgrade your Vim to a newer version or use other events in g:auto_save_events!" + endif + endif +endfor + +augroup auto_save + autocmd! + for event in g:auto_save_events + execute "au " . event . " * nested call AutoSave()" + endfor +augroup END + +command AutoSaveToggle :call AutoSaveToggle() + +function AutoSave() + if s:GetVar('auto_save', 0) == 0 + return + end + + let was_modified = s:IsModified() + if !was_modified + return + end + + if exists("g:auto_save_presave_hook") + let g:auto_save_abort = 0 + execute "" . g:auto_save_presave_hook + if g:auto_save_abort >= 1 + return + endif + endif + + " Preserve marks that are used to remember start and + " end position of the last changed or yanked text (`:h '[`). + let first_char_pos = getpos("'[") + let last_char_pos = getpos("']") + + call DoSave() + + call setpos("'[", first_char_pos) + call setpos("']", last_char_pos) + + if was_modified && !&modified + if exists("g:auto_save_postsave_hook") + execute "" . g:auto_save_postsave_hook + endif + + if g:auto_save_silent == 0 + echo "(AutoSave) saved at " . strftime("%H:%M:%S") + endif + endif +endfunction + +function s:IsModified() + if g:auto_save_write_all_buffers >= 1 + let buffers = filter(range(1, bufnr('$')), 'bufexists(v:val)') + call filter(buffers, 'getbufvar(v:val, "&modified")') + return len(buffers) > 0 + else + return &modified + endif +endfunction + +" Resolve variable value by climbing up window-buffer-global hierarchy +" So, buffer-local or window-local variables override global ones +" If not found on any level, fallbacks to default value or empty string +function s:GetVar(...) + let varName = a:1 + + if exists('w:' . varName) + return w:{varName} + elseif exists('b:' . varName) + return b:{varName} + elseif exists('g:' . varName) + return g:{varName} + else + return exists('a:2') ? a:2 : '' + endif +endfunction + +function DoSave() + if g:auto_save_write_all_buffers >= 1 + silent! wa + else + silent! w + endif +endfunction + +function AutoSaveToggle() + if g:auto_save >= 1 + let g:auto_save = 0 + echo "(AutoSave) OFF" + else + let g:auto_save = 1 + echo "(AutoSave) ON" + endif +endfunction + +let &cpo = s:save_cpo +unlet s:save_cpo + From 7217973905ff0616e734eeef1c2fc262915b5158 Mon Sep 17 00:00:00 2001 From: PandeCode Date: Sat, 16 Mar 2024 09:25:40 -0600 Subject: [PATCH 10/11] plugin config[ --- README.md | 1 + lua/config/options.lua | 2 ++ lua/plugins/init.lua | 21 ++++++++++++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 405fd2f..ca1ef6c 100644 --- a/README.md +++ b/README.md @@ -117,3 +117,4 @@ pnpm -g install vscode-langservers-extracted @tailwindcss/language-server cssmod ## Future https://github.com/nullchilly/CatNvim https://github.com/noib3/nvim-oxi +https://github.com/gillescastel/latex-snippets diff --git a/lua/config/options.lua b/lua/config/options.lua index 390cf37..57076ae 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -2,6 +2,8 @@ vim.g.python_recommended_style = 0 vim.g.python_host_skip_check = 1 vim.g.loaded_python3_provider = 1 +vim.o.conceallevel = 1 + -- vim.o.t_Co = 256 -- vim.o.t_ut = true -- vim.o.shortmess = (vim.o.shortmess .. "c") diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 9ccdff5..fcb5d5f 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -321,7 +321,19 @@ local vscode_disabled_plugins = { }, desc = "Obsidian", }, - dependencies = { "nvim-lua/plenary.nvim" }, + dependencies = { + "nvim-lua/plenary.nvim", + { + "jbyuki/nabla.nvim", + config = function() + vim.keymap.set(Keys.N, "p", ':lua require("nabla").popup()', Keys.Noremap) + -- require("nabla").enable_virt({ + -- autogen = true, -- auto-regenerate ASCII art when exiting insert mode + -- silent = true, -- silents error messages + -- }) + end, + }, + }, opts = { workspaces = { { name = "School", path = "/mnt/c/Users/pande/Vault/School" }, @@ -382,6 +394,13 @@ local vscode_disabled_plugins = { ft = { "lua" }, config = RequireFn("plugins.neodev_conf"), priority = 47, + lazy = true, + event = { + "BufReadPre ~/.config/nvim/**.lua", + "BufNewFile ~/.config/nvim/**.lua", + "BufReadPre ~/.config/nvim/**.lua", + "BufNewFile ~/.config/nvim/**.lua", + }, }, { "p00f/clangd_extensions.nvim", From 4daa73f569c59a27413baf89550751e2c2021f7e Mon Sep 17 00:00:00 2001 From: PandeCode Date: Sat, 16 Mar 2024 19:54:37 -0600 Subject: [PATCH 11/11] readmn | todo --- README.md | 152 ++++++++++++++++++++++--------------------- TODO.md | 13 ++++ lazy-lock.json | 8 +-- lua/plugins/init.lua | 7 ++ 4 files changed, 102 insertions(+), 78 deletions(-) diff --git a/README.md b/README.md index ca1ef6c..daf7b00 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,28 @@ # Nvim Config + My personal configuration for [https://github.com/neovim/neovim](neovim). ## Supported languages - - C - - C++ - - Golang - - Lua - - Rust - - Javascript(react) - - Typescript(react) - - Vimscript + +- C +- C++ +- Golang +- Lua +- Rust +- Javascript(react) +- Typescript(react) +- Vimscript ## Dependencies ### Arch linux + https://github.com/golang/tools/tree/master/gopls sudo pacman -S gopls cargo-binstall ### Rust Deps (cargo-binstall installed) + Decodetalkers/neocmakelsp ```bash @@ -32,8 +36,8 @@ go install github.com/segmentio/golines@latest go install mvdan.cc/gofumpt@latest ``` - ### Node Deps (pnpm installed) + tailwindlabs/tailwindcss-intellisense antonk52/cssmodules-language-server hrsh7th/vscode-langservers-extracted @@ -47,74 +51,74 @@ iamcco/vim-language-server pnpm -g install vscode-langservers-extracted @tailwindcss/language-server cssmodules-language-server emmet-ls pyright bash-language-server awk-language-server vim-language-server ``` -## Extensions - -| Extension | Description | -|-|-| -| [https://github.com/lewis6991/impatient.nvim](lewis6991/impatient.nvim) | Improve startup time for Neovim | -| [https://github.com/marko-cerovac/material.nvim](marko-cerovac/material.nvim) | :trident: Material colorscheme for NeoVim written in Lua with built-in support for native LSP, TreeSitter and many more plugins | -| [https://github.com/stevearc/dressing.nvim](stevearc/dressing.nvim) | Neovim plugin to improve the default vim.ui interfaces | -| [https://github.com/airblade/vim-gitgutter](airblade/vim-gitgutter) | A Vim plugin which shows git diff markers in the sign column and stages/previews/undoes hunks and partial hunks. | -| [https://github.com/ap/vim-css-color](ap/vim-css-color) | Preview colours in source code while editing | -| [https://github.com/chaoren/vim-wordmotion](chaoren/vim-wordmotion) | More useful word motions for Vim | -| [https://github.com/itchyny/vim-cursorword](itchyny/vim-cursorword) | Underlines the word under the cursor | -| [https://github.com/mg979/vim-visual-multi](mg979/vim-visual-multi) | Multiple cursors plugin for vim/neovim | -| [https://github.com/rcarriga/nvim-notify](rcarriga/nvim-notify) | A fancy, configurable, notification manager for NeoVim | -| [https://github.com/romainl/vim-cool](romainl/vim-cool) | A very simple plugin that makes hlsearch more useful. | -| [https://github.com/tpope/vim-repeat](tpope/vim-repeat) | repeat.vim: enable repeating supported plugin maps with "." | -| [https://github.com/windwp/nvim-autopairs](windwp/nvim-autopairs) | autopairs for neovim written by lua | -| [https://github.com/kylechui/nvim-surround](kylechui/nvim-surround) | Add/change/delete surrounding delimiter pairs with ease. Written with :heart: in Lua. | -| [https://github.com/chentoast/marks.nvim](chentoast/marks.nvim) | A better user experience for viewing and interacting with Vim marks. | -| [https://github.com/folke/todo-comments.nvim](folke/todo-comments.nvim) | ✅ Highlight, list and search todo comments in your projects | -| [https://github.com/Iron-E/nvim-libmodal](Iron-E/nvim-libmodal) | Create new "modes" for Neovim! | -| [https://github.com/junegunn/vim-easy-align](junegunn/vim-easy-align) | :sunflower: A Vim alignment plugin | -| [https://github.com/mbbill/undotree](mbbill/undotree) | The undo history visualizer for VIM | -| [https://github.com/preservim/nerdcommenter](preservim/nerdcommenter) | Vim plugin for intensely nerdy commenting powers | -| [https://github.com/sbdchd/neoformat](sbdchd/neoformat) | :sparkles: A (Neo)vim plugin for formatting code. | -| [https://github.com/ludovicchabant/vim-gutentags](ludovicchabant/vim-gutentags) | A Vim plugin that manages your tag files | -| [https://github.com/andymass/vim-matchup](andymass/vim-matchup) | vim match-up: even better % :facepunch: navigate and highlight matching words :facepunch: modern matchit and matchparen. Supports both vim and neovim + tree-sitter. | -| [https://github.com/nvim-tree/nvim-web-devicons](nvim-tree/nvim-web-devicons) | lua `fork` of vim-web-devicons for neovim | -| [https://github.com/akinsho/bufferline.nvim](akinsho/bufferline.nvim) | A snazzy bufferline for Neovim | -| [https://github.com/nvim-lualine/lualine.nvim](nvim-lualine/lualine.nvim) | A blazing fast and easy to configure neovim statusline plugin written in pure lua. | -| [https://github.com/glepnir/dashboard-nvim](glepnir/dashboard-nvim) | vim dashboard | -| [https://github.com/nvim-telescope/telescope.nvim](nvim-telescope/telescope.nvim) | Find, Filter, Preview, Pick. All lua, all the time. | -| [https://github.com/nvim-lua/plenary.nvim](nvim-lua/plenary.nvim) | plenary: full; complete; entire; absolute; unqualified. All the lua functions I don't want to write twice. | -| [https://github.com/nvim-orgmode/orgmode](nvim-orgmode/orgmode) | Orgmode clone written in Lua for Neovim 0.7+. | -| [https://github.com/mrjones2014/nvim-ts-rainbow](mrjones2014/nvim-ts-rainbow) | Rainbow parentheses for neovim using tree-sitter. | -| [https://github.com/nvim-treesitter/nvim-treesitter](nvim-treesitter/nvim-treesitter) | Nvim Treesitter configurations and abstraction layer | -| [https://github.com/lukas-reineke/indent-blankline.nvim](lukas-reineke/indent-blankline.nvim) | Indent guides for Neovim | -| [https://github.com/nvim-treesitter/nvim-treesitter-textobjects](nvim-treesitter/nvim-treesitter-textobjects) | null | -| [https://github.com/nvim-treesitter/playground](nvim-treesitter/playground) | Treesitter playground integrated into Neovim | -| [https://github.com/hrsh7th/nvim-cmp](hrsh7th/nvim-cmp) | A completion plugin for neovim coded in Lua. | -| [https://github.com/hrsh7th/cmp-nvim-lsp](hrsh7th/cmp-nvim-lsp) | nvim-cmp source for neovim builtin LSP client | -| [https://github.com/quangnguyen30192/cmp-nvim-tags](quangnguyen30192/cmp-nvim-tags) | tags sources for nvim-cmp | -| [https://github.com/hrsh7th/cmp-buffer](hrsh7th/cmp-buffer) | nvim-cmp source for buffer words | -| [https://github.com/hrsh7th/cmp-path](hrsh7th/cmp-path) | nvim-cmp source for path | -| [https://github.com/hrsh7th/cmp-cmdline](hrsh7th/cmp-cmdline) | nvim-cmp source for vim's cmdline | -| [https://github.com/L3MON4D3/LuaSnip](L3MON4D3/LuaSnip) | Snippet engine for Neovim written in Lua. | -| [https://github.com/saadparwaiz1/cmp_luasnip](saadparwaiz1/cmp_luasnip) | luasnip completion source for nvim-cmp | -| [https://github.com/neovim/nvim-lspconfig](neovim/nvim-lspconfig) | Quickstart configs for Nvim LSP | -| [https://github.com/j-hui/fidget.nvim](j-hui/fidget.nvim) | Standalone UI for nvim-lsp progress | -| [https://github.com/kevinhwang91/nvim-ufo](kevinhwang91/nvim-ufo) | Not UFO in the sky, but an ultra fold in Neovim. | -| [https://github.com/kevinhwang91/promise-async](kevinhwang91/promise-async) | Promise & Async in Lua | -| [https://github.com/folke/neodev.nvim](folke/neodev.nvim) | 💻 Neovim setup for init.lua and plugin development with full signature help, docs and completion for the nvim lua API. | -| [https://github.com/p00f/clangd_extensions.nvim](p00f/clangd_extensions.nvim) | Clangd's off-spec features for neovim's LSP client. Use https://sr.ht/~p00f/clangd_extensions.nvim instead | -| [https://github.com/ray-x/go.nvim](ray-x/go.nvim) | Modern Go dev plugin, based on gopls, treesitter AST, Dap and a variety of go tools. | -| [https://github.com/simrat39/rust-tools.nvim](simrat39/rust-tools.nvim) | Tools for better development in rust using neovim's builtin lsp | -| [https://github.com/b0o/SchemaStore.nvim](b0o/SchemaStore.nvim) | 🛍 JSON schemas for Neovim | -| [https://github.com/mfussenegger/nvim-dap](mfussenegger/nvim-dap) | Debug Adapter Protocol client implementation for Neovim | -| [https://github.com/rcarriga/nvim-dap-ui](rcarriga/nvim-dap-ui) | A UI for nvim-dap | -| [https://github.com/danymat/neogen](danymat/neogen) | A better annotation generator. Supports multiple languages and annotation conventions. | -| [https://github.com/ThePrimeagen/refactoring.nvim](ThePrimeagen/refactoring.nvim) | The Refactoring library based off the Refactoring book by Martin Fowler | -| [https://github.com/wakatime/vim-wakatime](wakatime/vim-wakatime) | Vim plugin for automatic time tracking and metrics generated from your programming activity. | -| [https://github.com/folke/which-key.nvim](folke/which-key.nvim) | 💥 Create key bindings that stick. WhichKey is a lua plugin for Neovim 0.5 that displays a popup with possible keybindings of the command you started typing. | -| [https://github.com/Eandrju/cellular-automaton.nvim](Eandrju/cellular-automaton.nvim) | A useless plugin that might help you cope with stubbornly broken tests or overall lack of sense in life. It lets you execute aesthetically pleasing, cellular automaton animations based on the content of neovim buffer. | -| [https://github.com/jose-elias-alvarez/typescript.nvim](jose-elias-alvarez/typescript.nvim) | A Lua plugin, written in TypeScript, to write TypeScript (Lua optional). | -| [https://github.com/Maan2003/lsp_lines.nvim](Maan2003/lsp_lines.nvim) | renders diagnostics using virtual lines on top of the real line of code | -| [https://github.com/tpope/vim-abolish](tpope/vim-abolish) | abolish.vim: Work with several variants of a word at once | +## Extensions +| Extension | Description | +| ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [https://github.com/lewis6991/impatient.nvim](lewis6991/impatient.nvim) | Improve startup time for Neovim | +| [https://github.com/marko-cerovac/material.nvim](marko-cerovac/material.nvim) | :trident: Material colorscheme for NeoVim written in Lua with built-in support for native LSP, TreeSitter and many more plugins | +| [https://github.com/stevearc/dressing.nvim](stevearc/dressing.nvim) | Neovim plugin to improve the default vim.ui interfaces | +| [https://github.com/airblade/vim-gitgutter](airblade/vim-gitgutter) | A Vim plugin which shows git diff markers in the sign column and stages/previews/undoes hunks and partial hunks. | +| [https://github.com/ap/vim-css-color](ap/vim-css-color) | Preview colours in source code while editing | +| [https://github.com/chaoren/vim-wordmotion](chaoren/vim-wordmotion) | More useful word motions for Vim | +| [https://github.com/itchyny/vim-cursorword](itchyny/vim-cursorword) | Underlines the word under the cursor | +| [https://github.com/mg979/vim-visual-multi](mg979/vim-visual-multi) | Multiple cursors plugin for vim/neovim | +| [https://github.com/rcarriga/nvim-notify](rcarriga/nvim-notify) | A fancy, configurable, notification manager for NeoVim | +| [https://github.com/romainl/vim-cool](romainl/vim-cool) | A very simple plugin that makes hlsearch more useful. | +| [https://github.com/tpope/vim-repeat](tpope/vim-repeat) | repeat.vim: enable repeating supported plugin maps with "." | +| [https://github.com/windwp/nvim-autopairs](windwp/nvim-autopairs) | autopairs for neovim written by lua | +| [https://github.com/kylechui/nvim-surround](kylechui/nvim-surround) | Add/change/delete surrounding delimiter pairs with ease. Written with :heart: in Lua. | +| [https://github.com/chentoast/marks.nvim](chentoast/marks.nvim) | A better user experience for viewing and interacting with Vim marks. | +| [https://github.com/folke/todo-comments.nvim](folke/todo-comments.nvim) | ✅ Highlight, list and search todo comments in your projects | +| [https://github.com/Iron-E/nvim-libmodal](Iron-E/nvim-libmodal) | Create new "modes" for Neovim! | +| [https://github.com/junegunn/vim-easy-align](junegunn/vim-easy-align) | :sunflower: A Vim alignment plugin | +| [https://github.com/mbbill/undotree](mbbill/undotree) | The undo history visualizer for VIM | +| [https://github.com/preservim/nerdcommenter](preservim/nerdcommenter) | Vim plugin for intensely nerdy commenting powers | +| [https://github.com/sbdchd/neoformat](sbdchd/neoformat) | :sparkles: A (Neo)vim plugin for formatting code. | +| [https://github.com/ludovicchabant/vim-gutentags](ludovicchabant/vim-gutentags) | A Vim plugin that manages your tag files | +| [https://github.com/andymass/vim-matchup](andymass/vim-matchup) | vim match-up: even better % :facepunch: navigate and highlight matching words :facepunch: modern matchit and matchparen. Supports both vim and neovim + tree-sitter. | +| [https://github.com/nvim-tree/nvim-web-devicons](nvim-tree/nvim-web-devicons) | lua `fork` of vim-web-devicons for neovim | +| [https://github.com/akinsho/bufferline.nvim](akinsho/bufferline.nvim) | A snazzy bufferline for Neovim | +| [https://github.com/nvim-lualine/lualine.nvim](nvim-lualine/lualine.nvim) | A blazing fast and easy to configure neovim statusline plugin written in pure lua. | +| [https://github.com/glepnir/dashboard-nvim](glepnir/dashboard-nvim) | vim dashboard | +| [https://github.com/nvim-telescope/telescope.nvim](nvim-telescope/telescope.nvim) | Find, Filter, Preview, Pick. All lua, all the time. | +| [https://github.com/nvim-lua/plenary.nvim](nvim-lua/plenary.nvim) | plenary: full; complete; entire; absolute; unqualified. All the lua functions I don't want to write twice. | +| [https://github.com/nvim-orgmode/orgmode](nvim-orgmode/orgmode) | Orgmode clone written in Lua for Neovim 0.7+. | +| [https://github.com/mrjones2014/nvim-ts-rainbow](mrjones2014/nvim-ts-rainbow) | Rainbow parentheses for neovim using tree-sitter. | +| [https://github.com/nvim-treesitter/nvim-treesitter](nvim-treesitter/nvim-treesitter) | Nvim Treesitter configurations and abstraction layer | +| [https://github.com/lukas-reineke/indent-blankline.nvim](lukas-reineke/indent-blankline.nvim) | Indent guides for Neovim | +| [https://github.com/nvim-treesitter/nvim-treesitter-textobjects](nvim-treesitter/nvim-treesitter-textobjects) | null | +| [https://github.com/nvim-treesitter/playground](nvim-treesitter/playground) | Treesitter playground integrated into Neovim | +| [https://github.com/hrsh7th/nvim-cmp](hrsh7th/nvim-cmp) | A completion plugin for neovim coded in Lua. | +| [https://github.com/hrsh7th/cmp-nvim-lsp](hrsh7th/cmp-nvim-lsp) | nvim-cmp source for neovim builtin LSP client | +| [https://github.com/quangnguyen30192/cmp-nvim-tags](quangnguyen30192/cmp-nvim-tags) | tags sources for nvim-cmp | +| [https://github.com/hrsh7th/cmp-buffer](hrsh7th/cmp-buffer) | nvim-cmp source for buffer words | +| [https://github.com/hrsh7th/cmp-path](hrsh7th/cmp-path) | nvim-cmp source for path | +| [https://github.com/hrsh7th/cmp-cmdline](hrsh7th/cmp-cmdline) | nvim-cmp source for vim's cmdline | +| [https://github.com/L3MON4D3/LuaSnip](L3MON4D3/LuaSnip) | Snippet engine for Neovim written in Lua. | +| [https://github.com/saadparwaiz1/cmp_luasnip](saadparwaiz1/cmp_luasnip) | luasnip completion source for nvim-cmp | +| [https://github.com/neovim/nvim-lspconfig](neovim/nvim-lspconfig) | Quickstart configs for Nvim LSP | +| [https://github.com/j-hui/fidget.nvim](j-hui/fidget.nvim) | Standalone UI for nvim-lsp progress | +| [https://github.com/kevinhwang91/nvim-ufo](kevinhwang91/nvim-ufo) | Not UFO in the sky, but an ultra fold in Neovim. | +| [https://github.com/kevinhwang91/promise-async](kevinhwang91/promise-async) | Promise & Async in Lua | +| [https://github.com/folke/neodev.nvim](folke/neodev.nvim) | 💻 Neovim setup for init.lua and plugin development with full signature help, docs and completion for the nvim lua API. | +| [https://github.com/p00f/clangd_extensions.nvim](p00f/clangd_extensions.nvim) | Clangd's off-spec features for neovim's LSP client. Use https://sr.ht/~p00f/clangd_extensions.nvim instead | +| [https://github.com/ray-x/go.nvim](ray-x/go.nvim) | Modern Go dev plugin, based on gopls, treesitter AST, Dap and a variety of go tools. | +| [https://github.com/simrat39/rust-tools.nvim](simrat39/rust-tools.nvim) | Tools for better development in rust using neovim's builtin lsp | +| [https://github.com/b0o/SchemaStore.nvim](b0o/SchemaStore.nvim) | 🛍 JSON schemas for Neovim | +| [https://github.com/mfussenegger/nvim-dap](mfussenegger/nvim-dap) | Debug Adapter Protocol client implementation for Neovim | +| [https://github.com/rcarriga/nvim-dap-ui](rcarriga/nvim-dap-ui) | A UI for nvim-dap | +| [https://github.com/danymat/neogen](danymat/neogen) | A better annotation generator. Supports multiple languages and annotation conventions. | +| [https://github.com/ThePrimeagen/refactoring.nvim](ThePrimeagen/refactoring.nvim) | The Refactoring library based off the Refactoring book by Martin Fowler | +| [https://github.com/wakatime/vim-wakatime](wakatime/vim-wakatime) | Vim plugin for automatic time tracking and metrics generated from your programming activity. | +| [https://github.com/folke/which-key.nvim](folke/which-key.nvim) | 💥 Create key bindings that stick. WhichKey is a lua plugin for Neovim 0.5 that displays a popup with possible keybindings of the command you started typing. | +| [https://github.com/Eandrju/cellular-automaton.nvim](Eandrju/cellular-automaton.nvim) | A useless plugin that might help you cope with stubbornly broken tests or overall lack of sense in life. It lets you execute aesthetically pleasing, cellular automaton animations based on the content of neovim buffer. | +| [https://github.com/jose-elias-alvarez/typescript.nvim](jose-elias-alvarez/typescript.nvim) | A Lua plugin, written in TypeScript, to write TypeScript (Lua optional). | +| [https://github.com/Maan2003/lsp_lines.nvim](Maan2003/lsp_lines.nvim) | renders diagnostics using virtual lines on top of the real line of code | +| [https://github.com/tpope/vim-abolish](tpope/vim-abolish) | abolish.vim: Work with several variants of a word at once | ## Future + https://github.com/nullchilly/CatNvim https://github.com/noib3/nvim-oxi https://github.com/gillescastel/latex-snippets diff --git a/TODO.md b/TODO.md index 1a5c65e..bf7b532 100644 --- a/TODO.md +++ b/TODO.md @@ -1 +1,14 @@ +[ ] Convert what i can to rust and make it main branch [ ] Fix refactoring.nvim +[ ] Fix debugging https://github.com/mfussenegger/nvim-dap + +Future plugins ? ⚡ + - https://github.com/polirritmico/telescope-lazy-plugins.nvim + - https://github.com/s1n7ax/nvim-search-and-replace + - https://github.com/nvim-pack/nvim-spectre + - https://github.com/AckslD/muren.nvim/ + - https://github.com/SirVer/ultisnips?tab=readme-ov-file + - https://github.com/Bekaboo/dropbar.nvim | https://github.com/utilyre/barbecue.nvim + - https://github.com/willothy/veil.nvim + + diff --git a/lazy-lock.json b/lazy-lock.json index ad0a7e9..43b3f8e 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,6 +1,6 @@ { "LuaSnip": { "branch": "master", "commit": "500981ff6cefc7343e3959ef0f939bd0bfd49ba9" }, - "SchemaStore.nvim": { "branch": "main", "commit": "b788bde023f9fbc2eb86e89d32c0bf98a60ae406" }, + "SchemaStore.nvim": { "branch": "main", "commit": "9f74c6a52f4f6adaf3b3d64b15d2363219afefae" }, "bufferline.nvim": { "branch": "main", "commit": "64e2c5def50dfd6b6f14d96a45fa3d815a4a1eef" }, "cellular-automaton.nvim": { "branch": "main", "commit": "b7d056dab963b5d3f2c560d92937cb51db61cb5b" }, "clangd_extensions.nvim": { "branch": "main", "commit": "34c8eaa12be192e83cd4865ce2375e9f53e728f2" }, @@ -11,10 +11,10 @@ "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "dashboard-nvim": { "branch": "master", "commit": "413442b12d85315fc626c44a0ce4929b213ef604" }, - "dressing.nvim": { "branch": "master", "commit": "6f212262061a2120e42da0d1e87326e8a41c0478" }, + "dressing.nvim": { "branch": "master", "commit": "18e5beb3845f085b6a33c24112b37988f3f93c06" }, "fidget.nvim": { "branch": "legacy", "commit": "2f7c08f45639a64a5c0abcf67321d52c3f499ae6" }, "flutter-tools.nvim": { "branch": "main", "commit": "01d72d9c1bdf2d454a60c5ba450f83e5ea783f6a" }, - "go.nvim": { "branch": "master", "commit": "d217a74fa823d0adef1a3680c3af562ae14e6854" }, + "go.nvim": { "branch": "master", "commit": "9ac3e6faa32d01479973f4ca368d00b7ae328646" }, "guihua.lua": { "branch": "master", "commit": "9fb6795474918b492d9ab01b1ebaf85e8bf6fe0b" }, "impatient.nvim": { "branch": "main", "commit": "47302af74be7b79f002773011f0d8e85679a7618" }, - "indent-blankline.nvim": { "branch": "master", "commit": "821a7acd88587d966f7e464b0b3031dfe7f5680c" }, + "indent-blankline.nvim": { "branch": "master", "commit": "3d08501caef2329aba5121b753e903904088f7e6" }, diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index fcb5d5f..3ef4616 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -422,6 +422,13 @@ local vscode_disabled_plugins = { "jose-elias-alvarez/typescript.nvim", ft = { "typescript", "javascript", "typescriptreact", "javascriptreact" }, config = RequireFn("plugins.typescript_conf"), + priority = 1, + }, + + { + "dmmulroy/ts-error-translator.nvim", + ft = { "typescript", "javascript", "typescriptreact", "javascriptreact" }, + config = RequireSetupFn("ts-error-translator"), priority = 0, },