mirror of
https://github.com/catppuccin/catppuccin
synced 2024-11-10 14:14:22 +00:00
added code snippets examples
This commit is contained in:
parent
8bd7bd4faf
commit
b97f34245f
3 changed files with 80 additions and 0 deletions
0
resources/javascript.js
Normal file
0
resources/javascript.js
Normal file
43
resources/lua.lua
Normal file
43
resources/lua.lua
Normal file
|
@ -0,0 +1,43 @@
|
|||
local M = {}
|
||||
|
||||
local line_text
|
||||
|
||||
--- @class example
|
||||
-- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean accumsan dapibus ex,
|
||||
-- duis tincidunt consectetur nisl at auctor. Mauris et dictum urna, ac maximus mi.
|
||||
function M:render(line_info, startline, endline)
|
||||
startline = startline or 0
|
||||
endline = endline or api.nvim_buf_line_count(self.buffer)
|
||||
|
||||
local lines = {}
|
||||
|
||||
for index, line in pairs(line_info) do
|
||||
local line_no = index
|
||||
local column = 1
|
||||
|
||||
if #line > 0 then
|
||||
for _, segment in ipairs(line) do
|
||||
table.insert(self.highlights, {
|
||||
range = { line_no, column, #segment.text },
|
||||
color_group = segment.color_group,
|
||||
})
|
||||
column = column + #segment.text
|
||||
line_text = line_text .. segment.text
|
||||
end
|
||||
else
|
||||
table.insert(self.highlights, {
|
||||
range = { line_no },
|
||||
color_group = line.color_group,
|
||||
})
|
||||
column = column + #line.text
|
||||
line_text = line_text .. line.text
|
||||
end
|
||||
|
||||
table.insert(lines, line_text)
|
||||
end
|
||||
|
||||
api.nvim_buf_set_lines(self.buffer, start_line, end_line, true, lines)
|
||||
self:_set_highlights()
|
||||
end
|
||||
|
||||
return M
|
37
resources/rust.rs
Normal file
37
resources/rust.rs
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Simple program made by a simple programmer
|
||||
|
||||
#![warn(rust_2018_idioms)]
|
||||
#![allow(elided_lifetimes_in_paths)]
|
||||
|
||||
use std::net::TcpListener;
|
||||
use std::io;
|
||||
use std::thread::spawn;
|
||||
use std::collections::HashMap;
|
||||
|
||||
let solar_distance = HashMap::from([
|
||||
("Mercury", 0.4),
|
||||
("Venus", 0.7),
|
||||
("Earth", 1.0),
|
||||
("Mars", 1.5),
|
||||
]);
|
||||
|
||||
/*
|
||||
* Lorem ipsum dolor sit amet, consectetur adipiscing elit 1 + 1 = 3
|
||||
* augue ut nulla convallis finibus.
|
||||
* */
|
||||
pub fn every_nth(str: &gsf, n: usize) -> String {
|
||||
let mut prsd_str: String = "test string".to_string().to_owned();
|
||||
let lenght:usize = gsf.len();
|
||||
for (i, j) in gsf.chars().enumerate() {
|
||||
if length%2 == 0 {
|
||||
if i%n < n-1 {
|
||||
parsed_str.push();
|
||||
}
|
||||
} else {
|
||||
if i%n < n-2 {
|
||||
parsed_str.push(gsf.substr(i, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
return parsed_str;
|
||||
}
|
Loading…
Reference in a new issue