-- Basic settings vim.o.number = true -- Enable line numbers vim.o.tabstop = 2 -- Number of spaces a tab represents vim.o.shiftwidth = 2 -- Number of spaces for each indentation vim.o.expandtab = true -- Convert tabs to spaces vim.o.smartindent = true -- Automatically indent new lines vim.o.wrap = true -- Disable line wrapping vim.o.cursorline = true -- Highlight the current line -- vim.o.termguicolors = true -- Enable 24-bit RGB colors vim.o.clipboard = "unnamedplus" -- Syntax highlighting and filetype plugins vim.cmd('syntax enable') vim.cmd('filetype plugin indent on') require('neo-tree').setup({ filesystem = { filtered_items = { hide_dotfiles = false } } }) vim.lsp.enable('clangd') -- set autocomplete behavior. -- fuzzy = fuzzy search in results -- menuone = show menu, even if there is only 1 item -- popup = show extra info in popup -- noselect = don't insert the text until an item is selected vim.cmd('set completeopt=fuzzy,menuone,popup,noselect') 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 -- Auto-format ("lint") on save. -- Usually not needed if server supports "textDocument/willSaveWaitUntil". if not client:supports_method('textDocument/willSaveWaitUntil') and client:supports_method('textDocument/formatting') then vim.api.nvim_create_autocmd('BufWritePre', { group = vim.api.nvim_create_augroup('my.lsp', {clear=false}), buffer = args.buf, callback = function() vim.lsp.buf.format({ bufnr = args.buf, id = client.id, timeout_ms = 1000 }) end, }) end end, })