diff --git a/home/r0r5chach/.config/nvim/init.lua b/home/r0r5chach/.config/nvim/init.lua new file mode 100644 index 0000000..f90f29f --- /dev/null +++ b/home/r0r5chach/.config/nvim/init.lua @@ -0,0 +1,361 @@ +vim.loader.enable() + +local Plug = vim.fn['plug#'] + +vim.call('plug#begin') + -- General Plugins +Plug 'preservim/nerdtree' -- File Tree +Plug 'ggandor/leap.nvim' -- line hopping +Plug 'folke/todo-comments.nvim' -- Todo Comments +Plug 'folke/trouble.nvim' -- Error List +Plug 'nvim-tree/nvim-web-devicons' +Plug 'windwp/nvim-autopairs' +Plug 'tpope/vim-surround' +Plug 'RRethy/vim-illuminate' +Plug 'numToStr/Comment.nvim' +Plug 'ryanoasis/vim-devicons' +Plug 'mhinz/vim-startify' + -- Telescope +Plug 'nvim-lua/plenary.nvim' +Plug 'nvim-telescope/telescope.nvim' + -- Mason +Plug 'williamboman/mason.nvim' +Plug 'williamboman/mason-lspconfig.nvim' + -- Rust-tools +Plug 'neovim/nvim-lspconfig' +Plug 'simrat39/rust-tools.nvim' + -- Auto Complete & Snippets +Plug 'hrsh7th/nvim-cmp' -- Completion framework +Plug 'hrsh7th/cmp-nvim-lsp' -- LSP Completion Source + -- Completion Sources +Plug 'hrsh7th/cmp-nvim-lua' -- +Plug 'hrsh7th/cmp-nvim-lsp-signature-help' +Plug 'hrsh7th/cmp-vsnip' +Plug 'hrsh7th/cmp-path' +Plug 'hrsh7th/cmp-buffer' +Plug 'hrsh7th/vim-vsnip' + -- Debugging +Plug 'puremourning/vimspector' +vim.call('plug#end') + + -- Mason Setup +require("mason").setup({ + ui = { + icons = { + package_installed = "", + package_pending = "", + package_uninstalled = "", + }, + } +}) +require("mason-lspconfig").setup() + + -- Rust-tools Setup +local opts = { + tools = { -- rust-tools options + + -- how to execute terminal commands + -- options right now: termopen / quickfix / toggleterm / vimux + 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", + }, + }, + }, + + -- 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 = true, + }, -- rust-analyzer options + + -- debugging stuff + dap = { + adapter = { + type = "executable", + command = "lldb-vscode", + name = "rt_lldb", + }, + }, +} + +require('rust-tools').setup(opts) + + -- Auto Complete & Snippets setup +local cmp = require'cmp' +cmp.setup({ + -- Enable LSP snippets + snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + -- Add tab support + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.close(), + [''] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }) + }), + -- Installed sources: + sources = { + { name = 'path' }, -- file paths + { name = 'nvim_lsp', keyword_length = 3 }, -- from language server + { name = 'nvim_lsp_signature_help'}, -- display function signatures with current parameter emphasized + { name = 'nvim_lua', keyword_length = 2}, -- complete neovim's Lua runtime API such vim.lsp.* + { name = 'buffer', keyword_length = 2 }, -- source current buffer + { name = 'vsnip', keyword_length = 2 }, -- nvim-cmp source for vim-vsnip + { name = 'calc'}, -- source for math calculation + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + formatting = { + fields = {'menu', 'abbr', 'kind'}, + format = function(entry, item) + local menu_icon ={ + nvim_lsp = 'λ', + vsnip = '⋗', + buffer = 'Ω', + path = '🖫', + } + item.menu = menu_icon[entry.source.name] + return item + end, + }, +}) + +-- Telescope Setup +local builtin = require('telescope.builtin') +vim.keymap.set('n', 'ff', builtin.find_files, {}) +vim.keymap.set('n', 'fg', builtin.live_grep, {}) +vim.keymap.set('n', 'fb', builtin.buffers, {}) +vim.keymap.set('n', 'fh', builtin.help_tags, {}) + + --- Leap Setup +require('leap').create_default_mappings() + + -- Todo Comments Setup +require('todo-comments').setup() + + -- Error List Setup +require('trouble').setup() + + --- Autopairs Setup +require('nvim-autopairs').setup() + + -- Illuminate Setup +-- default configuration +require('illuminate').configure({ + -- providers: provider used to get references in the buffer, ordered by priority + providers = { + 'lsp', + 'treesitter', + 'regex', + }, + -- delay: delay in milliseconds + delay = 100, + -- filetype_overrides: filetype specific overrides. + -- The keys are strings to represent the filetype while the values are tables that + -- supports the same keys passed to .configure except for filetypes_denylist and filetypes_allowlist + filetype_overrides = {}, + -- filetypes_denylist: filetypes to not illuminate, this overrides filetypes_allowlist + filetypes_denylist = { + 'dirbuf', + 'dirvish', + 'fugitive', + }, + -- filetypes_allowlist: filetypes to illuminate, this is overridden by filetypes_denylist + -- You must set filetypes_denylist = {} to override the defaults to allow filetypes_allowlist to take effect + filetypes_allowlist = {}, + -- modes_denylist: modes to not illuminate, this overrides modes_allowlist + -- See `:help mode()` for possible values + modes_denylist = {}, + -- modes_allowlist: modes to illuminate, this is overridden by modes_denylist + -- See `:help mode()` for possible values + modes_allowlist = {}, + -- providers_regex_syntax_denylist: syntax to not illuminate, this overrides providers_regex_syntax_allowlist + -- Only applies to the 'regex' provider + -- Use :echom synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name') + providers_regex_syntax_denylist = {}, + -- providers_regex_syntax_allowlist: syntax to illuminate, this is overridden by providers_regex_syntax_denylist + -- Only applies to the 'regex' provider + -- Use :echom synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name') + providers_regex_syntax_allowlist = {}, + -- under_cursor: whether or not to illuminate under the cursor + under_cursor = true, + -- large_file_cutoff: number of lines at which to use large_file_config + -- The `under_cursor` option is disabled when this cutoff is hit + large_file_cutoff = nil, + -- large_file_config: config to use for large files (based on large_file_cutoff). + -- Supports the same keys passed to .configure + -- If nil, vim-illuminate will be disabled for large files. + large_file_overrides = nil, + -- min_count_to_highlight: minimum number of matches required to perform highlighting + min_count_to_highlight = 1, + -- should_enable: a callback that overrides all other settings to + -- enable/disable illumination. This will be called a lot so don't do + -- anything expensive in it. + should_enable = function(bufnr) return true end, + -- case_insensitive_regex: sets regex case sensitivity + case_insensitive_regex = false, +}) + + -- Comment Setup +require('Comment').setup() diff --git a/home/r0r5chach/.config/nvim/lua/keys.lua b/home/r0r5chach/.config/nvim/lua/keys.lua new file mode 100644 index 0000000..3b0edee --- /dev/null +++ b/home/r0r5chach/.config/nvim/lua/keys.lua @@ -0,0 +1,14 @@ +-- Vimspector +vim.cmd([[ +nmap call vimspector#Launch() +nmap call vimspector#StepOver() +nmap call vimspector#Reset() +nmap call vimspector#StepOver()") +nmap call vimspector#StepOut()") +nmap call vimspector#StepInto()") +]]) +map('n', "Db", ":call vimspector#ToggleBreakpoint()") +map('n', "Dw", ":call vimspector#AddWatch()") +map('n', "De", ":call vimspector#Evaluate()") + + diff --git a/home/r0r5chach/.config/nvim/lua/opts.lua b/home/r0r5chach/.config/nvim/lua/opts.lua new file mode 100644 index 0000000..c5c73df --- /dev/null +++ b/home/r0r5chach/.config/nvim/lua/opts.lua @@ -0,0 +1,24 @@ +--Set completeopt to have a better completion experience +-- :help completeopt +-- menuone: popup even when there's only one match +-- noinsert: Do not insert text until a selection is made +-- noselect: Do not select, force to select one from the menu +-- shortness: avoid showing extra messages when using completion +-- updatetime: set updatetime for CursorHold +vim.opt.completeopt = {'menuone', 'noselect', 'noinsert'} +vim.opt.shortmess = vim.opt.shortmess + { c = true} +vim.api.nvim_set_option('updatetime', 300) + +-- Fixed column for diagnostics to appear +-- Show autodiagnostic popup on cursor hover_range +-- Goto previous / next diagnostic warning / error +-- Show inlay_hints more frequently +vim.cmd([[ +set signcolumn=yes +autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false }) +]]) + +-- Treesitter folding +vim.wo.foldmethod = 'expr' +vim.wo.foldexpr = 'nvim_treesitter#foldexpr()' +