From 2a3ee1c8f696e6f3a9972a05f8b5f8681c244a2e Mon Sep 17 00:00:00 2001 From: philw Date: Sat, 17 Feb 2024 12:42:20 +0100 Subject: Migrate to lazy and coq --- init.lua | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 163 insertions(+), 6 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 45e6811..87a9b46 100644 --- a/init.lua +++ b/init.lua @@ -1,8 +1,165 @@ ---Open this file if you want to add new plugins -require("config.packer") +-- require("config.lsp") +local option = vim.opt +local keymap = vim.keymap --- Here you can find stuff related to lsp -require("config.lsp") +--Basic Editor Setup +option.nu = true +option.tabstop = 2 +option.softtabstop = 2 +option.shiftwidth = 2 +option.expandtab = true +option.smartindent = true +option.wrap = false +option.swapfile = false +option.hlsearch = false +option.incsearch = true +option.updatetime = 50 +option.laststatus = 0 +option.signcolumn = "number" +option.autoindent = true +option.clipboard = "unnamedplus" +option.termguicolors = true +option.fillchars = 'eob: ' +option.autoindent = true --- And there goes editor customization -require("config.editor") +-- Setup Editor Theme +vim.cmd([[ +highlight GitGutterAdd ctermbg=none +highlight GitGutterAdd guibg=none +highlight NonText guifg=none +highlight EndOfBuffer ctermfg=none ctermbg=none +highlight Normal ctermbg=none +highlight Normal guibg=none +highlight signcolumn ctermbg=none +highlight signcolumn guibg=none +highlight StatusLine ctermbg=none +highlight StatusLine guibg=none +highlight DiagnosticError ctermbg=none +highlight DiagnosticError guibg=none +highlight DiagnosticWarn ctermbg=none +highlight DiagnosticWarn guibg=none +highlight DiagnosticInfo ctermbg=none +highlight DiagnosticInfo guibg=none +highlight DiagnosticHint ctermbg=none +highlight DiagnosticHint guibg=none +highlight Pmenu ctermbg=none guibg=none + +highlight DiagnosticVirtualError ctermbg=none +highlight DiagnosticVirtualError guibg=none +highlight DiagnosticVirtualWarn ctermbg=none +highlight DiagnosticVirtualWarn guibg=none +highlight DiagnosticVirtualInfo ctermbg=none +highlight DiagnosticVirtualInfo guibg=none +highlight DiagnosticVirtualHint ctermbg=none +highlight DiagnosticVirtualHint guibg=none + +highlight DiagnosticVirtualTextError ctermbg=none +highlight DiagnosticVirtualTextError guibg=none +highlight DiagnosticVirtualTextWarn ctermbg=none +highlight DiagnosticVirtualTextWarn guibg=none +highlight DiagnosticVirtualTextInfo ctermbg=none +highlight DiagnosticVirtualTextInfo guibg=none +highlight DiagnosticVirtualTextHint ctermbg=none +highlight DiagnosticVirtualTextHint guibg=none +]]) + +-- run specific commands after different file extensions +vim.cmd([[ +augroup RunPfOnSave +autocmd! +autocmd BufWritePost *.js,*.ts,*.jsx,*json,*.tsx,*.css,*.html,*.yaml,*.md silent! !prettier --write % +autocmd BufWritePost *.tex silent! :VimtexCompile +autocmd BufWritePost *.md silent! :MarkdownPreview +autocmd BufWritePost *.php silent! !php-cs-fixer fix % +augroup END +]]) + +-- Gui options +vim.o.guifont = "Fira Code:h7" +vim.g.vimtex_view_method = "zathura" +vim.g.vimtex_compiler_method = "latexrun" +vim.g.gitgutter_set_sign_backgrounds = 1 + +--Keybinds +vim.g.mapleader = " " +keymap.set("n", "e", vim.cmd.Ex) +keymap.set("n", "s", [[:%s/\<\>//gI]]) +keymap.set("n", "a", "ggVG") +keymap.set("v", "J", ":m '>+1gv=gv") +keymap.set("v", "K", ":m '<-2gv=gv") +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) +require("lazy").setup({ + "nvim-lua/plenary.nvim", + "airblade/vim-gitgutter", + "nvim-treesitter/nvim-treesitter", + "neovim/nvim-lspconfig", + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + 'nvim-telescope/telescope.nvim', + tag = '0.1.5', + dependencies = { 'nvim-lua/plenary.nvim' }, + "windwp/nvim-autopairs", + config = function() + require("nvim-autopairs").setup({}) + end, + { + 'nvim-telescope/telescope-fzf-native.nvim', + build = + 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build', + keys = { + { "/", false }, + { "f", "Telescope find_files", desc = "Find Files" }, + { "g", "Telescope live_grep", desc = "Grep" }, + { "b", "Telescope buffers", desc = "Grep" }, + } + }, + { + 'numToStr/Comment.nvim', + }, + + 'ms-jpq/coq_nvim', + { 'ms-jpq/coq.artifacts', branch = "artifacts" }, +}) + + +vim.api.nvim_create_autocmd('InsertEnter', { + command = 'COQnow --shut-up' +}) +local lsp_servers = { + clangd = {}, + lua_ls = {}, +} +require("mason").setup() +require("mason-lspconfig").setup { + ensure_installed = lsp_servers, + automatic_installation = true, +} + +local server_maps = function(opts) + vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) -- goto def + vim.keymap.set("n", "k", vim.lsp.buf.hover, opts) -- see docs + vim.keymap.set("n", "fo", function() -- format + vim.lsp.buf.format({ async = true }) + end, opts) +end + +for lsp, settings in pairs(lsp_servers) do + require("lspconfig")[lsp].setup(coq.lsp_ensure_capabilities({ + on_attach = function(_, buffer) + server_maps({ buffer = buffer }) + end, + settings = settings, + })) +end -- cgit v1.2.3