diff --git a/playground/init_lazy.lua b/playground/init_lazy.lua new file mode 100644 index 0000000..91d7d96 --- /dev/null +++ b/playground/init_lazy.lua @@ -0,0 +1,106 @@ +vim.cmd([[set runtimepath=$VIMRUNTIME]]) +vim.cmd([[set packpath=/tmp/nvim/lazy]]) + +local package_root = '/tmp/nvim/lazy' +local plugin_folder = function() + local host = os.getenv('HOST_NAME') + if host and (host:find('Ray') or host:find('ray')) then + return [[~/github/ray-x]] -- vim.fn.expand("$HOME") .. '/github/' + else + return '' + end +end + +local lazypath = package_root .. '/lazy.nvim' +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + 'git', + 'clone', + '--filter=blob:none', + 'https://github.com/folke/lazy.nvim.git', + '--branch=stable', -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) +local function load_plugins() + return { + { + 'nvim-treesitter/nvim-treesitter', + config = function() + require('nvim-treesitter.configs').setup({ + ensure_installed = { 'go' }, + highlight = { enable = true }, + }) + end, + build = ':TSUpdate', + }, + { 'neovim/nvim-lspconfig' }, + { + 'simrat39/rust-tools.nvim', + config = function() + require('rust-tools').setup({ + server = { + on_attach = function(client, bufnr) + require('navigator.lspclient.mapping').setup({ client = client, bufnr = bufnr }) -- setup navigator keymaps here, + -- otherwise, you can define your own commands to call navigator functions + end, + }, + }) + end, + }, + { 'ray-x/lsp_signature.nvim', dev = (plugin_folder() ~= '') }, + { + 'ray-x/navigator.lua', + dev = (plugin_folder() ~= ''), + -- '~/github/ray-x/navigator.lua', + dependencies = { 'ray-x/guihua.lua', build = 'cd lua/fzy && make' }, + config = function() + require('navigator').setup({ + lsp = { + -- disable_lsp = { 'rust_analyzer', 'clangd' }, + }, + }) + end, + }, + { + 'ray-x/go.nvim', + dev = (plugin_folder() ~= ''), + -- dev = true, + ft = 'go', + dependencies = { + 'mfussenegger/nvim-dap', -- Debug Adapter Protocol + 'rcarriga/nvim-dap-ui', + 'theHamsta/nvim-dap-virtual-text', + 'ray-x/guihua.lua', + }, + config = function() + require('go').setup({ + verbose = true, + lsp_cfg = { + handlers = { + ['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'double' }), + ['textDocument/signatureHelp'] = vim.lsp.with( + vim.lsp.handlers.signature_help, + { border = 'round' } + ), + }, + }, -- false: do nothing + }) + end, + }, + } +end + +local opts = { + root = package_root, -- directory where plugins will be installed + default = { lazy = true }, + dev = { + -- directory where you store your local plugin projects + path = plugin_folder(), + }, +} + +require('lazy').setup(load_plugins(), opts) + +vim.cmd('colorscheme murphy') diff --git a/playground/rust/Cargo.toml b/playground/rust/Cargo.toml new file mode 100755 index 0000000..2f25955 --- /dev/null +++ b/playground/rust/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "hello" +version = "0.1.0" +authors = ["Ray-X "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/playground/rust/src/main.rs b/playground/rust/src/main.rs new file mode 100755 index 0000000..876811b --- /dev/null +++ b/playground/rust/src/main.rs @@ -0,0 +1,79 @@ +use std::io; + +trait Show { + fn show(&self) -> String; +} + +impl Show for i32 { + fn show(&self) -> String { + format!("four-byte signed {}", self) + } +} + +impl Show for f64 { + fn show(&self) -> String { + format!("eight-byte float {}", self) + } +} +fn another_function(x: i32, y: i32) { + println!("The value of x is: {}, y {}", x, y); +} +fn fun1(x: i32, y: i32) { + println!("The value of x is: {}, y {}", x, y); +} + +fn add(left: i32, right: i32) -> i32 { + return left + right; +} + +fn add4(left: i32, right: i32, t: i32, f: i32) -> i32 { + return left + right + t + f; +} + +struct Foo<'a> { + x: &'a i32, +} +struct Boo<'b> { + x: &'b i32, +} + +const CAMEL_CASE: i32 = 42; + +fn bug(left: i32, rigth: i32) -> i32 { + return left; +} + +fn test_signature(a: i32, b: i32, c: i32) -> i32 { + a + b - c +} +fn test(a: i32) {} +fn test2() { + test(1) +} +fn test3() { + test(1); + test2() +} + +fn main() { + test_signature(1, 2, 3); + let x = || 42; + bug(x(), 32); + bug(x(), 32); + + add(add(1, 2), 3); + add(add(1, 2), 3); + let answer = 42; + let maybe_pi = 3.14; + let v: Vec<&Show> = vec![&answer, &maybe_pi]; + for d in v.iter() { + println!("show {}", d.show()); + } + add4(1, 2, 3, add(1, 2)); + add4(add(1, 2), 3, add(3, 4), 4); + let y = &5; // this is the same as `let _y = 5; let y = &_y;` + let f = Foo { x: y }; + let z = &5; // this is the same as `let _y = 5; let y = &_y;` + let f22 = Boo { x: z }; + another_function(11, 2); +}