This commit is contained in:
2022-02-20 03:52:11 -06:00
parent 68d9b480f6
commit 2420aee32b
10 changed files with 375 additions and 195 deletions
+3
View File
@@ -0,0 +1,3 @@
--vim.o.foldlevelstart = 4
--vim.o.foldmethod = "expr"
--vim.o.foldexpr = "nvim_treesitter#foldexpr()"
+4
View File
@@ -0,0 +1,4 @@
-- automatically opens all marked files
_G.harpoon_open_marks()
-- sets tab switch mode to harpoon marks
_G.harpoon_btoggle(true)
+3
View File
@@ -0,0 +1,3 @@
local len = 4
vim.bo.shiftwidth = len
vim.bo.tabstop = len
+4 -3
View File
@@ -4,13 +4,14 @@ local g = vim.g
g.ale_completion_enabled = false g.ale_completion_enabled = false
g.ale_linters_explicit = true g.ale_linters_explicit = true
g.ale_fix_on_save = true g.ale_fix_on_save = false
g.ale_fixers = { g.ale_fixers = {
c = {"clang-format"}, --c = {"clang-format"},
cpp = {"clang-format"}, cpp = {"clang-format"},
sh = {"shfmt"}, sh = {"shfmt"},
python = {"black"}, python = {"isort", "black"},
lua = {"luafmt"}, lua = {"luafmt"},
json = {"prettier"},
css = {"prettier"}, css = {"prettier"},
scss = {"prettier"}, scss = {"prettier"},
html = {"prettier"}, html = {"prettier"},
+27 -6
View File
@@ -11,7 +11,6 @@ opt.autoindent = true
opt.autoread = true opt.autoread = true
--opt.autowrite = true --opt.autowrite = true
opt.expandtab = true opt.expandtab = true
opt.foldenable = false
opt.hlsearch = true opt.hlsearch = true
opt.ignorecase = true opt.ignorecase = true
opt.number = true opt.number = true
@@ -46,7 +45,17 @@ opt.titlestring = [[NVIM: [%{fnamemodify(getcwd(), ':t')}] %t]]
opt.cursorline = true opt.cursorline = true
opt.cursorcolumn = true opt.cursorcolumn = true
-- disable highlight outside of search and replace --opt.foldlevel = 1
opt.foldlevelstart = 10
--opt.foldenable = false
opt.foldmethod = "indent"
--opt.foldmethod = "syntax"
--opt.foldmethod = "expr"
--opt.foldexpr = "nvim_treesitter#foldexpr()"
-----------------------------------------------------
-- DISABLE HIGHLIGHT OUTSIDE OF SEARCH AND REPLACE --
-----------------------------------------------------
vim.cmd [[ vim.cmd [[
" Enable highlighting all the matches in incsearch mode " Enable highlighting all the matches in incsearch mode
" But don't enable hlsearch always " But don't enable hlsearch always
@@ -57,14 +66,26 @@ augroup vimrc-incsearch-highlight
augroup END augroup END
]] ]]
---------------
-- PROVIDERS --
---------------
g.python3_host_prog = "/usr/bin/python3"
------------------ ------------------
-- ONEDARK.NVIM -- -- ONEDARK.NVIM --
------------------ ------------------
--g.onedark_style = "cool" --g.onedark_style = "cool"
g.onedark_style = "darker" --g.onedark_style = "darker"
g.onedark_toggle_style_keymap = "<nop>" --g.onedark_toggle_style_keymap = "<nop>"
--g.onedark_darker_diagnostics = false --g.onedark_darker_diagnostics = false
-- Lua
require("onedark").setup {
style = "darker",
toggle_style_key = "<nop>"
}
require("onedark").load()
---------------- ----------------
-- BCLOSE.VIM -- -- BCLOSE.VIM --
---------------- ----------------
@@ -139,7 +160,7 @@ require("lualine").setup {
"buffers", "buffers",
show_filename_only = false, -- shows shortened relative path when false show_filename_only = false, -- shows shortened relative path when false
show_modified_status = true, -- shows indicator then bufder is modified show_modified_status = true, -- shows indicator then bufder is modified
max_length = vim.o.columns * 6 / 7, -- maximum width of buffers component max_length = vim.o.columns * 5 / 7, -- maximum width of buffers component
filetype_names = { filetype_names = {
TelescopePrompt = "Telescope", TelescopePrompt = "Telescope",
dashboard = "Dashboard", dashboard = "Dashboard",
@@ -228,8 +249,8 @@ require("fzf").default_options = {
-- show_end_of_line = true -- show_end_of_line = true
--} --}
--vim.opt.listchars:append("eol:↴") --vim.opt.listchars:append("eol:↴")
--vim.opt.listchars:append("space:⋅")
vim.opt.list = true vim.opt.list = true
vim.opt.listchars:append("space:⋅")
require("indent_blankline").setup { require("indent_blankline").setup {
space_char_blankline = " ", space_char_blankline = " ",
+180 -115
View File
@@ -1,17 +1,9 @@
-- Determines if harpoon_bnext and harpoon_bprevious
-- should switch between buffers or harpoon marks
-- `true` - harpoon
-- `false` - buffers
local function harpoon_tab_switch()
return require("harpoon.mark").get_length() > 1
end
local bug = local bug =
[[ [[
Weird bug: Weird bug:
When at home directory, `Marked.get_current_index()` returns `nil` on files. When at home directory or in a dot directory, `Marked.get_current_index()` returns `nil` on files.
Caused by differences in the outputs of `Marked.get_marked_file_name()` Caused by differences in the outputs of `Marked.get_marked_file_name()`
and `require("harpoon.utils").normalize_path()`. and `require("harpoon.utils").normalize_path()`.
@@ -24,26 +16,110 @@ Example:
]] ]]
local harpoon_cycle_marked_file = function(up) -- true: harpoon
local step = up and 1 or -1 -- false: regular buffer
vim.g.my_harpoon_tab_switch = false
local Marked = require("harpoon.mark") -- Determines if harpoon_bnext and harpoon_bprevious
local current_index = Marked.get_current_index() -- should switch between buffers or harpoon marks
local number_of_items = Marked.get_length() -- `true` - harpoon
-- `false` - buffers
local function harpoon_tab_switch()
--return require("harpoon.mark").get_length() > 0
return vim.g.my_harpoon_tab_switch
end
current_index = current_index + step -- Checks if a table contains a value.
current_index = current_index % number_of_items local function has_value(tab, val)
for _, value in ipairs(tab) do
if value == val then
return true
end
end
require("harpoon.ui").nav_file(current_index) return false
end
local strip_dot_slash = function(str)
local first_two = string.sub(str, 1, 2)
if first_two == "./" then
str = string.sub(str, 3)
end
return str
end
local fzf_run_with_opts = function(args)
local opts = require("fzf").default_options
opts.width = math.floor(vim.o.columns * 0.9)
opts.height = math.floor(vim.o.lines * 0.6)
local old_cli_args = opts.fzf_cli_args
if args.multi then
opts.fzf_cli_args = opts.fzf_cli_args .. " --multi "
end
local results = args.fn()
opts.fzf_cli_args = old_cli_args
return results
end
-- Does a fzf function call with the default options set.
-- idk if there's a better way to do this
local fzf_call = function(args)
local fn = function()
local fzf = require("fzf").fzf
if args.flags then
return fzf(args.items, args.flags)
elseif args.items then
return fzf(args.items)
else
return fzf()
end
end
local results = fzf_run_with_opts({fn = fn, multi = args.multi})
local stripped_results = {}
for _, filepath in ipairs(results) do
stripped_results[#stripped_results + 1] = strip_dot_slash(filepath)
end
return stripped_results
end
--coroutine.wrap(fzf_call)()
-- 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] = strip_dot_slash(buf_path)
--print(buf_path)
end
end
end
return buffers
end
-- toggles tab mode
function _G.harpoon_btoggle(on)
if on == nil then
vim.g.my_harpoon_tab_switch = require("harpoon.mark").get_length() > 0 and not vim.g.my_harpoon_tab_switch
else
vim.g.my_harpoon_tab_switch = on and require("harpoon.mark").get_length() > 0
end
print(vim.g.my_harpoon_tab_switch and "Tab: Harpoon" or "Tab: Buffer")
end end
-- Dynamically switches between bnext and harpoon.ui.nav_next -- Dynamically switches between bnext and harpoon.ui.nav_next
function _G.harpoon_bnext() function _G.harpoon_bnext()
if harpoon_tab_switch() then 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") print("Harpoon nav_next")
else else
vim.api.nvim_command("bnext") vim.api.nvim_command("bnext")
@@ -54,10 +130,7 @@ end
-- Dynamically switches between bprevious and harpoon.ui.nav_prev -- Dynamically switches between bprevious and harpoon.ui.nav_prev
function _G.harpoon_bprevious() function _G.harpoon_bprevious()
if harpoon_tab_switch() then 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") print("Harpoon nav_prev")
else else
vim.api.nvim_command("bprevious") vim.api.nvim_command("bprevious")
@@ -67,13 +140,14 @@ end
-- Runs harpoon.mark.toggle_file and refreshes lualine elements -- Runs harpoon.mark.toggle_file and refreshes lualine elements
function _G.harpoon_toggle_file() function _G.harpoon_toggle_file()
require("harpoon.mark").toggle_file() require("harpoon.mark").add_file()
vim.api.nvim_command("redrawtabline") vim.api.nvim_command("redrawtabline")
vim.api.nvim_command("redrawstatus") vim.api.nvim_command("redrawstatus")
end end
function _G.harpoon_clear_all() function _G.harpoon_clear_all()
require("harpoon.mark").clear_all() require("harpoon.mark").clear_all()
_G.harpoon_btoggle()
vim.api.nvim_command("redrawtabline") vim.api.nvim_command("redrawtabline")
vim.api.nvim_command("redrawstatus") vim.api.nvim_command("redrawstatus")
end end
@@ -81,7 +155,7 @@ end
-- I want my bclose bindings to also remove harpoon marks -- I want my bclose bindings to also remove harpoon marks
function _G.harpoon_rm_file() function _G.harpoon_rm_file()
require("harpoon.mark").rm_file() require("harpoon.mark").rm_file()
vim.api.nvim_command("bw") vim.api.nvim_command("Bclose")
end end
-- Lualine status element for harpoon -- Lualine status element for harpoon
@@ -94,99 +168,90 @@ function _G.harpoon_status()
status_str = (harpoon_tab_switch() and "" or "") .. status_str status_str = (harpoon_tab_switch() and "" or "") .. status_str
return string.format(status_str, marked_files) return string.format(status_str, marked_files)
end 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 -- Marks buffers for harpoon
function _G.fzf_buffer_add_to_harpoon() local buffer_to_harpoon = function()
-- Returns list of buffer file paths. local buf_paths = get_buffer_paths()
-- Does not include buffers without a file path. local results = fzf_call({items = buf_paths, multi = true})
local get_buffer_paths = function()
local buffers = {} if results then
for b = 1, vim.fn.bufnr "$" do local sorted_results = {}
if vim.fn.buflisted(b) ~= 0 and vim.api.nvim_buf_get_option(b, "buftype") == "" then -- original buf_paths table is correctly ordered, easier to take from there
local buf_path = vim.fn.expand("#" .. b) -- and just check if each item is in results.
if buf_path ~= "" then for _, filepath in ipairs(buf_paths) do
buffers[#buffers + 1] = buf_path if has_value(results, filepath) then
end sorted_results[#sorted_results + 1] = filepath
end end
end end
local Marked = require("harpoon.mark")
return buffers Marked.set_mark_list(sorted_results)
_G.harpoon_btoggle(true)
end 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 end
--local testing = function () function _G.fzf_buffer_add_to_harpoon()
-- coroutine.wrap(function () coroutine.wrap(buffer_to_harpoon)()
-- local fzf = require("fzf").fzf end
-- fzf({}, '', { })
-- end)()
--end
-- width: 139 -- Opens files from fzf, then marks them with harpoon.
-- margin width: 14 local files_to_harpoon = function()
-- 90% width local results = fzf_call({multi = true})
-- height: 35
-- margin height: 14 if results then
-- 60% height -- opens all results into buffer
local cmd = ":n "
for _, filepath in ipairs(results) do
cmd = cmd .. filepath .. " "
end
vim.cmd(cmd)
local buf_paths = get_buffer_paths()
local sorted_results = {}
for _, filepath in ipairs(buf_paths) do
print(filepath)
if has_value(results, filepath) then
sorted_results[#sorted_results + 1] = filepath
end
end
local Marked = require("harpoon.mark")
Marked.set_mark_list(sorted_results)
_G.harpoon_btoggle(true)
end
end
function _G.fzf_files_to_harpoon()
coroutine.wrap(files_to_harpoon)()
end
local get_marked_file_names = function()
local Marked = require("harpoon.mark")
local filepaths = {}
for i = 1, Marked.get_length() do
filepaths[#filepaths + 1] = Marked.get_marked_file_name(i)
end
return filepaths
end
local select_harpoon_mark = function()
local results = fzf_call({items = get_marked_file_names()})
if results then
vim.api.nvim_win_set_buf(0, vim.fn.bufnr(results[1]))
end
end
function _G.fzf_select_harpoon_mark()
coroutine.wrap(select_harpoon_mark)()
end
_G.harpoon_open_marks = function()
local filepaths = get_marked_file_names()
if #filepaths ~= 0 then
local cmd = ":n "
for _, filepath in ipairs(filepaths) do
cmd = cmd .. filepath .. " "
end
vim.cmd(cmd)
end
end
+36 -21
View File
@@ -19,7 +19,7 @@ map("n", "<Tab>", ":lua harpoon_bnext()<CR>")
map("n", "<S-Tab>", ":lua harpoon_bprevious()<CR>") map("n", "<S-Tab>", ":lua harpoon_bprevious()<CR>")
map("n", "<esc>", ":noh<cr><esc>", {silent = true}) --After searching, pressing escape stops the highlight map("n", "<esc>", ":noh<cr><esc>", {silent = true}) --After searching, pressing escape stops the highlight
map("n", "<Leader>w", [[:%s/\s\+$//e<CR>]]) --map("n", "<Leader>w", [[:%s/\s\+$//e<CR>]])
--map("n", "<Leader>x", ":Bclose <CR>") --map("n", "<Leader>x", ":Bclose <CR>")
map("n", "<Leader>t", ":tabnew<CR>") map("n", "<Leader>t", ":tabnew<CR>")
@@ -29,12 +29,22 @@ map("n", "<A-Left>", "<C-W><S-H>")
map("n", "<A-Up>", "<C-W><S-K>") map("n", "<A-Up>", "<C-W><S-K>")
map("n", "<A-Down>", "<C-W><S-J>") map("n", "<A-Down>", "<C-W><S-J>")
--map("n", "<A-l>", "<C-W><S-L>")
--map("n", "<A-h>", "<C-W><S-H>")
--map("n", "<A-k>", "<C-W><S-K>")
--map("n", "<A-j>", "<C-W><S-J>")
-- Split navigations -- Split navigations
map("n", "<C-Right>", "<C-W><C-L>") map("n", "<C-Right>", "<C-W><C-L>")
map("n", "<C-Left>", "<C-W><C-H>") map("n", "<C-Left>", "<C-W><C-H>")
map("n", "<C-Up>", "<C-W><C-K>") map("n", "<C-Up>", "<C-W><C-K>")
map("n", "<C-Down>", "<C-W><C-J>") map("n", "<C-Down>", "<C-W><C-J>")
--map("n", "<C-l>", "<C-W><C-L>")
--map("n", "<C-h>", "<C-W><C-H>")
--map("n", "<C-k>", "<C-W><C-K>")
--map("n", "<C-j>", "<C-W><C-J>")
-- Resize split -- Resize split
--map("n", "<A-j>", "<C-W>-") --map("n", "<A-j>", "<C-W>-")
--map("n", "<A-k>", "<C-W>+") --map("n", "<A-k>", "<C-W>+")
@@ -81,18 +91,18 @@ map("v", "w", hopword, {silent = true})
-- args: direction: bool, inclusive: bool -- args: direction: bool, inclusive: bool
-- inclusive is broken in hop as of this comment -- inclusive is broken in hop as of this comment
local hop_hint_char1 = function(args) --local hop_hint_char1 = function(args)
local direction = args.forward and "AFTER_CURSOR" or "BEFORE_CURSOR" -- local direction = args.forward and "AFTER_CURSOR" or "BEFORE_CURSOR"
local inclusive = args.inclusive and "true" or "false" -- local inclusive = args.inclusive and "true" or "false"
--
return ("<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection." .. -- return ("<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection." ..
direction .. ", current_line_only = true, inclusive_jump = " .. inclusive .. " })<cr>") -- direction .. ", current_line_only = true, inclusive_jump = " .. inclusive .. " })<cr>")
end --end
--
vim.api.nvim_set_keymap("", "f", hop_hint_char1({forward = true, inclusive = false}), {}) --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("", "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 = true, inclusive = false}), {})
vim.api.nvim_set_keymap("", "T", hop_hint_char1({forward = false, inclusive = false}), {}) --vim.api.nvim_set_keymap("", "T", hop_hint_char1({forward = false, inclusive = false}), {})
-- place this in one of your configuration file(s) -- place this in one of your configuration file(s)
--vim.api.nvim_set_keymap( --vim.api.nvim_set_keymap(
@@ -138,7 +148,7 @@ vim.api.nvim_set_keymap("", "T", hop_hint_char1({forward = false, inclusive = fa
map("n", "<Leader>o", ":Files<CR>") map("n", "<Leader>o", ":Files<CR>")
--map("n", "<Leader>O", [[:lua vim.fn['fzf#vim#files']('~/')<CR>]]) --map("n", "<Leader>O", [[:lua vim.fn['fzf#vim#files']('~/')<CR>]])
map("n", "<Leader>O", ":Files ~/<CR>") map("n", "<Leader>O", ":Files ~/<CR>")
map("n", "<Leader>b", ":Buffers<CR>") map("n", "<Leader>p", ":Buffers<CR>")
map("n", "<Leader>h", ":Helptags<CR>") map("n", "<Leader>h", ":Helptags<CR>")
map("n", "<Leader>;", ":History:<CR>") map("n", "<Leader>;", ":History:<CR>")
map("n", "<Leader>c", ":Commands<CR>") map("n", "<Leader>c", ":Commands<CR>")
@@ -160,6 +170,7 @@ map("n", "<Leader>gb", ":GBranches<CR>")
--------- ---------
--map("n", "<c-k>", ":ALEPreviousWrap <CR>", {silent = true}) --map("n", "<c-k>", ":ALEPreviousWrap <CR>", {silent = true})
--map("n", "<c-j>", ":ALENextWrap <CR>", {silent = true}) --map("n", "<c-j>", ":ALENextWrap <CR>", {silent = true})
map("n", "<space>f", ":ALEFix<CR>", {silent = true})
------------- -------------
-- HARPOON -- -- HARPOON --
@@ -167,9 +178,10 @@ map("n", "<Leader>gb", ":GBranches<CR>")
--map("n", "<Leader>m", [[:lua require("harpoon.mark").add_file() <CR>]]) --map("n", "<Leader>m", [[:lua require("harpoon.mark").add_file() <CR>]])
map("n", "<Leader>x", ":lua harpoon_rm_file()<CR>") map("n", "<Leader>x", ":lua harpoon_rm_file()<CR>")
--map("n", "<Leader>m", [[:lua harpoon_toggle_file()<CR>]]) map("n", "<Leader>ma", [[:lua harpoon_toggle_file()<CR>]])
map("n", "<Leader>M", [[:lua harpoon_clear_all()<CR>]]) map("n", "<Leader>mc", [[:lua harpoon_clear_all()<CR>]])
map("n", "<Leader>l", [[:lua require("harpoon.ui").toggle_quick_menu()<CR>]]) map("n", "<Leader>ml", [[:lua require("harpoon.ui").toggle_quick_menu()<CR>]])
map("n", "<Leader>mt", [[:lua harpoon_btoggle()<CR>]])
--map("n", "<Leader>n", [[:lua require("harpoon.ui").nav_next() <CR>]]) --map("n", "<Leader>n", [[:lua require("harpoon.ui").nav_next() <CR>]])
--map("n", "<Leader>N", [[:lua require("harpoon.ui").nav_prev() <CR>]]) --map("n", "<Leader>N", [[:lua require("harpoon.ui").nav_prev() <CR>]])
@@ -177,12 +189,15 @@ map("n", "<Leader>l", [[:lua require("harpoon.ui").toggle_quick_menu()<CR>]])
----------- -----------
-- CODEX -- -- CODEX --
----------- -----------
local create_completion = ":lua vim.fn.CreateCompletion(200)<CR>" --local create_completion = ":lua vim.fn.CreateCompletion(200)<CR>"
map("n", "<C-x>", create_completion) --local create_completion = ":lua vim.fn.CreateCompletionLine()<CR>"
map("i", "<C-x>", ("<C-o>" .. create_completion)) --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>") --map("i", "<C-x>", "<Esc>li<C-g>u<Esc>l:CreateCompletion<CR>")
-------------- --------------
-- NVIM FZF -- -- NVIM FZF --
-------------- --------------
map("n", "<Leader>m", [[:lua fzf_buffer_add_to_harpoon()<CR>]]) map("n", "<Leader>mm", [[:lua fzf_buffer_add_to_harpoon()<CR>]])
map("n", "<Leader>mo", [[:lua fzf_files_to_harpoon()<CR>]])
map("n", "<Leader>ml", [[:lua fzf_select_harpoon_mark()<CR>]])
+92 -40
View File
@@ -17,15 +17,70 @@ local has_words_before = function()
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end end
local luasnip = require("luasnip")
local cmp_autopairs = require("nvim-autopairs.completion.cmp") local cmp_autopairs = require("nvim-autopairs.completion.cmp")
local cmp = require("cmp") local cmp = require("cmp")
-- LUASNIP CMP THINGS
--local luasnip = require("luasnip")
--
--local luasnip_expand = function(args)
-- luasnip.lsp_expand(args.body)
--end
--
--local luasnip_tab = cmp.mapping(
-- function(fallback)
-- if cmp.visible() then
-- cmp.select_next_item()
-- elseif luasnip.expand_or_jumpable() then
-- luasnip.expand_or_jump()
-- elseif has_words_before() then
-- cmp.complete()
-- else
-- fallback()
-- end
-- end,
-- {"i", "s"}
--)
--
--local luasnip_shift_tab = cmp.mapping(
-- function(fallback)
-- if cmp.visible() then
-- cmp.select_prev_item()
-- elseif luasnip.jumpable(-1) then
-- luasnip.jump(-1)
-- else
-- fallback()
-- end
-- end,
-- {"i", "s"}
--)
-- CMP NVIM ULTISNIP
local cmp_ultisnips_mappings = require("cmp_nvim_ultisnips.mappings")
local ultisnip = {
expand = function(args)
vim.fn["UltiSnips#Anon"](args.body)
end,
tab = cmp.mapping(
function(fallback)
--cmp_ultisnips_mappings.jump_forwards(fallback)
--cmp_ultisnips_mappings.compose({"jump_forwards", "select_next_item"})(fallback)
cmp_ultisnips_mappings.compose({"select_next_item"})(fallback)
end,
{"i", "s"}
),
shift_tab = cmp.mapping(
function(fallback)
--cmp_ultisnips_mappings.jump_backwards(fallback)
cmp_ultisnips_mappings.compose({"select_prev_item"})(fallback)
end,
{"i", "s"}
)
}
cmp.setup { cmp.setup {
snippet = { snippet = {
expand = function(args) expand = ultisnip.expand
luasnip.lsp_expand(args.body)
end
}, },
mapping = { mapping = {
["<C-p>"] = cmp.mapping.select_prev_item(), ["<C-p>"] = cmp.mapping.select_prev_item(),
@@ -38,36 +93,13 @@ cmp.setup {
--behavior = cmp.ConfirmBehavior.Replace, --behavior = cmp.ConfirmBehavior.Replace,
select = true select = true
}, },
["<Tab>"] = cmp.mapping( ["<Tab>"] = ultisnip.tab,
function(fallback) ["<S-Tab>"] = ultisnip.shift_tab
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end,
{"i", "s"}
),
["<S-Tab>"] = cmp.mapping(
function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end,
{"i", "s"}
)
}, },
sources = { sources = {
{name = "nvim_lsp"}, {name = "nvim_lsp"},
{name = "luasnip"} --{name = "luasnip"},
{name = "ultisnips"}
} }
} }
@@ -108,8 +140,8 @@ local common_on_attach = function(client, bufnr)
vim.api.nvim_buf_set_option(bufnr, ...) vim.api.nvim_buf_set_option(bufnr, ...)
end end
client.resolved_capabilities.document_formatting = false --client.resolved_capabilities.document_formatting = false
client.resolved_capabilities.document_range_formatting = false --client.resolved_capabilities.document_range_formatting = false
-- Enable completion triggered by <c-x><c-o> -- Enable completion triggered by <c-x><c-o>
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
@@ -120,16 +152,16 @@ local common_on_attach = function(client, bufnr)
--buf_set_keymap("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts) --buf_set_keymap("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
buf_set_keymap("n", "<space>D", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts) buf_set_keymap("n", "<space>D", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
buf_set_keymap("n", "<space>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts) buf_set_keymap("n", "<space>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
buf_set_keymap("n", "<space>e", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", opts) buf_set_keymap("n", "<space>e", "<cmd>lua vim.diagnostic.show_line_diagnostics()<CR>", opts)
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts) buf_set_keymap("n", "<space>F", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
buf_set_keymap("n", "<space>q", "<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>", opts) buf_set_keymap("n", "<space>q", "<cmd>lua vim.diagnostic.set_loclist()<CR>", opts)
buf_set_keymap("n", "<space>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts) buf_set_keymap("n", "<space>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
buf_set_keymap("n", "<space>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>", opts) buf_set_keymap("n", "<space>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>", opts)
buf_set_keymap("n", "<space>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>", opts) buf_set_keymap("n", "<space>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>", opts)
buf_set_keymap("n", "<space>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>", opts) buf_set_keymap("n", "<space>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>", opts)
buf_set_keymap("n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts) buf_set_keymap("n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
buf_set_keymap("n", "<c-k>", "<cmd>lua vim.lsp.diagnostic.goto_prev({wrap = false})<CR>", opts) buf_set_keymap("n", "<C-[>", "<cmd>lua vim.diagnostic.goto_prev({wrap = true})<CR>", opts)
buf_set_keymap("n", "<c-j>", "<cmd>lua vim.lsp.diagnostic.goto_next({wrap = false})<CR>", opts) buf_set_keymap("n", "<C-]>", "<cmd>lua vim.diagnostic.goto_next({wrap = true})<CR>", opts)
buf_set_keymap("n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts) buf_set_keymap("n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
buf_set_keymap("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts) buf_set_keymap("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
buf_set_keymap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts) buf_set_keymap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
@@ -191,7 +223,7 @@ require("nvim-lsp-installer").on_server_ready(
debounce_text_changes = 150 debounce_text_changes = 150
}, },
settings = { settings = {
format = {enable = false} format = {enable = true}
}, },
handlers = { handlers = {
["textDocument/publishDiagnostics"] = vim.lsp.with( ["textDocument/publishDiagnostics"] = vim.lsp.with(
@@ -224,6 +256,22 @@ require("nvim-lsp-installer").on_server_ready(
} }
} }
} }
elseif server.name == "diagnosticls" then
opts = {
filetypes = {"python"},
init_options = {
formatters = {
black = {
command = "black",
args = {"--quiet", "-"},
rootPatterns = {"pyproject.toml", "setup.cfg"}
},
formatFiletypes = {
python = {"black"}
}
}
}
}
end end
server:setup(opts) server:setup(opts)
@@ -234,6 +282,7 @@ require("nvim-lsp-installer").on_server_ready(
local lsp_installer_servers = require("nvim-lsp-installer.servers") local lsp_installer_servers = require("nvim-lsp-installer.servers")
local auto_servers = { local auto_servers = {
"pylsp", "pylsp",
--"pyright",
"sumneko_lua", "sumneko_lua",
"tsserver", "tsserver",
"bashls", "bashls",
@@ -241,7 +290,10 @@ local auto_servers = {
"rust_analyzer", "rust_analyzer",
"html", "html",
"cssls", "cssls",
"jsonls" "jsonls",
"omnisharp",
"eslint"
--"diagnosticls"
--"eslintls" --"eslintls"
} }
+26 -10
View File
@@ -5,21 +5,29 @@ require("packer").startup(
use "wbthomason/packer.nvim" use "wbthomason/packer.nvim"
-- OPENAI CODEX -- OPENAI CODEX
use "tom-doerr/vim_codex" --use "tom-doerr/vim_codex"
-- NAVIGATION -- NAVIGATION
use { use {
"phaazon/hop.nvim", "phaazon/hop.nvim",
as = "hop", --branch = "v1.2", -- optional but strongly recommended
config = function() config = function()
-- you can configure Hop the way you like here; see :h hop-config -- you can configure Hop the way you like here; see :h hop-config
require "hop".setup {} require "hop".setup {keys = "etovxqpdygfblzhckisuran"}
--require "hop".setup {keys = "etovxqpdygfblzhckisuran"}
end end
} }
--use {
-- "phaazon/hop.nvim",
-- as = "hop",
-- config = function()
-- -- you can configure Hop the way you like here; see :h hop-config
-- require "hop".setup {}
-- --require "hop".setup {keys = "etovxqpdygfblzhckisuran"}
-- end
--}
-- TABLE -- TABLE
use "dhruvasagar/vim-table-mode" --use "dhruvasagar/vim-table-mode"
-- VIM THEMING -- VIM THEMING
--use "rafi/awesome-vim-colorschemes" -- vim themes --use "rafi/awesome-vim-colorschemes" -- vim themes
@@ -35,6 +43,7 @@ require("packer").startup(
use "francoiscabrol/ranger.vim" use "francoiscabrol/ranger.vim"
use "vijaymarupudi/nvim-fzf" use "vijaymarupudi/nvim-fzf"
use "vijaymarupudi/nvim-fzf-commands" use "vijaymarupudi/nvim-fzf-commands"
use {"tpope/vim-obsession"}
-- GIT -- GIT
use "tpope/vim-fugitive" use "tpope/vim-fugitive"
@@ -52,14 +61,23 @@ require("packer").startup(
use "dense-analysis/ale" use "dense-analysis/ale"
--use "nathanmsmith/nvim-ale-diagnostic" --use "nathanmsmith/nvim-ale-diagnostic"
use "turbio/bracey.vim" use "turbio/bracey.vim"
-- init.lua
use "lukas-reineke/indent-blankline.nvim" use "lukas-reineke/indent-blankline.nvim"
--use "sheerun/vim-polyglot"
-- SNIPPETS
use "SirVer/ultisnips"
use "honza/vim-snippets"
-- LSP -- LSP
use "hrsh7th/nvim-cmp" -- Autocompletion plugin
--use "saadparwaiz1/cmp_luasnip" -- Snippets source for nvim-cmp
use {"nvim-treesitter/nvim-treesitter", run = ":TSUpdate"} use {"nvim-treesitter/nvim-treesitter", run = ":TSUpdate"}
use "neovim/nvim-lspconfig" -- Collection of configurations for built-in LSP client use "neovim/nvim-lspconfig" -- Collection of configurations for built-in LSP client
use "williamboman/nvim-lsp-installer" use "williamboman/nvim-lsp-installer"
use "hrsh7th/cmp-nvim-lsp" -- LSP source for nvim-cmp use {
"hrsh7th/cmp-nvim-lsp",
requires = "quangnguyen30192/cmp-nvim-ultisnips"
} -- LSP source for nvim-cmp
use "nvim-lua/plenary.nvim" use "nvim-lua/plenary.nvim"
use "jose-elias-alvarez/nvim-lsp-ts-utils" use "jose-elias-alvarez/nvim-lsp-ts-utils"
@@ -68,8 +86,6 @@ require("packer").startup(
use "ThePrimeagen/harpoon" use "ThePrimeagen/harpoon"
use "L3MON4D3/LuaSnip" -- Snippets plugin use "L3MON4D3/LuaSnip" -- Snippets plugin
use "hrsh7th/nvim-cmp" -- Autocompletion plugin
use "saadparwaiz1/cmp_luasnip" -- Snippets source for nvim-cmp
-- JS -- JS
use "HerringtonDarkholme/yats.vim" use "HerringtonDarkholme/yats.vim"
@@ -79,7 +95,7 @@ require("packer").startup(
--use "leafOfTree/vim-vue-plugin" -- vue syntax highlight & indent --use "leafOfTree/vim-vue-plugin" -- vue syntax highlight & indent
-- PYTHON -- PYTHON
use {"numirias/semshi", run = ":UpdateRemotePlugins"} -- python --use {"numirias/semshi", run = ":UpdateRemotePlugins"} -- python
use "Vimjas/vim-python-pep8-indent" use "Vimjas/vim-python-pep8-indent"
-- HTML/CSS -- HTML/CSS