fixed up neovim config
This commit is contained in:
parent
1b903cce7f
commit
db5fa210a1
13 changed files with 198 additions and 68 deletions
|
@ -19,3 +19,5 @@ require("user.indentline")
|
|||
require("user.alpha")
|
||||
require("user.whichkey")
|
||||
require("user.trouble")
|
||||
require("user.colorizer")
|
||||
require("user.gps")
|
||||
|
|
46
.config/nvim/lua/user/autocommands.lua
Normal file
46
.config/nvim/lua/user/autocommands.lua
Normal file
|
@ -0,0 +1,46 @@
|
|||
-- Use 'q' to quit from common plugins
|
||||
vim.api.nvim_create_autocmd({ "FileType" }, {
|
||||
pattern = { "qf", "help", "man", "lspinfo", "spectre_panel", "lir" },
|
||||
callback = function()
|
||||
vim.cmd([[
|
||||
nnoremap <silent> <buffer> q :close<CR>
|
||||
set nobuflisted
|
||||
]])
|
||||
end,
|
||||
})
|
||||
|
||||
-- Remove statusline and tabline when in Alpha
|
||||
vim.api.nvim_create_autocmd({ "User" }, {
|
||||
pattern = { "AlphaReady" },
|
||||
callback = function()
|
||||
vim.cmd([[
|
||||
set showtabline=0 | autocmd BufUnload <buffer> set showtabline=2
|
||||
set laststatus=0 | autocmd BufUnload <buffer> set laststatus=3
|
||||
]])
|
||||
end,
|
||||
})
|
||||
|
||||
-- Set wrap and spell in markdown and gitcommit
|
||||
vim.api.nvim_create_autocmd({ "FileType" }, {
|
||||
pattern = { "gitcommit", "markdown" },
|
||||
callback = function()
|
||||
vim.opt_local.wrap = true
|
||||
vim.opt_local.spell = true
|
||||
end,
|
||||
})
|
||||
|
||||
vim.cmd("autocmd BufEnter * ++nested if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif")
|
||||
|
||||
-- Fixes Autocomment
|
||||
vim.api.nvim_create_autocmd({ "BufWinEnter" }, {
|
||||
callback = function()
|
||||
vim.cmd("set formatoptions-=cro")
|
||||
end,
|
||||
})
|
||||
|
||||
-- Highlight Yanked Text
|
||||
vim.api.nvim_create_autocmd({ "TextYankPost" }, {
|
||||
callback = function()
|
||||
vim.highlight.on_yank({ higroup = "Visual", timeout = 200 })
|
||||
end,
|
||||
})
|
|
@ -1,25 +1,12 @@
|
|||
-- Setup nvim-cmp.
|
||||
local status_ok, npairs = pcall(require, "nvim-autopairs")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
npairs.setup({
|
||||
check_ts = true,
|
||||
ts_config = {
|
||||
lua = { "string", "source" },
|
||||
},
|
||||
check_ts = true, -- treesitter integration
|
||||
disable_filetype = { "TelescopePrompt" },
|
||||
fast_wrap = {
|
||||
map = "<M-e>",
|
||||
chars = { "{", "[", "(", '"', "'" },
|
||||
pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""),
|
||||
offset = 0,
|
||||
end_key = "$",
|
||||
keys = "qwertyuiopzxcvbnmasdfghjkl",
|
||||
check_comma = true,
|
||||
highlight = "PmenuSel",
|
||||
highlight_grey = "LineNr",
|
||||
},
|
||||
})
|
||||
|
||||
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
|
||||
|
@ -27,4 +14,4 @@ local cmp_status_ok, cmp = pcall(require, "cmp")
|
|||
if not cmp_status_ok then
|
||||
return
|
||||
end
|
||||
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } }))
|
||||
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({}))
|
||||
|
|
|
@ -115,9 +115,11 @@ cmp.setup({
|
|||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = false,
|
||||
},
|
||||
window = {
|
||||
documentation = {
|
||||
border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" },
|
||||
},
|
||||
},
|
||||
experimental = {
|
||||
ghost_text = true,
|
||||
native_menu = false,
|
||||
|
|
17
.config/nvim/lua/user/colorizer.lua
Normal file
17
.config/nvim/lua/user/colorizer.lua
Normal file
|
@ -0,0 +1,17 @@
|
|||
local status_ok, colorizer = pcall(require, "colorizer")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
colorizer.setup({ "*" }, {
|
||||
RGB = true, -- #RGB hex codes
|
||||
RRGGBB = true, -- #RRGGBB hex codes
|
||||
names = false, -- "Name" codes like Blue oe blue
|
||||
RRGGBBAA = true, -- #RRGGBBAA hex codes
|
||||
rgb_fn = true, -- CSS rgb() and rgba() functions
|
||||
hsl_fn = true, -- CSS hsl() and hsla() functions
|
||||
css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
|
||||
css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn
|
||||
-- Available modes: foreground, background, virtualtext
|
||||
mode = "background", -- Set the display mode.)
|
||||
})
|
34
.config/nvim/lua/user/gps.lua
Normal file
34
.config/nvim/lua/user/gps.lua
Normal file
|
@ -0,0 +1,34 @@
|
|||
local status_ok, gps = pcall(require, "nvim-gps")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
gps.setup({
|
||||
disable_icons = false, -- Setting it to true will disable all icons
|
||||
icons = {
|
||||
["class-name"] = " ", -- Classes and class-like objects
|
||||
["function-name"] = " ", -- Functions
|
||||
["method-name"] = " ", -- Methods (functions inside class-like objects)
|
||||
["container-name"] = "⛶ ", -- Containers (example: lua tables)
|
||||
["tag-name"] = "炙 ", -- Tags (example: html tags)
|
||||
["mapping-name"] = " ",
|
||||
["sequence-name"] = " ",
|
||||
["null-name"] = "[] ",
|
||||
["boolean-name"] = "ﰰﰴ ",
|
||||
["integer-name"] = "# ",
|
||||
["float-name"] = " ",
|
||||
["string-name"] = " ",
|
||||
["array-name"] = " ",
|
||||
["object-name"] = " ",
|
||||
["number-name"] = "# ",
|
||||
["table-name"] = " ",
|
||||
["date-name"] = " ",
|
||||
["date-time-name"] = " ",
|
||||
["inline-table-name"] = " ",
|
||||
["time-name"] = " ",
|
||||
["module-name"] = " ",
|
||||
},
|
||||
separator = " > ",
|
||||
depth = 0,
|
||||
depth_limit_indicator = "..",
|
||||
})
|
3
.config/nvim/lua/user/illuminate.lua
Normal file
3
.config/nvim/lua/user/illuminate.lua
Normal file
|
@ -0,0 +1,3 @@
|
|||
vim.g.Illuminate_ftblacklist = {'alpha', 'NvimTree'}
|
||||
vim.api.nvim_set_keymap('n', '<a-n>', '<cmd>lua require"illuminate".next_reference{wrap=true}<cr>', {noremap=true})
|
||||
vim.api.nvim_set_keymap('n', '<a-p>', '<cmd>lua require"illuminate".next_reference{reverse=true,wrap=true}<cr>', {noremap=true})
|
|
@ -42,18 +42,11 @@ M.setup = function()
|
|||
end
|
||||
|
||||
local function lsp_highlight_document(client)
|
||||
if client.resolved_capabilities.document_highlight then
|
||||
vim.api.nvim_exec(
|
||||
[[
|
||||
augroup lsp_document_highlight
|
||||
autocmd! * <buffer>
|
||||
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
|
||||
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
|
||||
augroup END
|
||||
]],
|
||||
false
|
||||
)
|
||||
local status_ok, illuminate = pcall(require, "illuminate")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
illuminate.on_attach(client)
|
||||
end
|
||||
|
||||
local function lsp_keymaps(bufnr)
|
||||
|
|
|
@ -12,11 +12,11 @@ null_ls.setup({
|
|||
formatting.stylua,
|
||||
},
|
||||
on_attach = function(client)
|
||||
if client.resolved_capabilities.document_formatting then
|
||||
if client.server_capabilities.documentFormattingProvider then
|
||||
vim.cmd([[
|
||||
augroup LspFormatting
|
||||
autocmd! * <buffer>
|
||||
autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()
|
||||
autocmd BufWritePre <buffer> lua vim.lsp.buf.format()
|
||||
augroup END
|
||||
]])
|
||||
end
|
||||
|
|
|
@ -3,6 +3,20 @@ if not status_ok then
|
|||
return
|
||||
end
|
||||
|
||||
local status_gps_ok, gps = pcall(require, "nvim-gps")
|
||||
if not status_gps_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local nvim_gps = function()
|
||||
local gps_location = gps.get_location()
|
||||
if gps_location == "error" then
|
||||
return ""
|
||||
else
|
||||
return gps.get_location()
|
||||
end
|
||||
end
|
||||
|
||||
lualine.setup({
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
|
@ -15,7 +29,7 @@ lualine.setup({
|
|||
sections = {
|
||||
lualine_a = { "mode" },
|
||||
lualine_b = { "branch", "diff", "diagnostics" },
|
||||
lualine_c = { "filename", "filesize" },
|
||||
lualine_c = { "filename", "filesize", nvim_gps },
|
||||
lualine_x = { "encoding", "fileformat", "filetype" },
|
||||
lualine_y = { "progress" },
|
||||
lualine_z = { "location" },
|
||||
|
|
|
@ -1,24 +1,3 @@
|
|||
vim.g.nvim_tree_icons = {
|
||||
default = "",
|
||||
symlink = "",
|
||||
git = {
|
||||
unstaged = "",
|
||||
staged = "S",
|
||||
unmerged = "",
|
||||
renamed = "➜",
|
||||
deleted = "",
|
||||
untracked = "U",
|
||||
ignored = "◌",
|
||||
},
|
||||
folder = {
|
||||
default = "",
|
||||
open = "",
|
||||
empty = "",
|
||||
empty_open = "",
|
||||
symlink = "",
|
||||
},
|
||||
}
|
||||
|
||||
local status_ok, nvim_tree = pcall(require, "nvim-tree")
|
||||
if not status_ok then
|
||||
return
|
||||
|
@ -30,6 +9,14 @@ if not config_status_ok then
|
|||
end
|
||||
|
||||
local tree_cb = nvim_tree_config.nvim_tree_callback
|
||||
vim.api.nvim_create_autocmd("BufEnter", {
|
||||
nested = true,
|
||||
callback = function()
|
||||
if #vim.api.nvim_list_wins() == 1 and vim.api.nvim_buf_get_name(0):match("NvimTree_") ~= nil then
|
||||
vim.cmd("quit")
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
nvim_tree.setup({
|
||||
disable_netrw = true,
|
||||
|
@ -38,14 +25,9 @@ nvim_tree.setup({
|
|||
ignore_ft_on_setup = {
|
||||
"alpha",
|
||||
},
|
||||
auto_close = true,
|
||||
open_on_tab = false,
|
||||
hijack_cursor = true,
|
||||
update_cwd = true,
|
||||
update_to_buf_dir = {
|
||||
enable = true,
|
||||
auto_open = true,
|
||||
},
|
||||
diagnostics = {
|
||||
enable = true,
|
||||
icons = {
|
||||
|
@ -82,15 +64,40 @@ nvim_tree.setup({
|
|||
number = false,
|
||||
relativenumber = false,
|
||||
},
|
||||
quit_on_open = 0,
|
||||
git_hl = 1,
|
||||
disable_window_picker = 0,
|
||||
root_folder_modifier = ":t",
|
||||
show_icons = {
|
||||
git = 1,
|
||||
folders = 1,
|
||||
files = 1,
|
||||
folder_arrows = 1,
|
||||
tree_width = 30,
|
||||
actions = {
|
||||
open_file = {
|
||||
quit_on_open = false,
|
||||
window_picker = {
|
||||
enable = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
renderer = {
|
||||
icons = {
|
||||
glyphs = {
|
||||
default = "",
|
||||
symlink = "",
|
||||
git = {
|
||||
unstaged = "",
|
||||
staged = "S",
|
||||
unmerged = "",
|
||||
renamed = "➜",
|
||||
deleted = "",
|
||||
untracked = "U",
|
||||
ignored = "◌",
|
||||
},
|
||||
folder = {
|
||||
default = "",
|
||||
open = "",
|
||||
empty = "",
|
||||
empty_open = "",
|
||||
symlink = "",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
filesystem_watchers = {
|
||||
enable = true,
|
||||
interval = 100,
|
||||
},
|
||||
})
|
||||
|
|
|
@ -119,6 +119,15 @@ return packer.startup(function(use)
|
|||
-- WhichKey
|
||||
use("folke/which-key.nvim")
|
||||
|
||||
-- Illuminate
|
||||
use("RRethy/vim-illuminate")
|
||||
|
||||
-- Colorizer
|
||||
use("norcalli/nvim-colorizer.lua")
|
||||
|
||||
-- GPS
|
||||
use("SmiteshP/nvim-gps")
|
||||
|
||||
if PACKER_BOOTSTRAP then
|
||||
require("packer").sync()
|
||||
end
|
||||
|
|
|
@ -169,6 +169,16 @@ _G.packer_plugins = {
|
|||
path = "/home/relms/.local/share/nvim/site/pack/packer/start/nvim-cmp",
|
||||
url = "https://github.com/hrsh7th/nvim-cmp"
|
||||
},
|
||||
["nvim-colorizer.lua"] = {
|
||||
loaded = true,
|
||||
path = "/home/relms/.local/share/nvim/site/pack/packer/start/nvim-colorizer.lua",
|
||||
url = "https://github.com/norcalli/nvim-colorizer.lua"
|
||||
},
|
||||
["nvim-gps"] = {
|
||||
loaded = true,
|
||||
path = "/home/relms/.local/share/nvim/site/pack/packer/start/nvim-gps",
|
||||
url = "https://github.com/SmiteshP/nvim-gps"
|
||||
},
|
||||
["nvim-lsp-installer"] = {
|
||||
loaded = true,
|
||||
path = "/home/relms/.local/share/nvim/site/pack/packer/start/nvim-lsp-installer",
|
||||
|
@ -289,6 +299,11 @@ _G.packer_plugins = {
|
|||
path = "/home/relms/.local/share/nvim/site/pack/packer/start/vim-better-whitespace",
|
||||
url = "https://github.com/ntpeters/vim-better-whitespace"
|
||||
},
|
||||
["vim-illuminate"] = {
|
||||
loaded = true,
|
||||
path = "/home/relms/.local/share/nvim/site/pack/packer/start/vim-illuminate",
|
||||
url = "https://github.com/RRethy/vim-illuminate"
|
||||
},
|
||||
["which-key.nvim"] = {
|
||||
loaded = true,
|
||||
path = "/home/relms/.local/share/nvim/site/pack/packer/start/which-key.nvim",
|
||||
|
@ -302,5 +317,6 @@ if should_profile then save_profiles() end
|
|||
end)
|
||||
|
||||
if not no_errors then
|
||||
error_msg = error_msg:gsub('"', '\\"')
|
||||
vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None')
|
||||
end
|
||||
|
|
Reference in a new issue