-- Options
--- ui
vim.opt.number = true
vim.opt.syntax = 'on'
vim.opt.smartcase = true
vim.opt.statusline = "%F %{wordcount().words} words"
vim.opt.wrap = false -- don't wrap text

--- clipboard
vim.opt.clipboard = 'unnamedplus'

-- Enable lazy.vim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

vim.g.mapleader = " " -- Make sure to set `mapleader` before lazy so your mappings are correct

plugins = {
	"folke/which-key.nvim",
	{ "folke/neoconf.nvim", cmd = "Neoconf" },
	"folke/neodev.nvim",
	{
		"neovim/nvim-lspconfig",
		["dependencies"] = { -- Dependencies define which plugins are loaded before this one
			{ "j-hui/fidget.nvim", ["opts"] = {} },
			{ "folke/neodev.nvim", ["opts"] = {} }
		},
		["name"] = "nvim-lspconfig"
	},
	{
		"nvim-treesitter/nvim-treesitter",
		["config"] = function(_, _)
			require("nvim-treesitter.configs").setup({
			        ["auto-install"] = true,
			        ["highlight"] = {
			        	["enable"] = true,
			        },
			        ["incremental-selection"] = {
			        	["enable"] = true,
			        },
			})
		end
	},
	{
                "ms-jpq/coq_nvim",
		["dependencies"] = {
			"nvim-lspconfig",
			{ "ms-jpq/coq.artifacts" },
			{ "ms-jpq/coq.thirdparty" },
		},
		["config"] = function(_, _)
			-- vim.g.coq_settings = {
			-- 	["xdg"] = true
			-- }
			-- coq.Now("--shut-up")
		end
	},
	{
		'AlexvZyl/nordic.nvim',
                lazy = false,
                priority = 1000,
                config = function()
			require'nordic'.load()
		end
	},
	"lervag/vimtex",
	{
		'jghauser/auto-pandoc.nvim',
		dependencies = { 'nvim-lua/plenary.nvim' },
		ft = "markdown",
		config = function()
			vim.api.nvim_create_autocmd("BufEnter", {
				pattern = "*.md",
				callback = function()
					vim.keymap.set("n", "go", function()
						require("auto-pandoc").run_pandoc()
					end, { silent = true, buffer = 0 })
				end,
				group = vim.api.nvim_create_augroup("setAutoPandocKeymap", {}),
				desc = "Set keymap for auto-pandoc",
			})
		end
	},
	-- {
	-- 	'nvim-lualine/lualine.nvim',
	-- 	dependencies = { 'nvim-tree/nvim-web-devicons' }
	-- },
}

require("lazy").setup(plugins)

-- Configure nvim-lspconfig to work with servers; configure coq to work with lsps
-- TODO put this in coq config block in lazy so it doesn't load every time!!!!!!!
local lspconfig = require('lspconfig')
local coq = require('coq')
lspconfig.ocamllsp.setup(coq.lsp_ensure_capabilities({}))

-- Configure vimtex
vim.g.vimtex_view_method = "zathura"


-- Configure lualine
-- require('lualine').setup {
-- 	options = {
-- 		icons_enabled = true,
-- 		theme = 'nord',
-- 	},
-- }

