init.lua: removed buildcmd, only needed in keybindings.lua
keybindings.lua: added grep_string to <leader>fs and spell_suggest to <leader>ss buildcmd.lua: searches the cwd for a build file and decides which build to use (build.zig, build.bat, build.sh)
This commit is contained in:
		
							parent
							
								
									de564b9cba
								
							
						
					
					
						commit
						4363c8d7d5
					
				
							
								
								
									
										1
									
								
								init.lua
								
								
								
								
							
							
						
						
									
										1
									
								
								init.lua
								
								
								
								
							| 
						 | 
					@ -1,5 +1,4 @@
 | 
				
			||||||
-- Only required if you have packer configured as `opt`
 | 
					-- Only required if you have packer configured as `opt`
 | 
				
			||||||
require('buildcmd')
 | 
					 | 
				
			||||||
require('statusline')
 | 
					require('statusline')
 | 
				
			||||||
require('packer_init')
 | 
					require('packer_init')
 | 
				
			||||||
require('keybindings')
 | 
					require('keybindings')
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,6 +9,25 @@ local function has_buffer()
 | 
				
			||||||
    return job_buffer and vim.fn.buflisted(job_buffer) == 1
 | 
					    return job_buffer and vim.fn.buflisted(job_buffer) == 1
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local function get_build_cmd()
 | 
				
			||||||
 | 
					    for path, type in vim.fs.dir(vim.fn.getcwd(), nil)
 | 
				
			||||||
 | 
					        do
 | 
				
			||||||
 | 
					        if (path == "build.zig") then
 | 
				
			||||||
 | 
					            return "zig build"
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					        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")
 | 
				
			||||||
| 
						 | 
					@ -29,7 +48,8 @@ function save_all_and_build()
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    vim.api.nvim_buf_set_option(job_buffer, 'filetype', 'build')
 | 
					    vim.api.nvim_buf_set_option(job_buffer, 'filetype', 'build')
 | 
				
			||||||
    vim.api.nvim_buf_set_option(job_buffer, 'modified', false)
 | 
					    vim.api.nvim_buf_set_option(job_buffer, 'modified', false)
 | 
				
			||||||
    -- TODO: if I want to get fancy I can set a build string per language.
 | 
					    -- THis looks at files in the cwd and decides if there is something to build (build.zig for zig, build.bat/.sh for c++)
 | 
				
			||||||
    job_id = vim.fn.termopen("zig build", {on_exit = job_exit})
 | 
					    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]')
 | 
					    vim.api.nvim_buf_set_name(job_buffer, '[build]')
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,6 +20,10 @@ vim.keymap.set('n', '<leader>bb', save_all_and_build, opts)
 | 
				
			||||||
-- Would love to have this be alt but that doesn't work...
 | 
					-- Would love to have this be alt but that doesn't work...
 | 
				
			||||||
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)
 | 
				
			||||||
 | 
					-- This is horrendous on windows, can't use nvim for almost a minute!
 | 
				
			||||||
 | 
					vim.keymap.set('n', 'K', '')
 | 
				
			||||||
 | 
					vim.keymap.set('n', '<leader>fs', '<cmd>Telescope grep_string<cr>', opts)
 | 
				
			||||||
 | 
					vim.keymap.set('n', '<leader>ss', '<cmd>Telescope spell_suggest', opts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local on_attach = function(client, bufnr)
 | 
					local on_attach = function(client, bufnr)
 | 
				
			||||||
   vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
 | 
					   vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue