diff --git a/nvim/.config/nvim/lsp/lua.lua b/nvim/.config/nvim/lsp/lua.lua new file mode 100644 index 0000000..13f1d07 --- /dev/null +++ b/nvim/.config/nvim/lsp/lua.lua @@ -0,0 +1,12 @@ +return { + cmd = { "lua-language-server" }, + root_markers = { ".luarc.json", ".luarc.jsonc" }, + filetypes = { "lua" }, + settings = { + Lua = { + runtime = { + version = "LuaJIT", + }, + }, + }, +} diff --git a/nvim/.config/nvim/lsp/rust.lua b/nvim/.config/nvim/lsp/rust.lua new file mode 100644 index 0000000..7fbe39f --- /dev/null +++ b/nvim/.config/nvim/lsp/rust.lua @@ -0,0 +1,28 @@ +return { + cmd = { "rust-analyzer" }, + root_markers = { "Cargo.toml" }, + filetypes = { "rust" }, + settings = { + ["rust-analyzer"] = { + cargo = { + allFeatures = true, + loadOutDirsFromCheck = true, + runBuildScripts = true, + }, + -- Add clippy lints for Rust + checkOnSave = { + allFeatures = true, + command = "clippy", + extraArgs = { "--no-deps" }, + }, + procMacro = { + enable = true, + ignored = { + ["async-trait"] = { "async_trait" }, + ["napi-derive"] = { "napi" }, + ["async-recursion"] = { "async_recursion" }, + }, + }, + }, + }, +} diff --git a/nvim/.config/nvim/lua/ink/lsp.lua b/nvim/.config/nvim/lua/ink/lsp.lua index c7cb9c4..207911f 100644 --- a/nvim/.config/nvim/lua/ink/lsp.lua +++ b/nvim/.config/nvim/lua/ink/lsp.lua @@ -1,23 +1,42 @@ --- vim.lsp.config["luals"] = { --- -- Command and arguments to start the server. --- cmd = { "lua-language-server" }, --- -- Filetypes to automatically attach to. --- filetypes = { "lua" }, --- -- Sets the "root directory" to the parent directory of the file in the --- -- current buffer that contains either a ".luarc.json" or a --- -- ".luarc.jsonc" file. Files that share a root directory will reuse --- -- the connection to the same LSP server. --- root_markers = { ".luarc.json", ".luarc.jsonc" }, --- -- Specific settings to send to the server. The schema for this is --- -- defined by the server. For example the schema for lua-language-server --- -- can be found here https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json --- settings = { --- Lua = { --- runtime = { --- version = "LuaJIT", --- }, --- }, --- }, --- } --- --- vim.lsp.enable("luals") +vim.lsp.config("*", { + capabilities = { + textDocument = { + semanticTokens = { + multilineTokenSupport = true, + }, + }, + }, + root_markers = { ".git" }, +}) + +vim.lsp.config("lua", { + filetypes = { "lua" }, +}) + +vim.lsp.config("rust", { + filetypes = { "rust" }, +}) + +vim.lsp.enable("lua") +vim.lsp.enable("rust") +-- vim.lsp.completion.enable(true) +vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("my.lsp", {}), + callback = function(args) + local client = assert(vim.lsp.get_client_by_id(args.data.client_id)) + if client:supports_method("textDocument/implementation") then + -- Create a keymap for vim.lsp.buf.implementation ... + end + -- Enable auto-completion. Note: Use CTRL-Y to select an item. |complete_CTRL-Y| + if client:supports_method("textDocument/completion") then + -- Optional: trigger autocompletion on EVERY keypress. May be slow! + -- local chars = {}; for i = 32, 126 do table.insert(chars, string.char(i)) end + -- client.server_capabilities.completionProvider.triggerCharacters = chars + vim.lsp.completion.enable(true, client.id, args.buf, { autotrigger = true }) + end + + if client.server_capabilities.inlayHintProvider then + vim.lsp.inlay_hint.enable(true, { bufnr = bufnr }) + end + end, +}) diff --git a/nvim/.config/nvim/lua/plugins/basic.lua b/nvim/.config/nvim/lua/plugins/basic.lua index 2efb06a..6cab50b 100644 --- a/nvim/.config/nvim/lua/plugins/basic.lua +++ b/nvim/.config/nvim/lua/plugins/basic.lua @@ -30,13 +30,6 @@ return { { "gs", vim.cmd.Git, desc = "Fugitive git command" }, }, }, - { - "echasnovski/mini.surround", - version = false, - config = function() - require("mini.surround").setup() - end, - }, { "folke/flash.nvim", event = "VeryLazy", diff --git a/nvim/.config/nvim/lua/plugins/completion.lua b/nvim/.config/nvim/lua/plugins/completion.lua deleted file mode 100644 index 3fd0937..0000000 --- a/nvim/.config/nvim/lua/plugins/completion.lua +++ /dev/null @@ -1,286 +0,0 @@ -return { - -- { - -- "folke/lazydev.nvim", - -- ft = "lua", -- only load on lua files - -- opts = { - -- library = { - -- -- See the configuration section for more details - -- -- Load luvit types when the `vim.uv` word is found - -- { path = "${3rd}/luv/library", words = { "vim%.uv" } }, - -- }, - -- }, - -- }, - -- { - -- "saghen/blink.cmp", - -- -- optional: provides snippets for the snippet source - -- dependencies = { - -- "rafamadriz/friendly-snippets", - -- "Kaiser-Yang/blink-cmp-dictionary", - -- "moyiz/blink-emoji.nvim", - -- "mikavilpas/blink-ripgrep.nvim", - -- dependencies = { "nvim-lua/plenary.nvim" }, - -- }, - -- - -- -- use a release tag to download pre-built binaries - -- version = "*", - -- -- AND/OR build from source, requires nightly: - -- -- https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust - -- -- build = 'cargo build --release', - -- -- If you use nix, you can build from source using latest nightly rust with: - -- -- build = 'nix run .#build-plugin', - -- - -- ---@module 'blink.cmp' - -- ---@type blink.cmp.Config - -- opts = { - -- -- 'default' for mappings similar to built-in completion - -- -- 'super-tab' for mappings similar to vscode (tab to accept, arrow keys to navigate) - -- -- 'enter' for mappings similar to 'super-tab' but with 'enter' to accept - -- -- See the full "keymap" documentation for information on defining your own keymap. - -- keymap = { - -- preset = "super-tab", - -- }, - -- - -- completion = { - -- list = { - -- selection = { - -- preselect = function(ctx) - -- return ctx.mode ~= "cmdline" - -- end, - -- }, - -- }, - -- - -- menu = { - -- -- nvim-cmp style menu - -- draw = { - -- columns = { - -- { "label", "label_description", gap = 1 }, - -- { "kind_icon", "kind" }, - -- }, - -- }, - -- }, - -- - -- documentation = { auto_show = true, auto_show_delay_ms = 500 }, - -- - -- ghost_text = { enabled = false }, - -- }, - -- - -- appearance = { - -- -- Sets the fallback highlight groups to nvim-cmp's highlight groups - -- -- Useful for when your theme doesn't support blink.cmp - -- -- Will be removed in a future release - -- use_nvim_cmp_as_default = true, - -- -- Set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font' - -- -- Adjusts spacing to ensure icons are aligned - -- nerd_font_variant = "mono", - -- }, - -- - -- -- Default list of enabled providers defined so that you can extend it - -- -- elsewhere in your config, without redefining it, due to `opts_extend` - -- sources = { - -- --default = { 'lsp', 'path', 'snippets', 'buffer', 'ctags' }, - -- default = { "lazydev", "lsp", "path", "snippets", "buffer", "ripgrep", "emoji" }, - -- providers = { - -- lazydev = { - -- name = "LazyDev", - -- module = "lazydev.integrations.blink", - -- -- make lazydev completions top priority (see `:h blink.cmp`) - -- score_offset = 100, - -- }, - -- emoji = { - -- module = "blink-emoji", - -- name = "Emoji", - -- score_offset = 15, -- Tune by preference - -- opts = { insert = true }, -- Insert emoji (default) or complete its name - -- -- should_show_items = function() - -- -- return vim.tbl_contains( - -- -- -- Enable emoji completion only for git commits and markdown. - -- -- -- By default, enabled for all file-types. - -- -- { "gitcommit", "markdown" }, - -- -- vim.o.filetype - -- -- ) - -- -- end, - -- }, - -- ripgrep = { - -- module = "blink-ripgrep", - -- name = "Ripgrep", - -- -- the options below are optional, some default values are shown - -- ---@module "blink-ripgrep" - -- ---@type blink-ripgrep.Options - -- opts = { - -- -- For many options, see `rg --help` for an exact description of - -- -- the values that ripgrep expects. - -- - -- -- the minimum length of the current word to start searching - -- -- (if the word is shorter than this, the search will not start) - -- prefix_min_len = 3, - -- - -- -- The number of lines to show around each match in the preview - -- -- (documentation) window. For example, 5 means to show 5 lines - -- -- before, then the match, and another 5 lines after the match. - -- context_size = 5, - -- - -- -- The maximum file size of a file that ripgrep should include in - -- -- its search. Useful when your project contains large files that - -- -- might cause performance issues. - -- -- Examples: - -- -- "1024" (bytes by default), "200K", "1M", "1G", which will - -- -- exclude files larger than that size. - -- max_filesize = "1M", - -- - -- -- Specifies how to find the root of the project where the ripgrep - -- -- search will start from. Accepts the same options as the marker - -- -- given to `:h vim.fs.root()` which offers many possibilities for - -- -- configuration. If none can be found, defaults to Neovim's cwd. - -- -- - -- -- Examples: - -- -- - ".git" (default) - -- -- - { ".git", "package.json", ".root" } - -- project_root_marker = { ".git", ".terraform", "requirements.txt", "lazy-lock.json" }, - -- - -- -- Enable fallback to neovim cwd if project_root_marker is not - -- -- found. Default: `true`, which means to use the cwd. - -- project_root_fallback = true, - -- - -- -- The casing to use for the search in a format that ripgrep - -- -- accepts. Defaults to "--ignore-case". See `rg --help` for all the - -- -- available options ripgrep supports, but you can try - -- -- "--case-sensitive" or "--smart-case". - -- search_casing = "--ignore-case", - -- - -- -- (advanced) Any additional options you want to give to ripgrep. - -- -- See `rg -h` for a list of all available options. Might be - -- -- helpful in adjusting performance in specific situations. - -- -- If you have an idea for a default, please open an issue! - -- -- - -- -- Not everything will work (obviously). - -- additional_rg_options = {}, - -- - -- -- When a result is found for a file whose filetype does not have a - -- -- treesitter parser installed, fall back to regex based highlighting - -- -- that is bundled in Neovim. - -- fallback_to_regex_highlighting = true, - -- - -- -- Absolute root paths where the rg command will not be executed. - -- -- Usually you want to exclude paths using gitignore files or - -- -- ripgrep specific ignore files, but this can be used to only - -- -- ignore the paths in blink-ripgrep.nvim, maintaining the ability - -- -- to use ripgrep for those paths on the command line. If you need - -- -- to find out where the searches are executed, enable `debug` and - -- -- look at `:messages`. - -- ignore_paths = {}, - -- - -- -- Any additional paths to search in, in addition to the project - -- -- root. This can be useful if you want to include dictionary files - -- -- (/usr/share/dict/words), framework documentation, or any other - -- -- reference material that is not available within the project - -- -- root. - -- additional_paths = {}, - -- - -- -- Features that are not yet stable and might change in the future. - -- -- You can enable these to try them out beforehand, but be aware - -- -- that they might change. Nothing is enabled by default. - -- future_features = { - -- -- Keymaps to toggle features on/off. This can be used to alter - -- -- the behavior of the plugin without restarting Neovim. Nothing - -- -- is enabled by default. - -- toggles = { - -- -- The keymap to toggle the plugin on and off from blink - -- -- completion results. Example: "tg" - -- on_off = "tg", - -- }, - -- }, - -- - -- -- Show debug information in `:messages` that can help in - -- -- diagnosing issues with the plugin. - -- debug = false, - -- }, - -- -- (optional) customize how the results are displayed. Many options - -- -- are available - make sure your lua LSP is set up so you get - -- -- autocompletion help - -- transform_items = function(_, items) - -- for _, item in ipairs(items) do - -- -- example: append a description to easily distinguish rg results - -- item.labelDetails = { - -- description = "(rg)", - -- } - -- end - -- return items - -- end, - -- }, - -- }, - -- }, - -- }, - -- opts_extend = { "sources.default" }, - -- }, - -- { - -- "neovim/nvim-lspconfig", - -- dependencies = { - -- "saghen/blink.cmp", - -- -- "netmute/ctags-lsp.nvim" - -- }, - -- - -- -- example using `opts` for defining servers - -- opts = { - -- servers = { - -- -- brew install rust-analyzer - -- -- rust_analyzer = { - -- -- settings = { - -- -- ["rust-analyzer"] = {}, - -- -- }, - -- -- }, - -- -- brew install bash-language-server - -- bashls = {}, - -- -- lua_ls = { - -- -- settings = { - -- -- Lua = { - -- -- diagnostics = { - -- -- globals = { "vim" }, - -- -- undefined_global = false, -- remove this from diag! - -- -- missing_parameters = false, -- missing fields :) - -- -- }, - -- -- }, - -- -- }, - -- -- }, - -- -- ctags_lsp = {}, - -- }, - -- }, - -- config = function(_, opts) - -- local lspconfig = require("lspconfig") - -- --- brew install netmute/tap/ctags-lsp - -- -- require("lspconfig").ctags_lsp.setup({}) - -- - -- for server, config in pairs(opts.servers) do - -- -- passing config.capabilities to blink.cmp merges with the capabilities in your - -- -- `opts[server].capabilities, if you've defined it - -- config.capabilities = require("blink.cmp").get_lsp_capabilities(config.capabilities) - -- lspconfig[server].setup(config) - -- end - -- end, - -- }, - -- { - -- "mrcjkb/rustaceanvim", - -- version = "^5", -- Recommended - -- lazy = false, -- This plugin is already lazy - -- config = function() - -- vim.g.rustaceanvim = { - -- tools = { - -- float_win_config = { - -- border = { - -- { "╭", "FloatBorder" }, - -- { "─", "FloatBorder" }, - -- { "╮", "FloatBorder" }, - -- { "│", "FloatBorder" }, - -- { "╯", "FloatBorder" }, - -- { "─", "FloatBorder" }, - -- { "╰", "FloatBorder" }, - -- { "│", "FloatBorder" }, - -- }, - -- max_width = nil, - -- max_height = nil, - -- auto_focus = true, - -- }, - -- }, - -- } - -- end, - -- }, -}