vim.cmd [[packadd packer.nvim]] return require('packer').startup(function() -- packer use 'wbthomason/packer.vim' -- lspconfig use { 'neovim/nvim-lspconfig', config = function() local attachment = function(client, bufnr) local opts = { noremap=true, silent=true } vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', 'lua vim.lsp.buf.declaration()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', 'lua vim.lsp.buf.definition()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', 'lua vim.lsp.buf.implementation()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', '', 'lua vim.lsp.buf.signature_help()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'D', 'lua vim.lsp.buf.type_definition()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'rn', 'lua vim.lsp.buf.rename()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ca', 'lua vim.lsp.buf.code_action()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', 'lua vim.lsp.buf.references()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'f', 'lua vim.lsp.buf.formatting()', opts) if client.resolved_capabilities.document_formatting then vim.api.nvim_command [[augroup Format]] vim.api.nvim_command [[autocmd! * ]] vim.api.nvim_command [[autocmd BufWritePre lua vim.lsp.buf.formatting_seq_sync()]] vim.api.nvim_command [[augroup END]] end end local servers = { 'pyright', 'rust_analyzer', 'clangd' } for _, lsp in pairs(servers) do require('lspconfig')[lsp].setup { on_attach = attachment } end end, } -- treesitter use { 'nvim-treesitter/nvim-treesitter', config = function() require('nvim-treesitter.configs').setup { ensure_installed = 'maintained', sync_install = false, highlight = { enable = true, }, } end, } -- status line use { 'nvim-lualine/lualine.nvim', config = function() require('lualine').setup { options = { icons_enabled = true, -- theme = 'ayu_dark', theme = 'ayu_mirage', component_separators = { left = '', right = '' }, section_separators = { left = '', right = '' }, disabled_filetypes = {}, always_divide_middle = true, }, sections = { lualine_a = {'mode'}, lualine_b = {'filename', 'branch'}, lualine_c = { { 'diagnostics', symbols = {error = 'Errors:', warn = 'Warns:', info = 'Info:', hint = 'Hints:'}, sources = { 'nvim_diagnostic' } } }, lualine_w = {'encoding'}, lualine_x = {'filetype'}, lualine_y = {'progress'}, lualine_z = {'location'} }, inactive_sections = { lualine_a = {}, lualine_b = {}, lualine_c = {'filename'}, lualine_x = {'location'}, lualine_y = {}, lualine_z = {} }, tabline = { lualine_a = {'tabs'}, lualine_b = {}, lualine_c = {}, lualine_x = {}, lualine_y = {}, lualine_z = {} }, extensions = {} } end } use { 'nvim-telescope/telescope.nvim', requires = { {'nvim-lua/plenary.nvim'} }, config = function() vim.api.nvim_set_keymap('n', '', 'Telescope find_files', { noremap = true, silent = true }) vim.api.nvim_set_keymap('n', 'g', 'Telescope live_grep', { noremap = true, silent = true }) end, } use 'windwp/nvim-autopairs' end)