-------------------------------------------------------------------------------- -- nvim-tree -------------------------------------------------------------------------------- require('nvim-tree').setup({ auto_reload_on_write = true, disable_netrw = false, hijack_netrw = true, sort_by = 'case_sensitive', view = { width = 30, number = true, relativenumber = true, mappings = { list = { { key = 'u', action = 'dir_up' }, }, }, }, renderer = { group_empty = false, highlight_git = true, icons = { symlink_arrow = ' ➛ ', glyphs = { modified = '●', git = { unstaged = '✗', staged = '✓', unmerged = '', renamed = '➜', untracked = '[ ]', deleted = '', ignored = '◌', }, }, }, special_files = { 'Cargo.toml', 'README.md', 'Readme.md', 'readme.md' }, symlink_destination = true, }, filters = { dotfiles = true, }, }) -------------------------------------------------------------------------------- -- nvim-cmp -------------------------------------------------------------------------------- --[[ local cmp = require'cmp' cmp.setup({ snippet = { -- REQUIRED - you must specify a snippet engine expand = function(args) vim.fn['vsnip#anonymous'](args.body) -- for `vsnip` users end, }, window = { completion = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(), }, mapping = cmp.mapping.preset.insert({ -- accept currently selected item -- set `select` to `false` to only confirm explicitly selected items [''] = cmp.mapping.confirm({ select = true }), }), sources = cmp.config.sources({ { name = 'nvim_lsp' }, { name = 'vsnip' }, }, { { name = 'buffer' }, }) }) local capabilities = require('cmp_nvim_lsp').default_capabilities() require('lspconfig')['rust_analyzer'].setup { cmd = {'rust-analyzer'}, filetypes = {'rust'}, capabilities = capabilities, } --]] -------------------------------------------------------------------------------- -- rust-tools.nvim -------------------------------------------------------------------------------- local opts = { tools = { -- rust-tools options -- 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' }, }, -- whether the hover action window gets automatically focused -- default: false auto_focus = true, }, -- 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) -- set inlay hints for the current buffer require('rust-tools').inlay_hints.set() -- enable inlay hints auto update and set them for all the buffers require('rust-tools').inlay_hints.enable() -- RustRunnables require('rust-tools').runnables.runnables() -- RustExpandMacro require'rust-tools'.expand_macro.expand_macro() -------------------------------------------------------------------------------- -- telescope -------------------------------------------------------------------------------- require('telescope').setup { defaults = { mappings = { i = { [''] = false, [''] = false, }, }, }, } vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) vim.keymap.set('n', '/', function() -- you can pass additional configuration to telescope to change theme, layout, etc require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { winblend = 10, previewer = false, }) end, { desc = '[/] Fuzzily search in current buffer' }) vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) -------------------------------------------------------------------------------- -- treesitter -------------------------------------------------------------------------------- require('nvim-treesitter.configs').setup { -- add languages to be installed here that you want installed for treesitter -- https://github.com/nvim-treesitter/nvim-treesitter#supported-languages ensure_installed = { 'bash', 'c', 'cmake', 'comment', 'cpp', 'devicetree', 'diff', 'git_rebase', 'gitcommit', 'gitignore', 'go', 'help', 'html', 'lua', 'make', 'markdown', 'nix', 'python', 'regex', 'rust', 'toml', 'tsx', 'typescript', 'vim', 'yaml' }, -- -- autoinstall languages that are not installed -- defaults to false (but you can change for yourself!) auto_install = false, highlight = { enable = true }, indent = { enable = true, disable = { 'python' } }, incremental_selection = { enable = true, keymaps = { init_selection = '', node_incremental = '', scope_incremental = '', node_decremental = '', }, }, textobjects = { select = { enable = true, lookahead = true, -- automatically jump forward to textobj, similar to targets.vim keymaps = { -- you can use the capture groups defined in textobjects.scm ['aa'] = '@parameter.outer', ['ia'] = '@parameter.inner', ['af'] = '@function.outer', ['if'] = '@function.inner', ['ac'] = '@class.outer', ['ic'] = '@class.inner', }, }, move = { enable = true, set_jumps = true, -- whether to set jumps in the jumplist goto_next_start = { [']m'] = '@function.outer', [']]'] = '@class.outer', }, goto_next_end = { [']M'] = '@function.outer', [']['] = '@class.outer', }, goto_previous_start = { ['[m'] = '@function.outer', ['[['] = '@class.outer', }, goto_previous_end = { ['[M'] = '@function.outer', ['[]'] = '@class.outer', }, }, swap = { enable = true, swap_next = { ['a'] = '@parameter.inner', }, swap_previous = { ['A'] = '@parameter.inner', }, }, }, } -- diagnostic keymaps vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) -- LSP settings -- this function gets run when an LSP connects to a particular buffer local on_attach = function(_, bufnr) -- NOTE: remember that lua is a real programming language, and as such it is possible -- to define small helper and utility functions so you don't have to repeat yourself -- many times -- -- in this case, we create a function that lets us more easily define -- mappings specific for LSP related items -- it sets the mode, buffer and description for us each time local nmap = function(keys, func, desc) if desc then desc = 'LSP: ' .. desc end vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) end nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation') nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') -- see `:help K` for why this keymap nmap(')', vim.lsp.buf.hover, 'Hover Documentation') nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') -- lesser used LSP functionality nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') nmap('wl', function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end, '[W]orkspace [L]ist Folders') -- create a command `:Format` local to the LSP buffer vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) vim.lsp.buf.format() end, { desc = 'Format current buffer with LSP' }) end -- enable the following language servers -- feel free to add/remove any LSPs that you want here they will automatically be installed -- -- add any additional override configuration in the following tables -- they will be passed to the `settings` field of the server config -- you must look up that documentation yourself local servers = { -- clangd = {}, -- gopls = {}, -- pyright = {}, -- rust_analyzer = {}, -- tsserver = {}, } -- setup neovim lua configuration require('neodev').setup() -- nvim-cmp supports additional completion capabilities, so broadcast that to servers local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) -- setup mason so it can manage external tooling require('mason').setup() -- ensure the servers above are installed local mason_lspconfig = require 'mason-lspconfig' mason_lspconfig.setup { ensure_installed = vim.tbl_keys(servers), } mason_lspconfig.setup_handlers { function(server_name) require('lspconfig')[server_name].setup { capabilities = capabilities, on_attach = on_attach, settings = servers[server_name], } end, } -------------------------------------------------------------------------------- -- nvim-cmp -------------------------------------------------------------------------------- local cmp = require 'cmp' local luasnip = require 'luasnip' luasnip.config.setup {} cmp.setup { snippet = { expand = function(args) luasnip.lsp_expand(args.body) end, }, mapping = cmp.mapping.preset.insert { [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete {}, [''] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = true, }, [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif luasnip.expand_or_jumpable() then luasnip.expand_or_jump() else fallback() end end, { 'i', 's' }), [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif luasnip.jumpable(-1) then luasnip.jump(-1) else fallback() end end, { 'i', 's' }), }, sources = { { name = 'nvim_lsp' }, { name = 'luasnip' }, }, } -------------------------------------------------------------------------------- -- catppuccin.nvim -------------------------------------------------------------------------------- require("catppuccin").setup { flavour = "mocha", -- latte, frappe, macciato, mocha background = { light = "latte", dark = "mocha", }, transparent_background = false, show_end_of_buffer = false, term_colors = false, dim_inactive = { enabled = false, shade = "dark", percentage = 0.15, }, no_italic = false, -- force no_italic no_bold = false, styles = { comments = { "italic" }, conditionals = { "italic" }, loops = {}, functions = {}, keywords = {}, strings = {}, variables = { "bold" }, numbers = {}, booleans = { "italic" }, properties = {}, types = {}, operators = { "bold" }, }, color_overrides = { mocha = { base = "#000000", mantle = "#000000", crust = "#000000", }, }, highlight_overrides = { mocha = function(C) return { TabLineSel = { bg = C.pink }, CmpBorder = {fg = C.surface }, Pmenu = { bg = C.none }, TelescopeBorder = { link = "FloatBorder" }, } end, }, custom_highlights = {}, integrations = { cmp = true, gitsigns = true, nvimtree = false, telescope = true, markdown = true, mason = true, }, } -------------------------------------------------------------------------------- -- indent-blankline.nvim -------------------------------------------------------------------------------- require('indent_blankline').setup { show_current_context = true, show_current_context_start = true, space_char_blankline = ' ', char_highlight_list = { 'IndentBlanklineIndent1', 'IndentBlanklineIndent2', 'IndentBlanklineIndent3', 'IndentBlanklineIndent4', 'IndentBlanklineIndent5', 'IndentBlanklineIndent6', }, }