diff --git a/.luarc.json b/.luarc.json index e34fdba..e9dad33 100644 --- a/.luarc.json +++ b/.luarc.json @@ -2,6 +2,7 @@ "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", "Lua.diagnostics.globals": [ "vim", - "use" + "use", + "root_pattern" ] } \ No newline at end of file diff --git a/lua/configs/autocomplete.lua b/lua/configs/autocomplete.lua index 22fdde9..e9f5b43 100644 --- a/lua/configs/autocomplete.lua +++ b/lua/configs/autocomplete.lua @@ -60,18 +60,14 @@ function M.config() { name = 'cmdline' } }) }) - local has_words_before = function() local line, col = unpack(vim.api.nvim_win_get_cursor(0)) return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil end - local luasnip = require("luasnip") cmp.setup({ - mapping = { - [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() @@ -83,7 +79,6 @@ function M.config() fallback() end end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() @@ -93,21 +88,8 @@ function M.config() fallback() end end, { "i", "s" }), - - -- ... Your other mappings ... }, - - -- ... Your other configuration ... }) - - -- nvim-lspconfig config - -- List of all pre-configured LSP servers: - -- github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md - local servers = { 'clangd', 'rust_analyzer', 'pylsp', 'sumneko_lua', 'sourcekit' } - for _, lsp in pairs(servers) do - require('lspconfig')[lsp].setup {} - end - local devicons = require('nvim-web-devicons') cmp.register_source('devicons', { complete = function(_, _, callback) @@ -123,9 +105,15 @@ function M.config() end, }) - local saga = require 'lspsaga' + -- nvim-lspconfig config + -- List of all pre-configured LSP servers: + -- github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md + local servers = { 'clangd', 'rust_analyzer', 'pylsp', 'sumneko_lua', 'sourcekit' } + for _, lsp in pairs(servers) do + require('lspconfig')[lsp].setup {} + end - -- use default config + local saga = require 'lspsaga' saga.init_lsp_saga({ -- Options with default value -- "single" | "double" | "rounded" | "bold" | "plus" @@ -231,9 +219,6 @@ function M.config() server_filetype_map = {}, }) - require('rust-tools').setup() - - -- Lua configuration local glance = require('glance') local actions = glance.actions diff --git a/lua/configs/lang/rust.lua b/lua/configs/lang/rust.lua new file mode 100644 index 0000000..53b6311 --- /dev/null +++ b/lua/configs/lang/rust.lua @@ -0,0 +1,160 @@ +local M = {} + +function M.config() + local rt = require("rust-tools") + rt.setup { + -- how to execute terminal commands + -- options right now: termopen / quickfix + executor = require("rust-tools.executors").termopen, + + -- callback to execute once rust-analyzer is done initializing the workspace + -- The callback receives one parameter indicating the `health` of the server: "ok" | "warning" | "error" + on_initialized = nil, + + -- automatically call RustReloadWorkspace when writing to a Cargo.toml file. + reload_workspace_from_cargo_toml = true, + + -- These apply to the default RustSetInlayHints command + inlay_hints = { + -- automatically set inlay hints (type hints) + -- default: true + auto = true, + + -- Only show inlay hints for the current line + only_current_line = false, + + -- whether to show parameter hints with the inlay hints or not + -- default: true + show_parameter_hints = true, + + -- prefix for parameter hints + -- default: "<-" + parameter_hints_prefix = "<- ", + + -- prefix for all the other hints (type, chaining) + -- default: "=>" + other_hints_prefix = "=> ", + + -- whether to align to the length of the longest line in the file + max_len_align = false, + + -- padding from the left if max_len_align is true + max_len_align_padding = 1, + + -- whether to align to the extreme right or not + right_align = false, + + -- padding from the right if right_align is true + right_align_padding = 7, + + -- The color of the hints + highlight = "Comment", + }, + + -- options same as lsp hover / vim.lsp.util.open_floating_preview() + hover_actions = { + + -- the border that is used for the hover window + -- see vim.api.nvim_open_win() + border = { + { "╭", "FloatBorder" }, + { "─", "FloatBorder" }, + { "╮", "FloatBorder" }, + { "│", "FloatBorder" }, + { "╯", "FloatBorder" }, + { "─", "FloatBorder" }, + { "╰", "FloatBorder" }, + { "│", "FloatBorder" }, + }, + + -- Maximal width of the hover window. Nil means no max. + max_width = nil, + + -- Maximal height of the hover window. Nil means no max. + max_height = nil, + + -- whether the hover action window gets automatically focused + -- default: false + auto_focus = false, + }, + + -- settings for showing the crate graph based on graphviz and the dot + -- command + crate_graph = { + -- Backend used for displaying the graph + -- see: https://graphviz.org/docs/outputs/ + -- default: x11 + backend = "x11", + -- where to store the output, nil for no output stored (relative + -- path from pwd) + -- default: nil + output = nil, + -- true for all crates.io and external crates, false only the local + -- crates + -- default: true + full = true, + + -- List of backends found on: https://graphviz.org/docs/outputs/ + -- Is used for input validation and autocompletion + -- Last updated: 2021-08-26 + enabled_graphviz_backends = { + "bmp", + "cgimage", + "canon", + "dot", + "gv", + "xdot", + "xdot1.2", + "xdot1.4", + "eps", + "exr", + "fig", + "gd", + "gd2", + "gif", + "gtk", + "ico", + "cmap", + "ismap", + "imap", + "cmapx", + "imap_np", + "cmapx_np", + "jpg", + "jpeg", + "jpe", + "jp2", + "json", + "json0", + "dot_json", + "xdot_json", + "pdf", + "pic", + "pct", + "pict", + "plain", + "plain-ext", + "png", + "pov", + "ps", + "ps2", + "psd", + "sgi", + "svg", + "svgz", + "tga", + "tiff", + "tif", + "tk", + "vml", + "vmlz", + "wbmp", + "webp", + "xlib", + "x11", + }, + }, + } +end + +return M diff --git a/lua/core/init.lua b/lua/core/init.lua index b382908..afaf6f8 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -73,4 +73,6 @@ require("configs.grammar").config() require("configs.terminal").config() require("configs.ide").config() +-- require("configs.lang.rust").config() + require("core.keymaps") diff --git a/syntax/shark.vim b/syntax/shark.vim index 8dac4b3..da54254 100644 --- a/syntax/shark.vim +++ b/syntax/shark.vim @@ -8,7 +8,7 @@ if exists("b:current_syntax") endif syn case match -syn keyword sharkKeyword alias allow break case continue copy else enum extern for if import in local loop return static switch typedef while +syn keyword sharkKeyword as alias break continue else enum extern fn for if let loop mut pub return static struct true typedef union while syn keyword sharkBool true false syn keyword sharkPreProc elif else end endif ifpin include macro pin asm syn keyword sharkTypeNames u8 u16 u32 u64 i8 i16 i32 i64 usize isize f32 f64 none