new file: after/plugin/codex_unmap.lua

modified:   ftplugin/html.lua
      new file:   ftplugin/text.lua
      modified:   ftplugin/yaml.lua
      modified:   lua/config.lua
      modified:   lua/functions.lua
      modified:   lua/keybinds.lua
      modified:   lua/lsp.lua
      modified:   lua/plugins.lua
This commit is contained in:
2021-12-18 15:37:19 -06:00
parent 37c0127980
commit 68d9b480f6
9 changed files with 348 additions and 36 deletions
+1
View File
@@ -0,0 +1 @@
vim.api.nvim_del_keymap("n", "<leader>co")
+2 -2
View File
@@ -1,2 +1,2 @@
vim.opt.shiftwidth = 2
vim.opt.tabstop = 2
vim.bo.shiftwidth = 2
vim.bo.tabstop = 2
+21
View File
@@ -0,0 +1,21 @@
local function local_map(mode, lhs, rhs, opts)
local options = {noremap = true}
if opts then
options = vim.tbl_extend("force", options, opts)
end
vim.api.nvim_buf_set_keymap(0, mode, lhs, rhs, options)
end
local function silent_map(mode, lhs, rhs)
local_map(mode, lhs, rhs, {silent = true})
end
silent_map("n", "<Up>", "gk")
silent_map("n", "<Down>", "gj")
silent_map("n", "<Home>", "g<Home>")
silent_map("n", "<End>", "g<End>")
silent_map("i", "<Up>", "<C-o>gk")
silent_map("i", "<Down>", "<C-o>gj")
silent_map("i", "<Home>", "<C-o>g<Home>")
silent_map("i", "<End>", "<C-o>g<End>")
+2 -2
View File
@@ -1,2 +1,2 @@
vim.opt.shiftwidth = 4
vim.opt.tabstop = 4
vim.bo.shiftwidth = 4
vim.bo.tabstop = 4
+59 -3
View File
@@ -46,11 +46,24 @@ opt.titlestring = [[NVIM: [%{fnamemodify(getcwd(), ':t')}] %t]]
opt.cursorline = true
opt.cursorcolumn = true
-- disable highlight outside of search and replace
vim.cmd [[
" Enable highlighting all the matches in incsearch mode
" But don't enable hlsearch always
augroup vimrc-incsearch-highlight
autocmd!
autocmd CmdlineEnter [/\?:] :set hlsearch
autocmd CmdlineLeave [/\?:] :set nohlsearch
augroup END
]]
------------------
-- ONEDARK.NVIM --
------------------
g.onedark_toggle_style_keymap = "<nop>"
--g.onedark_style = "cool"
g.onedark_style = "darker"
g.onedark_toggle_style_keymap = "<nop>"
--g.onedark_darker_diagnostics = false
----------------
-- BCLOSE.VIM --
@@ -94,7 +107,7 @@ require("lualine").setup {
sections = {
lualine_a = {"mode"},
lualine_b = {
"branch"
"FugitiveHead"
},
lualine_c = {"filename"},
lualine_x = {
@@ -104,7 +117,7 @@ require("lualine").setup {
[[string.format("%d Lines", vim.fn.line('$'))]],
{
"diagnostics",
sources = {"nvim_lsp", "ale"}
sources = {"nvim_diagnostic", "ale"}
}
},
lualine_y = {
@@ -180,3 +193,46 @@ require("harpoon").setup(
}
}
)
--------------
-- NVIM FZF --
--------------
require("fzf").default_options = {
fzf_cli_args = " --height 100% --preview='bat --color=always --style=header,grid --line-range :300 {}' "
}
----------------------
-- INDENT-BLANKLINE --
----------------------
--vim.opt.termguicolors = true
--vim.cmd [[highlight IndentBlanklineIndent1 guibg=#1f1f1f gui=nocombine]]
--vim.cmd [[highlight IndentBlanklineIndent2 guibg=#1a1a1a gui=nocombine]]
--
--require("indent_blankline").setup {
-- char = "",
-- char_highlight_list = {
-- "IndentBlanklineIndent1",
-- "IndentBlanklineIndent2"
-- },
-- space_char_highlight_list = {
-- "IndentBlanklineIndent1",
-- "IndentBlanklineIndent2"
-- },
-- show_trailing_blankline_indent = false
--}
--vim.opt.list = true
--vim.opt.listchars:append("eol:↴")
--
--require("indent_blankline").setup {
-- show_end_of_line = true
--}
--vim.opt.listchars:append("eol:↴")
vim.opt.list = true
vim.opt.listchars:append("space:⋅")
require("indent_blankline").setup {
space_char_blankline = " ",
show_current_context = true,
show_current_context_start = true
}
+135 -3
View File
@@ -6,10 +6,44 @@ local function harpoon_tab_switch()
return require("harpoon.mark").get_length() > 1
end
local bug =
[[
Weird bug:
When at home directory, `Marked.get_current_index()` returns `nil` on files.
Caused by differences in the outputs of `Marked.get_marked_file_name()`
and `require("harpoon.utils").normalize_path()`.
Example:
marked:
./code/py/old/test.py
utils:
code/py/old/test.py
]]
local harpoon_cycle_marked_file = function(up)
local step = up and 1 or -1
local Marked = require("harpoon.mark")
local current_index = Marked.get_current_index()
local number_of_items = Marked.get_length()
current_index = current_index + step
current_index = current_index % number_of_items
require("harpoon.ui").nav_file(current_index)
end
-- Dynamically switches between bnext and harpoon.ui.nav_next
function _G.harpoon_bnext()
if harpoon_tab_switch() then
require("harpoon.ui").nav_next()
--require("harpoon.ui").nav_next()
-- for some reason, next and prev have opposite directions
require("harpoon.ui").nav_prev()
--harpoon_cycle_marked_file(true)
print("Harpoon nav_next")
else
vim.api.nvim_command("bnext")
@@ -20,7 +54,10 @@ end
-- Dynamically switches between bprevious and harpoon.ui.nav_prev
function _G.harpoon_bprevious()
if harpoon_tab_switch() then
require("harpoon.ui").nav_prev()
--require("harpoon.ui").nav_prev()
-- for some reason, next and prev have opposite directions
require("harpoon.ui").nav_next()
--harpoon_cycle_marked_file(false)
print("Harpoon nav_prev")
else
vim.api.nvim_command("bprevious")
@@ -44,7 +81,7 @@ end
-- I want my bclose bindings to also remove harpoon marks
function _G.harpoon_rm_file()
require("harpoon.mark").rm_file()
vim.api.nvim_command("bd")
vim.api.nvim_command("bw")
end
-- Lualine status element for harpoon
@@ -58,3 +95,98 @@ function _G.harpoon_status()
return string.format(status_str, marked_files)
end
--[[string.format("Harpoon: %d files", require("harpoon.mark").get_length())]]
local get_harpoon_marked = function()
local Marked = require("harpoon.mark")
local contents = {}
for idx = 1, Marked.get_length() do
local file = Marked.get_marked_file_name(idx)
if file == "" then
file = "(empty)"
end
contents[idx] = string.format("%s", file)
end
return contents
end
local fzf_opts = function()
return {
width = math.floor(vim.o.columns * 0.9),
height = math.floor(vim.o.lines * 0.6)
}
end
local sleep = function(n)
local t0 = os.clock()
while os.clock() - t0 <= n do
end
end
-- Marks buffers for harpoon
function _G.fzf_buffer_add_to_harpoon()
-- Returns list of buffer file paths.
-- Does not include buffers without a file path.
local get_buffer_paths = function()
local buffers = {}
for b = 1, vim.fn.bufnr "$" do
if vim.fn.buflisted(b) ~= 0 and vim.api.nvim_buf_get_option(b, "buftype") == "" then
local buf_path = vim.fn.expand("#" .. b)
if buf_path ~= "" then
buffers[#buffers + 1] = buf_path
end
end
end
return buffers
end
local add_to_harpoon = function()
local fzf = require("fzf").fzf
local action = require "fzf.actions".action
local buf_paths = get_buffer_paths()
-- items is a table of selected or hovered fzf items
local shell =
action(
function(items, fzf_lines, fzf_cols)
-- get last item
local buf = vim.fn.bufnr(items[#items])
-- you can return either a string or a table to show in the preview
-- window
return vim.api.nvim_buf_get_lines(buf, 0, fzf_lines, false)
end
)
--''\''nvim'\'' --headless --clean --cmd '\''luafile /home/guy/.local/share/nvim/site/pack/packer/start/nvim-fzf/action_helper.lua'\'' '\''/tmp/nvimDUg2xo/3'\'' 7 {+}'
--
local results = fzf(buf_paths, " --multi ", fzf_opts())
if results then
local Marked = require("harpoon.mark")
Marked.set_mark_list(results)
--for _, p in ipairs(results) do
-- Marked.toggle_file(p)
-- --sleep(0.5)
--end
end
end
--coroutine.wrap(add_to_harpoon)()
require("fzf-commands").files({fzf = add_to_harpoon})
end
--local testing = function ()
-- coroutine.wrap(function ()
-- local fzf = require("fzf").fzf
-- fzf({}, '', { })
-- end)()
--end
-- width: 139
-- margin width: 14
-- 90% width
-- height: 35
-- margin height: 14
-- 60% height
+105 -13
View File
@@ -1,3 +1,6 @@
-- these are my custom functions
require("functions")
--local fn = vim.fn -- to call Vim functions e.g. fn.bufnr()
local function map(mode, lhs, rhs, opts)
local options = {noremap = true}
@@ -9,8 +12,6 @@ end
vim.g.mapleader = ","
require("functions")
map("v", "<C-C>", '"+y')
--map("n", "<Tab>", ":bnext<CR>")
--map("n", "<S-Tab>", ":bprevious<CR>")
@@ -22,6 +23,12 @@ map("n", "<Leader>w", [[:%s/\s\+$//e <CR>]])
--map("n", "<Leader>x", ":Bclose <CR>")
map("n", "<Leader>t", ":tabnew<CR>")
-- Move split
map("n", "<A-Right>", "<C-W><S-L>")
map("n", "<A-Left>", "<C-W><S-H>")
map("n", "<A-Up>", "<C-W><S-K>")
map("n", "<A-Down>", "<C-W><S-J>")
-- Split navigations
map("n", "<C-Right>", "<C-W><C-L>")
map("n", "<C-Left>", "<C-W><C-H>")
@@ -29,10 +36,10 @@ map("n", "<C-Up>", "<C-W><C-K>")
map("n", "<C-Down>", "<C-W><C-J>")
-- Resize split
map("n", "<M-j>", "<C-W>-")
map("n", "<M-k>", "<C-W>+")
map("n", "<M-h>", "<C-W><")
map("n", "<M-l>", "<C-W>>")
--map("n", "<A-j>", "<C-W>-")
--map("n", "<A-k>", "<C-W>+")
--map("n", "<A-h>", "<C-W><")
--map("n", "<A-l>", "<C-W>>")
-- Scroll viewport
map("n", "<S-Up>", "<C-Y>")
@@ -41,6 +48,12 @@ map("v", "<S-Up>", "<C-Y>")
map("v", "<S-Down>", "<C-E>")
map("i", "<S-Up>", "<C-X><C-Y>")
map("i", "<S-Down>", "<C-X><C-E>")
--map("n", "<PageUp>", "<C-Y>")
--map("n", "<PageDown>", "<C-E>")
--map("v", "<PageUp>", "<C-Y>")
--map("v", "<PageDown>", "<C-E>")
--map("i", "<PageUp>", "<C-X><C-Y>")
--map("i", "<PageDown>", "<C-X><C-E>")
-- Make visual yanks place the cursor back where started
map("v", "y", "ygv<Esc>")
@@ -52,30 +65,96 @@ map("v", "y", "ygv<Esc>")
---------
-- HOP --
---------
local hopword = [[<cmd>lua require'hop'.hint_words()<cr>]]
local hopline = [[<cmd>lua require'hop'.hint_lines_skip_whitespace()<cr>]]
local hop_opts = "{ create_hl_autocmd = true }"
local hopword = [[<cmd>lua require'hop'.hint_words(]] .. hop_opts .. [[)<cr>]]
local hopline = [[<cmd>lua require'hop'.hint_lines_skip_whitespace(]] .. hop_opts .. [[)<cr>]]
--map("n", "<m-l>", hopline, {silent = true})
--map("v", "<m-l>", hopline, {silent = true})
--map("n", "<m-w>", hopword, {silent = true})
--map("v", "<m-w>", hopword, {silent = true})
map("n", "W", hopline, {silent = true})
map("v", "W", hopline, {silent = true})
map("n", "w", hopword, {silent = true})
map("v", "w", hopword, {silent = true})
-- args: direction: bool, inclusive: bool
-- inclusive is broken in hop as of this comment
local hop_hint_char1 = function(args)
local direction = args.forward and "AFTER_CURSOR" or "BEFORE_CURSOR"
local inclusive = args.inclusive and "true" or "false"
return ("<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection." ..
direction .. ", current_line_only = true, inclusive_jump = " .. inclusive .. " })<cr>")
end
vim.api.nvim_set_keymap("", "f", hop_hint_char1({forward = true, inclusive = false}), {})
vim.api.nvim_set_keymap("", "F", hop_hint_char1({forward = false, inclusive = false}), {})
vim.api.nvim_set_keymap("", "t", hop_hint_char1({forward = true, inclusive = false}), {})
vim.api.nvim_set_keymap("", "T", hop_hint_char1({forward = false, inclusive = false}), {})
-- place this in one of your configuration file(s)
--vim.api.nvim_set_keymap(
-- "n",
-- "f",
-- "<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.AFTER_CURSOR, current_line_only = true })<cr>",
-- {}
--)
--vim.api.nvim_set_keymap(
-- "n",
-- "F",
-- "<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.BEFORE_CURSOR, current_line_only = true })<cr>",
-- {}
--)
--vim.api.nvim_set_keymap(
-- "",
-- "f",
-- "<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.AFTER_CURSOR, current_line_only = true, inclusive_jump = true })<cr>",
-- {}
--)
--vim.api.nvim_set_keymap(
-- "",
-- "F",
-- "<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.BEFORE_CURSOR, current_line_only = true, inclusive_jump = true })<cr>",
-- {}
--)
--vim.api.nvim_set_keymap(
-- "",
-- "t",
-- "<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.AFTER_CURSOR, current_line_only = true })<cr>",
-- {}
--)
--vim.api.nvim_set_keymap(
-- "",
-- "T",
-- "<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.BEFORE_CURSOR, current_line_only = true })<cr>",
-- {}
--)
---------
-- FZF --
---------
map("n", "<Leader>o", ":Files<CR>")
map("n", "<Leader>O", [[:lua vim.fn['fzf#vim#files']('~/') <CR>]])
map("n", "<Leader>g", ":GFiles <CR>")
map("n", "<Leader>p", ":Buffers <CR>")
--map("n", "<Leader>O", [[:lua vim.fn['fzf#vim#files']('~/')<CR>]])
map("n", "<Leader>O", ":Files ~/<CR>")
map("n", "<Leader>b", ":Buffers<CR>")
map("n", "<Leader>h", ":Helptags<CR>")
map("n", "<Leader>;", ":History:<CR>")
map("n", "<Leader>c", ":Commands<CR>")
map("n", "<Leader>s", ":Rg <CR>")
map("n", "<Leader>r", ":Rg<CR>")
map("n", "<Leader>s", ":Lines<CR>")
--map("n", "<Leader>[", ":Windows <CR>")
map("n", "<Leader>gf", ":GFiles<CR>")
map("n", "<Leader>gn", ":GFiles?<CR>")
map("n", "<Leader>gc", ":Commits<CR>")
------------------
-- FZF-CHECKOUT --
------------------
map("n", "<Leader>gb", ":GBranches<CR>")
---------
-- ALE --
---------
@@ -88,9 +167,22 @@ map("n", "<Leader>s", ":Rg <CR>")
--map("n", "<Leader>m", [[:lua require("harpoon.mark").add_file() <CR>]])
map("n", "<Leader>x", ":lua harpoon_rm_file()<CR>")
map("n", "<Leader>m", [[:lua harpoon_toggle_file()<CR>]])
--map("n", "<Leader>m", [[:lua harpoon_toggle_file()<CR>]])
map("n", "<Leader>M", [[:lua harpoon_clear_all()<CR>]])
map("n", "<Leader>l", [[:lua require("harpoon.ui").toggle_quick_menu()<CR>]])
--map("n", "<Leader>n", [[:lua require("harpoon.ui").nav_next() <CR>]])
--map("n", "<Leader>N", [[:lua require("harpoon.ui").nav_prev() <CR>]])
-----------
-- CODEX --
-----------
local create_completion = ":lua vim.fn.CreateCompletion(200)<CR>"
map("n", "<C-x>", create_completion)
map("i", "<C-x>", ("<C-o>" .. create_completion))
--map("i", "<C-x>", "<Esc>li<C-g>u<Esc>l:CreateCompletion<CR>")
--------------
-- NVIM FZF --
--------------
map("n", "<Leader>m", [[:lua fzf_buffer_add_to_harpoon()<CR>]])
+10 -7
View File
@@ -137,9 +137,12 @@ local common_on_attach = function(client, bufnr)
end
-- enable null-ls integration (optional)
require("null-ls").config {}
require("lspconfig")["null-ls"].setup {
-- lspconfig integration is deprecated; pass options to setup instead
--require("null-ls").config {}
require("null-ls").setup {
on_attach = common_on_attach,
--}
--require("lspconfig")["null-ls"].setup {
handlers = {
["textDocument/publishDiagnostics"] = vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics,
@@ -200,12 +203,12 @@ require("nvim-lsp-installer").on_server_ready(
}
}
local vscode_servers = {html = "html", jsonls = "json", cssls = "css"}
local lang = vscode_servers[server.name]
--local vscode_servers = {html = "html", jsonls = "json", cssls = "css"}
--local lang = vscode_servers[server.name]
if lang ~= nil then
opts.cmd = {("vscode-" .. lang .. "-language-server"), "--stdio"}
end
--if lang ~= nil then
-- opts.cmd = {("vscode-" .. lang .. "-language-server"), "--stdio"}
--end
if server.name == "tsserver" then
opts.on_attach = tsserver_on_attach
+7
View File
@@ -4,6 +4,9 @@ require("packer").startup(
function()
use "wbthomason/packer.nvim"
-- OPENAI CODEX
use "tom-doerr/vim_codex"
-- NAVIGATION
use {
"phaazon/hop.nvim",
@@ -30,6 +33,8 @@ require("packer").startup(
use "junegunn/fzf.vim"
use "rbgrouleff/bclose.vim"
use "francoiscabrol/ranger.vim"
use "vijaymarupudi/nvim-fzf"
use "vijaymarupudi/nvim-fzf-commands"
-- GIT
use "tpope/vim-fugitive"
@@ -47,6 +52,8 @@ require("packer").startup(
use "dense-analysis/ale"
--use "nathanmsmith/nvim-ale-diagnostic"
use "turbio/bracey.vim"
-- init.lua
use "lukas-reineke/indent-blankline.nvim"
-- LSP
use {"nvim-treesitter/nvim-treesitter", run = ":TSUpdate"}