Switched to lazy vim as packer stopped working.

Will need to clear the .local/shared/nvim/site directory to stop using
the packer packages.
I guess I made a build and run? that's neat.
This commit is contained in:
Tyler White 2024-01-29 16:53:18 +08:00
parent 4a09b836c1
commit 48eb0d8d60
5 changed files with 90 additions and 23 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
[Pp]lugin/ [Pp]lugin/
lazy-lock.json

View File

@ -1,6 +1,25 @@
-- Only required if you have packer configured as `opt` 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({
"morhetz/gruvbox",
"neovim/nvim-lspconfig",
{ "nvim-telescope/telescope.nvim", dependencies = {"nvim-lua/plenary.nvim"} },
"windwp/nvim-autopairs",
"sheerun/vim-polyglot",
"habamax/vim-godot",
})
require('statusline') require('statusline')
require('packer_init') --require('packer_init')
require('keybindings') require('keybindings')
--vim.opt.guicursor = " " --vim.opt.guicursor = " "

View File

@ -28,6 +28,25 @@ local function get_build_cmd()
return "" return ""
end end
local function get_buildnrun_cmd()
for path, type in vim.fs.dir(vim.fn.getcwd(), nil)
do
if (path == "build.zig") then
return "zig build run"
end
-- TODO(twig): build and run on other langauges
--if (path == "build.bat" or path == "build.sh") then
-- if (vim.loop.os_uname().sysname == "Windows_NT") then
-- -- TODO(twig): if I move to llvm this should work, right now cl doesn't work because nvim spawns a command prompt that doesn't have vcvars in it (nor does it have my stuff)
-- return "build.bat"
-- else
-- -- TODO(twig): this is untested!
-- return "./build.sh"
-- end
--end
end
return ""
end
function save_all_and_build() function save_all_and_build()
if job_id then if job_id then
print("Job processing") print("Job processing")
@ -53,3 +72,30 @@ function save_all_and_build()
job_id = vim.fn.termopen(build_cmd, {on_exit = job_exit}) job_id = vim.fn.termopen(build_cmd, {on_exit = job_exit})
vim.api.nvim_buf_set_name(job_buffer, '[build]') vim.api.nvim_buf_set_name(job_buffer, '[build]')
end end
function save_all_and_buildnrun()
if job_id then
print("Job processing")
return
end
local opts = {}
vim.api.nvim_exec('wa', opts)
if not has_buffer() then
job_buffer = vim.api.nvim_create_buf(true, true)
end
local job_window = vim.fn.bufwinnr(job_buffer)
if job_window ~= -1 then
vim.cmd(job_window .. ' wincmd w')
else
vim.cmd('buffer ' .. job_buffer)
end
vim.api.nvim_buf_set_option(job_buffer, 'filetype', 'build')
vim.api.nvim_buf_set_option(job_buffer, 'modified', false)
-- THis looks at files in the cwd and decides if there is something to build (build.zig for zig, build.bat/.sh for c++)
local build_cmd = get_build_cmd()
job_id = vim.fn.termopen(build_cmd, {on_exit = job_exit})
vim.api.nvim_buf_set_name(job_buffer, '[build]')
end

View File

@ -10,6 +10,7 @@ vim.keymap.set('n', '<leader>e', '<cmd>Ex<CR>', opts)
vim.keymap.set('n', '<leader>ff', tbuiltin.find_files, opts) vim.keymap.set('n', '<leader>ff', tbuiltin.find_files, opts)
vim.keymap.set('n', '<leader>fb', '<cmd>Telescope buffers<cr>', opts) vim.keymap.set('n', '<leader>fb', '<cmd>Telescope buffers<cr>', opts)
vim.keymap.set('n', '<leader>bb', save_all_and_build, opts) vim.keymap.set('n', '<leader>bb', save_all_and_build, opts)
vim.keymap.set('n', '<leader>br', save_all_and_buildnrun, opts)
-- TODO: get fancy and read the commentstring and user -- TODO: get fancy and read the commentstring and user
vim.keymap.set('i', '<A-t>', '// TODO(twig): ', opts) vim.keymap.set('i', '<A-t>', '// TODO(twig): ', opts)
vim.keymap.set('i', '<A-y>', '// NOTE(twig): ', opts) vim.keymap.set('i', '<A-y>', '// NOTE(twig): ', opts)

View File

@ -1,21 +1,21 @@
vim.cmd [[packadd packer.nvim]] --vim.cmd [[packadd packer.nvim]]
--
return require('packer').startup(function(use) --return require('packer').startup(function(use)
-- Packer can manage itself -- -- Packer can manage itself
use 'wbthomason/packer.nvim' -- use 'wbthomason/packer.nvim'
-- themes -- -- themes
--use 'sainnhe/everforest' -- --use 'sainnhe/everforest'
--use 'sainnhe/sonokai' -- --use 'sainnhe/sonokai'
--use { 'tomasr/molokai' } -- --use { 'tomasr/molokai' }
use 'morhetz/gruvbox' -- use 'morhetz/gruvbox'
-- Treesitter -- -- Treesitter
--use { 'nvim-treesitter/nvim-treesitter' } -- --use { 'nvim-treesitter/nvim-treesitter' }
--use 'nvim-treesitter/nvim-treesitter-context' -- --use 'nvim-treesitter/nvim-treesitter-context'
--use { 'nvim-treesitter/playground', requires = {{'nvim-treesitter/nvim-treesitter'}} } -- --use { 'nvim-treesitter/playground', requires = {{'nvim-treesitter/nvim-treesitter'}} }
-- Utils -- -- Utils
use 'neovim/nvim-lspconfig' -- use 'neovim/nvim-lspconfig'
use { 'nvim-telescope/telescope.nvim', tag = '0.1.0', requires = {{'nvim-lua/plenary.nvim'}} } -- use { 'nvim-telescope/telescope.nvim', tag = '0.1.0', requires = {{'nvim-lua/plenary.nvim'}} }
use { 'windwp/nvim-autopairs' } -- use { 'windwp/nvim-autopairs' }
use 'sheerun/vim-polyglot' -- use 'sheerun/vim-polyglot'
use 'habamax/vim-godot' -- use 'habamax/vim-godot'
end) --end)