vim.g.mapleader = " " vim.opt.number = true vim.opt.relativenumber = true vim.opt.clipboard = "unnamedplus" vim.opt.termguicolors = true vim.opt.expandtab = true vim.opt.shiftwidth = 2 vim.opt.tabstop = 2 vim.opt.signcolumn = "yes" vim.opt.scrolloff = 5 vim.opt.showmode = false vim.pack.add({ { src = "https://github.com/neovim/nvim-lspconfig" }, { src = "https://github.com/hrsh7th/nvim-cmp" }, { src = "https://github.com/hrsh7th/cmp-nvim-lsp" }, { src = "https://github.com/L3MON4D3/LuaSnip" }, { src = "https://github.com/saadparwaiz1/cmp_luasnip" }, { src = "https://github.com/rafamadriz/friendly-snippets" }, { src = "https://github.com/nvim-treesitter/nvim-treesitter", build = ":TSUpdate" }, { src = "https://github.com/echasnovski/mini.nvim" }, { src = "https://github.com/stevearc/oil.nvim" }, { src = "https://github.com/nvim-telescope/telescope.nvim" }, { src = "https://github.com/nvim-lua/plenary.nvim" }, { src = "https://github.com/lukas-reineke/indent-blankline.nvim" }, { src = "https://github.com/folke/which-key.nvim" }, { src = "https://github.com/stevearc/conform.nvim" }, { src = "https://github.com/windwp/nvim-autopairs" }, { src = "https://github.com/nvim-tree/nvim-web-devicons" }, { src = "https://github.com/nvim-lualine/lualine.nvim" }, { src = "https://github.com/norcalli/nvim-colorizer.lua" }, { src = "https://github.com/WTFox/jellybeans.nvim" }, }) vim.cmd("colorscheme jellybeans") require("lualine").setup({ options = { section_separators = '', component_separators = '' }, sections = { lualine_a = { 'mode' }, lualine_y = { 'branch' }, lualine_z = { 'filename' }, lualine_b = {}, lualine_c = {}, lualine_x = {}, }, }) require("nvim-treesitter").setup({ ensure_installed = { "lua", "vim", "bash", "json", "python", "cpp", "css", "java", "c" }, highlight = { enable = true }, indent = { enable = true }, }) require("colorizer").setup() require("ibl").setup({ indent = { char = "▏" }, scope = { enabled = false }, }) require("mini.surround").setup() require("which-key").setup() require("nvim-autopairs").setup() require("oil").setup({ view_options = { show_hidden = true } }) require('telescope').setup({ defaults = { border = true, borderchars = { "─", "│", "─", "│", "┌", "┐", "┘", "└" }, }, pickers = { find_files = { hidden = true } } }) require("conform").setup({ formatters_by_ft = { python = { "isort", "black" }, }, }) local capabilities = require("cmp_nvim_lsp").default_capabilities() local servers = { pyright = {}, html = {}, ts_ls = {}, cssls = {}, bashls = { filetypes = { "sh", "zsh" }, }, clangd = { cmd = { "clangd", "--compile-commands-dir=." }, }, lua_ls = { settings = { Lua = { diagnostics = { globals = { "vim" }, }, }, }, }, } for server, config in pairs(servers) do config.capabilities = capabilities vim.lsp.config(server, config) vim.lsp.enable(server) end local cmp = require("cmp") local luasnip = require("luasnip") local cmp_autopairs = require("nvim-autopairs.completion.cmp") require("luasnip.loaders.from_vscode").lazy_load() cmp.setup({ snippet = { expand = function(args) luasnip.lsp_expand(args.body) end, }, mapping = cmp.mapping.preset.insert({ [""] = 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" }), [""] = cmp.mapping.confirm({ select = true }), }), sources = { { name = "nvim_lsp" }, { name = "luasnip" }, }, }) cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) local s = luasnip.snippet local t = luasnip.text_node local i = luasnip.insert_node luasnip.add_snippets("markdown", { s("s#", { t("Switch# "), i(0) }), s("sc", { t("Switch(config)# "), i(0) }), s("sci", { t({ "", "Switch(config-if)# " }), i(0) }), s("scir", { t({ "", "Switch(config-if-range)# " }), i(0) }), s("r#", { t("Router# "), i(0) }), s("rc", { t("Router(config)# "), i(0) }), s("rci", { t({ "", "Router(config-if)# " }), i(0) }), s("rcir", { t({ "", "Router(config-if-range)# " }), i(0) }), s("rcr", { t({ "", "Router(config-router)# " }), i(0) }), }) vim.api.nvim_create_autocmd("TextYankPost", { callback = function() vim.highlight.on_yank({ timeout = 150 }) end, }) -- vim.api.nvim_create_autocmd('LspAttach', { -- callback = function(args) -- vim.bo[args.buf].formatexpr = nil -- vim.bo[args.buf].omnifunc = nil -- vim.lsp.document_color.enable(false) -- end, -- }) local builtin = require('telescope.builtin') local map = vim.keymap.set map("n", "o", "Oil", { desc = "Open parent directory" }) map("n", "c", require("conform").format, { desc = "Format code" }) map('n', 'ff', builtin.find_files, { desc = "Find files" }) map('n', 'fg', builtin.live_grep, { desc = "Live grep" }) map('n', 'fb', builtin.buffers, { desc = "Find buffers" }) map('n', 'fh', builtin.help_tags, { desc = "Help tags" }) map('n', 'gd', builtin.lsp_definitions, { desc = "Go to definition" }) map('n', 'gr', builtin.lsp_references, { desc = "References" }) map('n', 'gi', builtin.lsp_implementations, { desc = "Implementations" }) map('n', 'ds', builtin.lsp_document_symbols, { desc = "Document symbols" }) map('n', 'ws', builtin.lsp_workspace_symbols, { desc = "Workspace symbols" }) map('n', 'rn', vim.lsp.buf.rename, { desc = "Rename symbol" }) map("n", "K", vim.lsp.buf.hover, { desc = "Hover docs" }) map("n", "M", vim.lsp.buf.signature_help, { desc = "Signature help" }) map('n', ']', vim.diagnostic.goto_next, { desc = "Next diagnostic" }) map('n', '[', vim.diagnostic.goto_prev, { desc = "Prev diagnostic" }) map('n', 'e', vim.diagnostic.open_float, { desc = "Line diagnostics" }) map("n", "bd", "bdelete", { desc = "Delete buffer" }) map("n", "", "bnext", { desc = "Next buffer" }) map("n", "", "bprevious", { desc = "Prev buffer" })