set nocompatible

so ~/.config/nvim/plugins.vim

lua <<EOF
vim.g['airline#extensions#tabline#enabled'] = 1
vim.g['airline#extensions#whitespace#enabled'] = 0
vim.g.airline_theme  = 'catppuccin'
vim.g.airline_powerline_fonts  = 1
vim.g.go_def_mapping_enabled =0
vim.g.go_gopls_enabled =1

vim.g.vimtex_view_method  = 'zathura'
vim.g.vimtex_compiler_method  = 'latexmk'
vim.g.vimtex_quickfix_enabled  = 0
vim.g.maplocalleader = ","

vim.o.errorbells = false
vim.o.title = true
vim.o.number = true
vim.o.relativenumber = true
vim.o.signcolumn = "number"
vim.o.ruler = true
vim.o.wrap = true
vim.o.scrolloff = 3
vim.o.clipboard = "unnamedplus"
vim.o.guicursor = "n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20,a:blinkon0"
vim.o.foldenable = false
vim.o.updatetime = 300
vim.o.shortmess = "filnxtToOFc"
vim.o.mouse = "ar"

vim.o.shiftwidth = 4
vim.o.tabstop = 4
vim.o.softtabstop = 0

vim.o.ignorecase = true
vim.o.smartcase = true
vim.o.incsearch = true
vim.o.hlsearch = true

require("catppuccin").setup {
	flavour = "mocha", -- latte, frappe, macchiato, mocha
	term_colors = true,
	transparent_background = true,
	no_italic = false,
	no_bold = false,
	styles = {
		comments = { "italic" },
		conditionals = {},
		loops = {},
		functions = {},
		keywords = {},
		strings = {},
		variables = {},
		numbers = {},
		booleans = {},
		properties = {},
		types = {},
	},
	color_overrides = {
		mocha = {
			base = "#000000",
			mantle = "#222222",
		},
	},
	integrations = {
		coc_nvim = true,
		native_lsp = {
			enabled = true,
			virtual_text = {
				errors = { "undercurl" },
				hints = { "italic" },
				warnings = { "undercurl" },
				information = { "italic" },
			},
			underlines = {
				errors = { "undercurl" },
				hints = { "underline" },
				warnings = { "undercurl" },
				information = { "underline" },
			},
		},
	},
	highlight_overrides = {
		mocha = function(C)
		return {
			Comment = { fg = C.sky },
			TabLineSel = { bg = C.pink },
			CmpBorder = { fg = C.surface2 },
			Pmenu = { bg = C.none },
			TelescopeBorder = { link = "FloatBorder" },
		}
		end,
	},
}

vim.o.background = "dark"
vim.o.termguicolors = true
vim.cmd.colorscheme("catppuccin-mocha")

require'telescope'.setup {
	defaults = {
		initial_mode = "normal"
	}
}

require'nvim-treesitter.configs'.setup {
	highlight = { enable = true },
	incremental_selection = { enable = true },
	textobjects = { enable = true },
}

vim.g.mapleader = ","
vim.g.coc_snippet_next = "<c-s-j>"
vim.g.coc_snippet_prev = "<c-s-k>"

vim.keymap.set('n', '//', '<cmd>nohls<cr>')
vim.keymap.set('n', ';', ':')
vim.keymap.set({'n', 'i'}, '<C-k>', '<cmd>bprev<cr>')
vim.keymap.set({'n', 'i'}, '<C-j>', '<cmd>bnext<cr>')
vim.keymap.set('n', 'K', '<cmd>call ShowDocumentation()<cr>', { silent = true })
vim.keymap.set('n', '<leader>w', ':e ')
vim.keymap.set('n', '<leader>E', '<cmd>Files<cr>')
vim.keymap.set('n', '<leader>b', '<cmd>Buffers<cr>')
vim.keymap.set('n', '<leader>d', '<cmd>bp<cr><cmd>:bd #<cr>')
vim.keymap.set('n', '<leader>rn', '<Plug>(coc-rename)')
vim.keymap.set('n', '<leader>pp', '<cmd>Prettier<cr>')
vim.keymap.set('n', '<leader>ff', '<cmd>Telescope find_files<cr>')
vim.keymap.set('n', '<leader>fg', '<cmd>Telescope live_grep<cr>')
vim.keymap.set('n', '<leader>fb', '<cmd>Telescope buffers<cr>')
vim.keymap.set('n', '<leader>fh', '<cmd>Telescope help_tags<cr>')
vim.keymap.set('n', '<leader>so', '<cmd>source ~/.config/nvim/init.vim<cr>')

vim.keymap.set('n', '[g', '<Plug>(coc-diagnostic-prev)', { silent = true })
vim.keymap.set('n', ']g', '<Plug>(coc-diagnostic-next)', { silent = true })
vim.keymap.set('n', '<leader>cl', '<Plug>(coc-codelens-action)', { silent = true })
vim.keymap.set('n', 'gd', '<Plug>(coc-definition)', { silent = true })
vim.keymap.set('n', 'gy', '<Plug>(coc-type-definition)', { silent = true })
vim.keymap.set('n', 'gi', '<Plug>(coc-implementaiton)', { silent = true })
vim.keymap.set('n', 'gr', '<Plug>(coc-references)', { silent = true })

vim.keymap.set('i', 'jj', '<Esc>')
vim.keymap.set('i', '<tab>', 'coc#pum#visible() ? coc#pum#next(1) : "<Tab>"', { expr = true, silent = true })
vim.keymap.set('i', '<s-tab>', 'coc#pum#visible() ? coc#pum#prev(1) : "<C-h>"', { expr = true, silent = true })
vim.keymap.set('i', '<cr>', 'EnterSelect()', { expr = true, silent = true })
vim.keymap.set('i', '<c-space>', 'coc#refresh()', { expr = true, silent = true })
vim.keymap.set('i', '<c-p>', '<cmd>call CocActionAsync("showSignatureHelp")<cr>a')
vim.keymap.set('i', '<c-a>', '<cmd>call CocActionAsync("codeAction", "")<cr>', { silent = true})
EOF


""""""""""""""""""""""""""""""""""""""""
"                                      "
"               KEYBINDS               "
"                                      "
""""""""""""""""""""""""""""""""""""""""

command WQ wq
command Wq q
command W w
command Q w
command! -nargs=0 Prettier :CocCommand prettier.forceFormatDocument

""""""""""""""""""""""""""""""""""""""""
"                                      "
"              FILE TYPES              "
"                                      "
""""""""""""""""""""""""""""""""""""""""


" autocmd FileType html,css,scss
 			\ setlocal ts=4 sts=4 sw=4 expandtab
" autocmd FileType javascript,typescript,typescriptreact,svelte
 			\ setlocal ts=2 sts=2 sw=2 expandtab
" autocmd BufNewFile,BufRead *.markdown,*.text
 			\ setlocal ts=2 sts=2 sw=2
" autocmd FileType sql
 			\setlocal ts=2 sts=2 sw=2 expandtab
" autocmd BufNewFile,BufRead *.md.tmpl
 			\ setlocal filetype=markdown
" autocmd BufNewFile,BufRead .*config,*.config,config
 			\ setlocal filetype=gitconfig
" autocmd BufNewFile,BufRead *.bolt
 			\ setlocal filetype=typescript
" autocmd BufNewFile,BufRead *.cql
 			\ setlocal filetype=cql
" autocmd BufNewFile,BufRead *.gradle,*.groovy
 			\ setlocal filetype=groovy
" autocmd BufNewFile,BufRead *.osgjs,*.osgjs.gz
			\ setlocal filetype=json
" autocmd BufNewFile,BufRead *.postcss
 			\ setlocal filetype=css
" autocmd BufNewFile,BufRead *.go.tpl,*.peg,*.qtpl
 			\ setlocal syntax=go
" autocmd BufNewFile,BufRead *.gunk
 			\ setlocal filetype=gunk syntax=go
" autocmd BufNewFile,BufRead *.gltf
 			\ setlocal filetype=gltf syntax=json
" autocmd BufNewFile,BufRead *.frag
 			\ setlocal filetype=glsl syntax=glsl
"
autocmd FileType json syntax match Comment +\/\/.\+$+
autocmd BufWritePre *.svelte,*.ts :silent call CocAction('runCommand', 'editor.action.organizeImport')
autocmd FileType svelte setlocal commentstring=//\ %s

augroup mygroup
  autocmd!
  autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
  autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end


function! EnterSelect()
    if coc#pum#visible() && coc#pum#info()["index"] == -1
        return "\<esc>o"

    elseif coc#pum#visible()
        return coc#_select_confirm()

    else
        return "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
endfunction

function! ShowDocumentation()
  if CocAction('hasProvider', 'hover')
    call CocActionAsync('doHover')
  else
    call feedkeys('K', 'in')
  endif
endfunction
