summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lua/lvim/config/settings.lua8
-rw-r--r--lua/lvim/core/alpha/dashboard.lua12
-rw-r--r--lua/lvim/core/autocmds.lua2
-rw-r--r--lua/lvim/core/autopairs.lua5
-rw-r--r--lua/lvim/core/bufferline.lua8
-rw-r--r--lua/lvim/core/builtins/init.lua1
-rw-r--r--lua/lvim/core/cmp.lua2
-rw-r--r--lua/lvim/core/lir.lua90
-rw-r--r--lua/lvim/core/nvimtree.lua15
-rw-r--r--lua/lvim/core/terminal.lua4
-rw-r--r--lua/lvim/core/which-key.lua14
-rw-r--r--lua/lvim/keymappings.lua6
-rw-r--r--lua/lvim/lsp/config.lua11
-rw-r--r--lua/lvim/lsp/peek.lua157
-rw-r--r--lua/lvim/plugins.lua10
15 files changed, 129 insertions, 216 deletions
diff --git a/lua/lvim/config/settings.lua b/lua/lvim/config/settings.lua
index faa28641..421d739b 100644
--- a/lua/lvim/config/settings.lua
+++ b/lua/lvim/config/settings.lua
@@ -13,8 +13,7 @@ M.load_default_options = function()
local default_options = {
backup = false, -- creates a backup file
clipboard = "unnamedplus", -- allows neovim to access the system clipboard
- cmdheight = 2, -- more space in the neovim command line for displaying messages
- colorcolumn = "99999", -- fixes indentline for now
+ cmdheight = 1, -- more space in the neovim command line for displaying messages
completeopt = { "menuone", "noselect" },
conceallevel = 0, -- so that `` is visible in markdown files
fileencoding = "utf-8", -- the encoding written to a file
@@ -34,19 +33,18 @@ M.load_default_options = function()
splitright = true, -- force all vertical splits to go to the right of current window
swapfile = false, -- creates a swapfile
termguicolors = true, -- set term gui colors (most terminals support this)
- timeoutlen = 250, -- time to wait for a mapped sequence to complete (in milliseconds)
+ timeoutlen = 1000, -- time to wait for a mapped sequence to complete (in milliseconds)
title = true, -- set the title of window to the value of the titlestring
-- opt.titlestring = "%<%F%=%l/%L - nvim" -- what the title of the window will be set to
undodir = undodir, -- set an undo directory
undofile = true, -- enable persistent undo
- updatetime = 300, -- faster completion
+ updatetime = 100, -- faster completion
writebackup = false, -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited
expandtab = true, -- convert tabs to spaces
shiftwidth = 2, -- the number of spaces inserted for each indentation
tabstop = 2, -- insert 2 spaces for a tab
cursorline = true, -- highlight the current line
number = true, -- set numbered lines
- relativenumber = false, -- set relative numbered lines
numberwidth = 4, -- set number column width to 2 {default 4}
signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time
wrap = false, -- display lines as one long line
diff --git a/lua/lvim/core/alpha/dashboard.lua b/lua/lvim/core/alpha/dashboard.lua
index d65980fb..9f235ce0 100644
--- a/lua/lvim/core/alpha/dashboard.lua
+++ b/lua/lvim/core/alpha/dashboard.lua
@@ -51,13 +51,13 @@ function M.get_sections()
local buttons = {
entries = {
- { "SPC f", " Find File", "<CMD>Telescope find_files<CR>" },
- { "SPC n", " New File", "<CMD>ene!<CR>" },
- { "SPC P", " Recent Projects ", "<CMD>Telescope projects<CR>" },
- { "SPC s r", " Recently Used Files", "<CMD>Telescope oldfiles<CR>" },
- { "SPC s t", " Find Word", "<CMD>Telescope live_grep<CR>" },
+ { "f", " Find File", "<CMD>Telescope find_files<CR>" },
+ { "n", " New File", "<CMD>ene!<CR>" },
+ { "p", " Recent Projects ", "<CMD>Telescope projects<CR>" },
+ { "r", " Recently Used Files", "<CMD>Telescope oldfiles<CR>" },
+ { "t", " Find Word", "<CMD>Telescope live_grep<CR>" },
{
- "SPC L c",
+ "c",
" Configuration",
"<CMD>edit " .. require("lvim.config"):get_user_config_path() .. " <CR>",
},
diff --git a/lua/lvim/core/autocmds.lua b/lua/lvim/core/autocmds.lua
index f5c63588..ef7122e5 100644
--- a/lua/lvim/core/autocmds.lua
+++ b/lua/lvim/core/autocmds.lua
@@ -18,7 +18,7 @@ function M.load_defaults()
pattern = "*",
desc = "Highlight text on yank",
callback = function()
- require("vim.highlight").on_yank { higroup = "Search", timeout = 200 }
+ require("vim.highlight").on_yank { higroup = "Search", timeout = 100 }
end,
},
},
diff --git a/lua/lvim/core/autopairs.lua b/lua/lvim/core/autopairs.lua
index 469a38a4..5daffba5 100644
--- a/lua/lvim/core/autopairs.lua
+++ b/lua/lvim/core/autopairs.lua
@@ -47,7 +47,10 @@ function M.config()
end
M.setup = function()
- local autopairs = require "nvim-autopairs"
+ local status_ok, autopairs = pcall(require, "nvim-autopairs")
+ if not status_ok then
+ return
+ end
local Rule = require "nvim-autopairs.rule"
autopairs.setup {
diff --git a/lua/lvim/core/bufferline.lua b/lua/lvim/core/bufferline.lua
index 36e5ff54..6ae0d6c6 100644
--- a/lua/lvim/core/bufferline.lua
+++ b/lua/lvim/core/bufferline.lua
@@ -140,7 +140,13 @@ end
M.setup = function()
require("lvim.keymappings").load(lvim.builtin.bufferline.keymap)
- require("bufferline").setup {
+
+ local status_ok, bufferline = pcall(require, "bufferline")
+ if not status_ok then
+ return
+ end
+
+ bufferline.setup {
options = lvim.builtin.bufferline.options,
highlights = lvim.builtin.bufferline.highlights,
}
diff --git a/lua/lvim/core/builtins/init.lua b/lua/lvim/core/builtins/init.lua
index 5cad2a00..03ee8aec 100644
--- a/lua/lvim/core/builtins/init.lua
+++ b/lua/lvim/core/builtins/init.lua
@@ -9,6 +9,7 @@ local builtins = {
"lvim.core.telescope",
"lvim.core.treesitter",
"lvim.core.nvimtree",
+ "lvim.core.lir",
"lvim.core.project",
"lvim.core.bufferline",
"lvim.core.autopairs",
diff --git a/lua/lvim/core/cmp.lua b/lua/lvim/core/cmp.lua
index 408691a6..8e954335 100644
--- a/lua/lvim/core/cmp.lua
+++ b/lua/lvim/core/cmp.lua
@@ -135,7 +135,7 @@ M.config = function()
keyword_length = 1,
},
experimental = {
- ghost_text = true,
+ ghost_text = false,
native_menu = false,
},
formatting = {
diff --git a/lua/lvim/core/lir.lua b/lua/lvim/core/lir.lua
new file mode 100644
index 00000000..e14e01cd
--- /dev/null
+++ b/lua/lvim/core/lir.lua
@@ -0,0 +1,90 @@
+local M = {}
+
+M.config = function()
+ local status_ok, lir = pcall(require, "lir")
+ if not status_ok then
+ return
+ end
+
+ local actions = require "lir.actions"
+ local mark_actions = require "lir.mark.actions"
+ local clipboard_actions = require "lir.clipboard.actions"
+
+ lir.setup {
+ show_hidden_files = false,
+ devicons_enable = true,
+ mappings = {
+ ["l"] = actions.edit,
+ ["<CR>"] = actions.edit,
+ ["<C-s>"] = actions.split,
+ ["v"] = actions.vsplit,
+ ["<C-t>"] = actions.tabedit,
+
+ ["h"] = actions.up,
+ ["q"] = actions.quit,
+
+ ["A"] = actions.mkdir,
+ ["a"] = actions.newfile,
+ ["r"] = actions.rename,
+ ["@"] = actions.cd,
+ ["Y"] = actions.yank_path,
+ ["i"] = actions.toggle_show_hidden,
+ ["d"] = actions.delete,
+
+ ["J"] = function()
+ mark_actions.toggle_mark()
+ vim.cmd "normal! j"
+ end,
+ ["c"] = clipboard_actions.copy,
+ ["x"] = clipboard_actions.cut,
+ ["p"] = clipboard_actions.paste,
+ },
+ float = {
+ winblend = 0,
+ curdir_window = {
+ enable = false,
+ highlight_dirname = true,
+ },
+
+ -- -- You can define a function that returns a table to be passed as the third
+ -- -- argument of nvim_open_win().
+ win_opts = function()
+ local width = math.floor(vim.o.columns * 0.7)
+ local height = math.floor(vim.o.lines * 0.7)
+ return {
+ border = "rounded",
+ width = width,
+ height = height,
+ -- row = 1,
+ -- col = math.floor((vim.o.columns - width) / 2),
+ }
+ end,
+ },
+ hide_cursor = false,
+ on_init = function()
+ -- use visual mode
+ vim.api.nvim_buf_set_keymap(
+ 0,
+ "x",
+ "J",
+ ':<C-u>lua require"lir.mark.actions".toggle_mark("v")<CR>',
+ { noremap = true, silent = true }
+ )
+
+ -- echo cwd
+ -- vim.api.nvim_echo({ { vim.fn.expand "%:p", "Normal" } }, false, {})
+ end,
+ }
+
+ -- custom folder icon
+ require("nvim-web-devicons").set_icon {
+ lir_folder_icon = {
+ icon = "",
+ -- color = "#7ebae4",
+ -- color = "#569CD6",
+ color = "#42A5F5",
+ name = "LirFolderNode",
+ },
+ }
+end
+return M
diff --git a/lua/lvim/core/nvimtree.lua b/lua/lvim/core/nvimtree.lua
index 15e80e85..372cd00f 100644
--- a/lua/lvim/core/nvimtree.lua
+++ b/lua/lvim/core/nvimtree.lua
@@ -6,26 +6,16 @@ function M.config()
active = true,
on_config_done = nil,
setup = {
- disable_netrw = true,
- hijack_netrw = true,
- open_on_setup = false,
- open_on_setup_file = false,
- sort_by = "name",
- ignore_buffer_on_setup = false,
ignore_ft_on_setup = {
"startify",
"dashboard",
"alpha",
},
auto_reload_on_write = true,
- hijack_unnamed_buffer_when_opening = false,
hijack_directories = {
- enable = true,
- auto_open = true,
+ enable = false,
},
- open_on_tab = false,
- hijack_cursor = false,
- update_cwd = false,
+ update_cwd = true,
diagnostics = {
enable = lvim.use_icons,
show_on_dirs = false,
@@ -55,7 +45,6 @@ function M.config()
height = 30,
hide_root_folder = false,
side = "left",
- preserve_window_proportions = false,
mappings = {
custom_only = false,
list = {},
diff --git a/lua/lvim/core/terminal.lua b/lua/lvim/core/terminal.lua
index 6f543d06..ac844b11 100644
--- a/lua/lvim/core/terminal.lua
+++ b/lua/lvim/core/terminal.lua
@@ -6,8 +6,8 @@ M.config = function()
on_config_done = nil,
-- size can be a number or function which is passed the current terminal
size = 20,
- -- open_mapping = [[<c-\>]],
- open_mapping = [[<c-t>]],
+ open_mapping = [[<c-\>]],
+ -- open_mapping = [[<c-t>]],
hide_numbers = true, -- hide the number column in toggleterm buffers
shade_filetypes = {},
shade_terminals = true,
diff --git a/lua/lvim/core/which-key.lua b/lua/lvim/core/which-key.lua
index 2301943f..7d75dee1 100644
--- a/lua/lvim/core/which-key.lua
+++ b/lua/lvim/core/which-key.lua
@@ -6,8 +6,8 @@ M.config = function()
on_config_done = nil,
setup = {
plugins = {
- marks = true, -- shows a list of your marks on ' and `
- registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
+ marks = false, -- shows a list of your marks on ' and `
+ registers = false, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
-- the presets plugin, adds help for a bunch of default keybindings in Neovim
-- No actual key bindings are created
presets = {
@@ -16,8 +16,8 @@ M.config = function()
text_objects = false, -- help for text objects triggered after entering an operator
windows = false, -- default bindings on <c-w>
nav = true, -- misc bindings to work with windows
- z = true, -- bindings for folds, spelling and others prefixed with z
- g = true, -- bindings for prefixed with g
+ z = false, -- bindings for folds, spelling and others prefixed with z
+ g = false, -- bindings for prefixed with g
},
spelling = { enabled = true, suggestions = 20 }, -- use which-key for spelling hints
},
@@ -170,12 +170,6 @@ M.config = function()
"Prev Diagnostic",
},
l = { vim.lsp.codelens.run, "CodeLens Action" },
- p = {
- name = "Peek",
- d = { "<cmd>lua require('lvim.lsp.peek').Peek('definition')<cr>", "Definition" },
- t = { "<cmd>lua require('lvim.lsp.peek').Peek('typeDefinition')<cr>", "Type Definition" },
- i = { "<cmd>lua require('lvim.lsp.peek').Peek('implementation')<cr>", "Implementation" },
- },
q = { vim.diagnostic.setloclist, "Quickfix" },
r = { vim.lsp.buf.rename, "Rename" },
s = { "<cmd>Telescope lsp_document_symbols<cr>", "Document Symbols" },
diff --git a/lua/lvim/keymappings.lua b/lua/lvim/keymappings.lua
index 63835f75..8c182682 100644
--- a/lua/lvim/keymappings.lua
+++ b/lua/lvim/keymappings.lua
@@ -31,12 +31,6 @@ local mode_adapters = {
local defaults = {
insert_mode = {
- -- 'jk' for quitting insert mode
- ["jk"] = "<ESC>",
- -- 'kj' for quitting insert mode
- ["kj"] = "<ESC>",
- -- 'jj' for quitting insert mode
- ["jj"] = "<ESC>",
-- Move current line / block with Alt-j/k ala vscode.
["<A-j>"] = "<Esc>:m .+1<CR>==gi",
-- Move current line / block with Alt-j/k ala vscode.
diff --git a/lua/lvim/lsp/config.lua b/lua/lvim/lsp/config.lua
index 96a1b823..7e91db52 100644
--- a/lua/lvim/lsp/config.lua
+++ b/lua/lvim/lsp/config.lua
@@ -79,11 +79,6 @@ return {
style = "minimal",
border = "rounded",
},
- peek = {
- max_height = 15,
- max_width = 30,
- context = 10,
- },
on_attach_callback = nil,
on_init_callback = nil,
automatic_configuration = {
@@ -100,12 +95,6 @@ return {
["gr"] = { vim.lsp.buf.references, "Goto references" },
["gI"] = { vim.lsp.buf.implementation, "Goto Implementation" },
["gs"] = { vim.lsp.buf.signature_help, "show signature help" },
- ["gp"] = {
- function()
- require("lvim.lsp.peek").Peek "definition"
- end,
- "Peek definition",
- },
["gl"] = {
function()
local config = lvim.lsp.diagnostics.float
diff --git a/lua/lvim/lsp/peek.lua b/lua/lvim/lsp/peek.lua
deleted file mode 100644
index 65c67e92..00000000
--- a/lua/lvim/lsp/peek.lua
+++ /dev/null
@@ -1,157 +0,0 @@
-local M = {
- floating_buf = nil,
- floating_win = nil,
- prev_result = nil,
-}
-
-local function create_floating_file(location, opts)
- vim.validate {
- location = { location, "t" },
- opts = { opts, "t", true },
- }
-
- -- Set some defaults
- opts = opts or {}
- local close_events = opts.close_events or { "CursorMoved", "CursorMovedI", "BufHidden", "InsertCharPre" }
-
- -- location may be LocationLink or Location
- local uri = location.targetUri or location.uri
- if uri == nil then
- return
- end
- local bufnr = vim.uri_to_bufnr(uri)
- if not vim.api.nvim_buf_is_loaded(bufnr) then
- vim.fn.bufload(bufnr)
- end
-
- local range = location.targetRange or location.range
-
- local contents = vim.api.nvim_buf_get_lines(
- bufnr,
- range.start.line,
- math.min(
- range["end"].line + 1 + (opts.context or lvim.lsp.peek.max_height),
- range.start.line + (opts.max_height or lvim.lsp.peek.max_height)
- ),
- false
- )
- if next(contents) == nil then
- vim.notify("peek: Unable to get contents of the file!", vim.log.levels.WARN)
- return
- end
- local width, height = vim.lsp.util._make_floating_popup_size(contents, opts)
- local if_nil = vim.F.if_nil
- opts = vim.lsp.util.make_floating_popup_options(
- if_nil(width, lvim.lsp.peek.max_width),
- if_nil(height, lvim.lsp.peek.max_height),
- opts
- )
- -- Don't make it minimal as it is meant to be fully featured
- opts["style"] = nil
-
- vim.api.nvim_buf_set_option(bufnr, "bufhidden", "wipe")
-
- local winnr = vim.api.nvim_open_win(bufnr, false, opts)
- vim.api.nvim_win_set_option(winnr, "winblend", 0)
-
- vim.api.nvim_win_set_cursor(winnr, { range.start.line + 1, range.start.character })
- vim.api.nvim_buf_set_var(bufnr, "lsp_floating_window", winnr)
-
- -- Set some autocmds to close the window
- vim.api.nvim_command(
- string.format("autocmd %s <buffer> ++once lua pcall(vim.api.nvim_win_close, %d, true)", unpack(close_events), winnr)
- )
-
- return bufnr, winnr
-end
-
-local function preview_location_callback(result)
- if result == nil or vim.tbl_isempty(result) then
- return nil
- end
-
- local opts = {
- border = "rounded",
- context = lvim.lsp.peek.context,
- }
-
- if vim.tbl_islist(result) then
- M.prev_result = result[1]
- M.floating_buf, M.floating_win = create_floating_file(result[1], opts)
- else
- M.prev_result = result
- M.floating_buf, M.floating_win = create_floating_file(result, opts)
- end
-end
-
-local function preview_location_callback_new_signature(_, result)
- return preview_location_callback(result)
-end
-
-function M.open_file()
- -- Get the file currently open in the floating window
- local filepath = vim.fn.expand "%:."
-
- if not filepath then
- vim.notify("peek: Unable to open the file!", vim.log.levels.ERROR)
- return
- end
-
- -- Close the floating window
- pcall(vim.api.nvim_win_close, M.floating_win, true)
-
- -- Edit the file
- vim.cmd("edit " .. filepath)
-
- local winnr = vim.api.nvim_get_current_win()
-
- -- Set the cursor at the right position
- M.set_cursor_to_prev_pos(winnr)
-end
-
-function M.set_cursor_to_prev_pos(winnr)
- -- Get position of the thing to peek at
- local location = M.prev_result
- local range = location.targetRange or location.range
- local cursor_pos = { range.start.line + 1, range.start.character }
-
- -- Set the winnr to the floating window if none was passed in
- winnr = winnr or M.floating_win
- -- Set the cursor at the correct position in the floating window
- vim.api.nvim_win_set_cursor(winnr, cursor_pos)
-end
-
-function M.Peek(what)
- -- If a window already exists, focus it at the right position!
- if vim.tbl_contains(vim.api.nvim_list_wins(), M.floating_win) then
- local success_1, _ = pcall(vim.api.nvim_set_current_win, M.floating_win)
- if not success_1 then
- vim.notify("peek: You cannot edit the current file in a preview!", vim.log.levels.ERROR)
- return
- end
-
- -- Set the cursor at the correct position in the floating window
- M.set_cursor_to_prev_pos()
-
- vim.api.nvim_buf_set_keymap(
- M.floating_buf,
- "n",
- "<CR>",
- ":lua require('lvim.lsp.peek').open_file()<CR>",
- { noremap = true, silent = true }
- )
- else
- -- Make a new request and then create the new window in the callback
- local params = vim.lsp.util.make_position_params()
- local preview_callback = preview_location_callback_new_signature
- local success, _ = pcall(vim.lsp.buf_request, 0, "textDocument/" .. what, params, preview_callback)
- if not success then
- vim.notify(
- 'peek: Error calling LSP method "textDocument/' .. what .. '". The current language lsp might not support it.',
- vim.log.levels.ERROR
- )
- end
- end
-end
-
-return M
diff --git a/lua/lvim/plugins.lua b/lua/lvim/plugins.lua
index bfe76bb8..0b3b51fc 100644
--- a/lua/lvim/plugins.lua
+++ b/lua/lvim/plugins.lua
@@ -132,13 +132,19 @@ local core_plugins = {
-- NvimTree
{
"kyazdani42/nvim-tree.lua",
- -- event = "BufWinOpen",
- -- cmd = "NvimTreeToggle",
config = function()
require("lvim.core.nvimtree").setup()
end,
disable = not lvim.builtin.nvimtree.active,
},
+ {
+
+ "christianchiarulli/lir.nvim",
+ config = function()
+ require("lvim.core.lir").setup()
+ end,
+ disable = not lvim.builtin.nvimtree.active,
+ },
{
"lewis6991/gitsigns.nvim",