-- START GLOBAL CONFIG vim.wo.number = true -- show numbers vim.o.scrolloff = 15 -- scrll if n lines left vim.o.hlsearch = false -- highlight search vim.o.updatetime = 20 vim.o.autoread = true vim.o.tabstop = 4 vim.o.shiftwidth = 4 vim.o.expandtab = true vim.g.mapleader = " " -- leader space vim.g.maplocalleader = " " vim.keymap.set({ "n", "v" }, "", "", { silent = true }) -- nop leader local nmap = function(keys, cmd) vim.keymap.set("n", keys, cmd, { noremap = true, silent = true }) end local vmap = function(keys, cmd) vim.keymap.set("v", keys, cmd, { noremap = true, silent = true }) end local tmap = function(keys, cmd) vim.keymap.set("t", keys, cmd, { noremap = true, silent = true }) end nmap("/", require("Comment.api").toggle.linewise.current) vmap("/", "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())") nmap("", "BufferNext") nmap("", "BufferPrevious") nmap("x", "BufferClose") nmap("h", "ToggleTerm") tmap("h", "ToggleTerm") nmap("r", "!%:p") nmap("ff", require("telescope.builtin").find_files) nmap("fw", require("telescope.builtin").live_grep) nmap("e", vim.diagnostic.open_float) -- END GLOBAL CONFIG -- START LSP local highlight_filetypes = { "*.ts", "*.tsx", "*.js", "*.jsx", "*.html", "*.lua", "*.hs" } local cmp = require("cmp") local lspconfig = require("lspconfig") local servers = { tsserver = { settings = { completions = { completeFunctionCalls = true, }, }, }, pylsp = {}, lua_ls = {}, rnix = {}, gopls = {}, tailwindcss = {}, prismals = {}, hls = {}, bashls = {}, } local cmp_capabilities = require("cmp_nvim_lsp").default_capabilities() local on_attach = function(client, bufnr) nmap("ca", vim.lsp.buf.code_action) nmap("lr", vim.lsp.buf.rename) nmap("gd", vim.lsp.buf.definition) nmap("lf", function() vim.lsp.buf.format() end) nmap("K", vim.lsp.buf.hover) nmap("gr", require("telescope.builtin").lsp_references) vim.api.nvim_create_autocmd("CursorHold", { callback = function() vim.lsp.buf.document_highlight() end, pattern = highlight_filetypes }) vim.api.nvim_create_autocmd("CursorMoved", { callback = function() vim.lsp.buf.clear_references() end, pattern = highlight_filetypes }) end cmp.setup({ snippet = { expand = function(args) require("luasnip").lsp_expand(args.body) end, }, mapping = cmp.mapping.preset.insert({ [""] = cmp.mapping.complete(), [""] = cmp.mapping.confirm({ select = true }), }), sources = cmp.config.sources({ { name = "nvim_lsp" }, { name = "luasnip" } }, { { name = "buffer" } }), }) for server, cfg in pairs(servers) do lspconfig[server].setup({ settings = cfg.settings, capabilities = cmp_capabilities, on_attach = on_attach, }) end -- END LSP require 'nvim-treesitter.configs'.setup { autotag = { enable = true, } } require("Comment").setup() require("toggleterm").setup() require("autoclose").setup() require("gitsigns").setup() require("nvim-surround").setup() require("nightfox").setup({ options = { transparent = true } }) vim.cmd.colorscheme("carbonfox")