From c233e93c2552940d228be7adb077da47ef42761f Mon Sep 17 00:00:00 2001 From: philw Date: Mon, 13 Jan 2025 15:52:11 +0100 Subject: Update config --- init.lua | 445 +++++++++++++++++++++++++++++---------------------------------- 1 file changed, 204 insertions(+), 241 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index b6a456b..d5e104d 100644 --- a/init.lua +++ b/init.lua @@ -4,8 +4,6 @@ local keymap = vim.keymap vim.loader.enable() --- vim.g.loaded_netrw = 1 --- vim.g.loaded_netrwPlugin = 1 vim.g.netrw_banner = 0 vim.g.netrw_liststyle = 3 vim.g.netrw_altv = 0 @@ -35,265 +33,230 @@ option.clipboard = "unnamedplus" option.termguicolors = true option.fillchars = 'eob: ' option.autoindent = true +option.lazyredraw = false +option.updatetime = 300 +option.timeoutlen = 500 + + +vim.cmd [[autocmd BufWritePre lua vim.lsp.buf.format()]] 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 *.php silent! !php-cs-fixer fix % augroup END ]]) vim.cmd([[ augroup AutoDeleteNetrwHiddenBuffers - au! - au FileType netrw setlocal bufhidden=wipe +au! +au FileType netrw setlocal bufhidden=wipe augroup end ]]) vim.cmd([[ function! ToggleVExplorer() - if exists("t:expl_buf_num") - let expl_win_num = bufwinnr(t:expl_buf_num) - if expl_win_num != -1 - let cur_win_id = win_getid() - exec expl_win_num . 'windo close' - let prev_win_num = win_id2win(cur_win_id) - if prev_win_num != 0 - exec prev_win_num . 'wincmd w' - endif +if exists("t:expl_buf_num") + let expl_win_num = bufwinnr(t:expl_buf_num) + if expl_win_num != -1 + let cur_win_id = win_getid() + exec expl_win_num . 'windo close' + let prev_win_num = win_id2win(cur_win_id) + if prev_win_num != 0 + exec prev_win_num . 'wincmd w' + endif endif unlet t:expl_buf_num - else + else exec '1wincmd w' Vexplore let t:expl_buf_num = bufnr("%") - endif -endfunction -]]) - - --- Gui options --- vim.o.guifont = "Fira Code:h7" -vim.g.vimtex_view_method = "zathura" -vim.g.vimtex_compiler_method = "latexmk" -vim.g.vimtex_quickfix_mode = 0 -vim.g.tex_conceal = "abdmg" -vim.g.tex_flavor = "latex" -vim.g.gitgutter_set_sign_backgrounds = 1 - - -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", - -- { - -- 'barrientosvctor/abyss.nvim', - -- lazy = false, - -- priority = 1000, - -- opts = {} - -- }, - -- 'ryanoasis/vim-devicons', - "airblade/vim-gitgutter", - "lervag/vimtex", - -- "nvim-tree/nvim-tree.lua", - "norcalli/nvim-colorizer.lua", - "nvim-treesitter/nvim-treesitter", - "neovim/nvim-lspconfig", - "williamboman/mason.nvim", - -- "nvim-tree/nvim-web-devicons", - "williamboman/mason-lspconfig.nvim", - -- "iamcco/markdown-preview.nvim", - -- cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, - -- build = "cd app && yarn install", - -- init = function() - -- vim.g.mkdp_filetypes = { "markdown" } - -- end, - -- ft = { "markdown" } - -- , - -- { - -- 'nvimdev/lspsaga.nvim', - -- config = function() - -- require('lspsaga').setup({}) - -- end - -- }, - 'nvim-telescope/telescope.nvim', - tag = '0.1.5', - dependencies = { 'nvim-lua/plenary.nvim' }, - { - '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" }, - { "s", "Telescope buffers", desc = "Grep" }, - } - }, - { - 'windwp/nvim-autopairs', - event = "InsertEnter", - - opts = {} - }, - { - 'numToStr/Comment.nvim', - opts = {}, - lazy = false, - }, - - 'ms-jpq/coq_nvim', - { 'ms-jpq/coq.artifacts', branch = "artifacts" }, -}) - -require("colorizer").setup() -vim.api.nvim_create_autocmd('InsertEnter', { - command = 'COQnow --shut-up' -}) - -vim.api.nvim_create_autocmd("BufWritePre", { - callback = function() - vim.lsp.buf.format() - end, -}) - -local lsp_servers = { - -- rust_analyzer = { - -- imports = { - -- granularity = { - -- group = 'module', - -- }, - -- prefix = 'self', - -- }, - -- cargo = { - -- buildScripts = { - -- enable = true, - -- }, - -- }, - -- procMacro = { - -- enable = true, - -- }, - -- }, -} - - -require("mason").setup() -require("mason-lspconfig").setup { - ensure_installed = lsp_servers, - automatic_installation = true, -} - -local server_maps = function(opts) - vim.keymap.set("n", "d", vim.lsp.buf.definition, opts) -- goto def - vim.keymap.set("n", "k", vim.lsp.buf.hover, opts) -- see docs -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 - --- require("nvim-tree").setup({ --- sort = { --- sorter = "case_sensitive", --- }, --- view = { --- width = 30, --- }, --- renderer = { --- group_empty = true, --- }, --- filters = { --- dotfiles = true, --- }, --- }) - - --- require('abyss').setup({ --- italic_comments = true, --- italic = true, --- bold = true, --- transparent_background = true, --- overrides = {} --- }) - --- vim.cmd.colorscheme("abyss") -vim.cmd([[ -highlight GitGutterAdd ctermbg=none guibg=none -highlight GitGutterDelete guibg=none ctermbg=none -highlight GitGutterChange guibg=none ctermbg=none -highlight GitGutterChangeAdd guibg=none ctermbg=none -highlight GitGutterChangeDelete guibg=none ctermbg=none -highlight NonText guifg=none -highlight EndOfBuffer ctermfg=none ctermbg=none -highlight Normal ctermbg=none guibg=none -highlight signcolumn ctermbg=none guibg=none -highlight StatusLine ctermbg=none guibg=none -highlight DiagnosticError ctermbg=none guibg=none -highlight DiagnosticWarn ctermbg=none guibg=none -highlight DiagnosticInfo ctermbg=none guibg=none -highlight DiagnosticHint ctermbg=none guibg=none -highlight Pmenu ctermbg=none guibg=none - -highlight DiagnosticVirtualError ctermbg=none guibg=none -highlight DiagnosticVirtualWarn ctermbg=none guibg=none -highlight DiagnosticVirtualInfo ctermbg=none guibg=none -highlight DiagnosticVirtualHint ctermbg=none guibg=none - -highlight LspFloatWinNormal ctermbg=none guibg=none -highlight NormalFloat ctermbg=none guibg=none - -highlight LineNr ctermbg=none guibg=none -highlight StatusLineNc ctermbg=none guibg=none -highlight StatusLineNc ctermfg=none guifg=none -highlight StatusLine ctermbg=none guibg=none -highlight StatusLine ctermfg=none guifg=none - -highlight NvimTreeWinSeparator ctermfg=none guifg=none -highlight CursorColumn ctermfg=none guifg=none -highlight CursorLine ctermbg=none guibg=none - -highlight VertSplit ctermbg=none guibg=none - -highlight DiagnosticVirtualTextError ctermbg=none guibg=none -highlight DiagnosticVirtualTextWarn ctermbg=none guibg=none -highlight DiagnosticVirtualTextInfo ctermbg=none guibg=none -highlight DiagnosticVirtualTextHint ctermbg=none guibg=none -]]) + endif + endfunction + ]]) + + + -- Gui options + vim.g.vimtex_view_method = "zathura" + vim.g.vimtex_compiler_method = "latexmk" + vim.g.vimtex_quickfix_mode = 0 + vim.g.tex_conceal = "abdmg" + vim.g.tex_flavor = "latex" + vim.g.gitgutter_set_sign_backgrounds = 1 + + + 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", + lazypath, + }) + end + + vim.opt.rtp:prepend(lazypath) + require("lazy").setup({ + "airblade/vim-gitgutter", + {"lervag/vimtex", lazy = true}, + "norcalli/nvim-colorizer.lua", + "nvim-treesitter/nvim-treesitter", + { + "neovim/nvim-lspconfig", + lazy = false, + dependencies = { + { "ms-jpq/coq_nvim", branch = "coq" }, + { "ms-jpq/coq.artifacts", branch = "artifacts" }, + { 'ms-jpq/coq.thirdparty', branch = "3p" }, + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + }, + init = function() + vim.g.coq_settings = { + auto_start = 'shut-up' + } + end, + config = function() + end, + }, + 'nvim-telescope/telescope.nvim', + lazy = true, + tag = '0.1.5', + dependencies = { 'nvim-lua/plenary.nvim' }, + { + 'nvim-telescope/telescope-fzf-native.nvim', + lazy = true, + 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" }, + { "s", "Telescope buffers", desc = "Grep" }, + } + }}, + { + 'windwp/nvim-autopairs', + event = "InsertEnter", + opts = {} + } +) + + require("colorizer").setup() + + vim.api.nvim_create_autocmd("BufWritePre", { + callback = function() + vim.lsp.buf.format() + end, + }) + + local lsp_servers = { + rust_analyzer = { + imports = { + granularity = { + group = 'module', + }, + prefix = 'self', + }, + cargo = { + buildScripts = { + enable = true, + }, + }, + procMacro = { + enable = true, + }, + }, + } + + require("mason").setup({ + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗" + } + } + }) + + local server_maps = function(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 + + vim.cmd([[ + highlight GitGutterAdd ctermbg=none guibg=none + highlight GitGutterDelete guibg=none ctermbg=none + highlight GitGutterChange guibg=none ctermbg=none + highlight GitGutterChangeAdd guibg=none ctermbg=none + highlight GitGutterChangeDelete guibg=none ctermbg=none + highlight NonText guifg=none + highlight EndOfBuffer ctermfg=none ctermbg=none + highlight Normal ctermbg=none guibg=none + highlight signcolumn ctermbg=none guibg=none + highlight StatusLine ctermbg=none guibg=none + highlight DiagnosticError ctermbg=none guibg=none + highlight DiagnosticWarn ctermbg=none guibg=none + highlight DiagnosticInfo ctermbg=none guibg=none + highlight DiagnosticHint ctermbg=none guibg=none + highlight Pmenu ctermbg=none guibg=none + + highlight DiagnosticVirtualError ctermbg=none guibg=none + highlight DiagnosticVirtualWarn ctermbg=none guibg=none + highlight DiagnosticVirtualInfo ctermbg=none guibg=none + highlight DiagnosticVirtualHint ctermbg=none guibg=none + + highlight LspFloatWinNormal ctermbg=none guibg=none + highlight NormalFloat ctermbg=none guibg=none + + highlight LineNr ctermbg=none guibg=none + highlight StatusLineNc ctermbg=none guibg=none + highlight StatusLineNc ctermfg=none guifg=none + highlight StatusLine ctermbg=none guibg=none + highlight StatusLine ctermfg=none guifg=none + + highlight NvimTreeWinSeparator ctermfg=none guifg=none + highlight CursorColumn ctermfg=none guifg=none + highlight CursorLine ctermbg=none guibg=none + + highlight VertSplit ctermbg=none guibg=none + + highlight DiagnosticVirtualTextError ctermbg=none guibg=none + highlight DiagnosticVirtualTextWarn ctermbg=none guibg=none + highlight DiagnosticVirtualTextInfo ctermbg=none guibg=none + highlight DiagnosticVirtualTextHint ctermbg=none guibg=none + ]]) + + + + vim.g.mapleader = " " + keymap.set("n", "e", ":call ToggleVExplorer() ") + keymap.set("n", "z", [[:%s/\<\>//gI]]) + keymap.set("n", "a", "ggVG") + keymap.set("n", "y", "cc") + keymap.set("n", "", "yy") + keymap.set("n", "", "p") + keymap.set("n", "", "u") + keymap.set("v", "J", ":m '>+1gv=gv") + keymap.set("n", "j", "5j") + keymap.set("n", "k", "5k") + keymap.set("v", "K", ":m '<-2gv=gv") + keymap.set("n", "ca", "Lspsaga code_action") + keymap.set("n", "f", "Telescope find_files") + keymap.set("n", "g", "Telescope live_grep") + keymap.set("n", "t", "Lspsaga term_toggle ") + keymap.set("n", "d", vim.lsp.buf.definition, opts) -- goto def + keymap.set("n", "k", vim.lsp.buf.hover, opts) ---Keybinds -vim.g.mapleader = " " -keymap.set("n", "e", ":call ToggleVExplorer() ") -keymap.set("n", "z", [[:%s/\<\>//gI]]) -keymap.set("n", "a", "ggVG") -keymap.set("n", "y", "cc") -keymap.set("n", "", "yy") -keymap.set("n", "", "p") -keymap.set("n", "", "u") -keymap.set("v", "J", ":m '>+1gv=gv") -keymap.set("n", "j", "5j") -keymap.set("n", "k", "5k") -keymap.set("v", "K", ":m '<-2gv=gv") -keymap.set("n", "ca", "Lspsaga code_action") -keymap.set("n", "f", "Telescope find_files") -keymap.set("n", "g", "Telescope live_grep") -keymap.set("n", "t", "Lspsaga term_toggle ") -- cgit v1.2.3