mirror of
https://github.com/ItsDrike/dotfiles.git
synced 2024-11-10 02:39:40 +00:00
Move nvim config to it's own repo and link module
This commit is contained in:
parent
4b92916fd3
commit
52877996e4
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -13,3 +13,6 @@
|
|||
[submodule "root/usr/local/src/z.lua"]
|
||||
path = "root/usr/local/src/z.lua"
|
||||
url = "https://github.com/skywind3000/z.lua"
|
||||
[submodule "home/.config/nvim"]
|
||||
path = home/.config/nvim
|
||||
url = https://github.com/ItsDrike/neovim
|
||||
|
|
1
home/.config/nvim
Submodule
1
home/.config/nvim
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 5e10bd30328a890bc2f62d8687b3c346a8032b14
|
|
@ -1,15 +0,0 @@
|
|||
{
|
||||
"pairs.enableCharacters": [
|
||||
"(",
|
||||
"[",
|
||||
"{",
|
||||
"'",
|
||||
"\"",
|
||||
"`"
|
||||
],
|
||||
"diagnostic.checkCurrentLine": true,
|
||||
"coc.preferences.formatOnSaveFiletypes": [
|
||||
"json"
|
||||
],
|
||||
"python.linting.flake8Enabled": true
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
-- The configuration is scattered across multiple files in the lua/ folder
|
||||
-- We can require the individual configurations from here
|
||||
|
||||
|
||||
-- This loads in the basic nvim configuration that doesn't rely on any
|
||||
-- plugins. it provides default keymaps, options, theming, autocmds, ...
|
||||
require "core"
|
||||
|
||||
-- This loads packer plugin manager which manages our plugins
|
||||
-- NOTE: Removing this will NOT disable the plugins, but it will disable
|
||||
-- automatic packer installation, allowing for the plugins to be deleted
|
||||
-- manually (from ~/.local/share/nvim/site/pack/packer).
|
||||
require "plugins"
|
|
@ -1,26 +0,0 @@
|
|||
local vim = require("vim")
|
||||
local fn = vim.fn
|
||||
local m = require("utility.mappings")
|
||||
|
||||
local function cabbrev(input, result, reabbrev)
|
||||
m.abbrev("c", input, result, reabbrev)
|
||||
end
|
||||
|
||||
-- Invalid case abbreviations
|
||||
cabbrev("Wq", "wq")
|
||||
cabbrev("wQ", "wq")
|
||||
cabbrev("WQ", "wq")
|
||||
cabbrev("Wa", "wa")
|
||||
cabbrev("W", "w")
|
||||
cabbrev("Q", "q")
|
||||
cabbrev("Qall", "qall")
|
||||
cabbrev("W!", "w!")
|
||||
cabbrev("Q!", "q!")
|
||||
cabbrev("Qall!", "qall!")
|
||||
|
||||
-- Save file with sudo
|
||||
cabbrev("w!!", "w !sudo tee > /dev/null %")
|
||||
|
||||
-- Reload lua configuration
|
||||
local initlua = fn.stdpath("config") .. "init.lua"
|
||||
cabbrev("reload", "luafile " .. initlua)
|
|
@ -1,21 +0,0 @@
|
|||
local vim = require("vim")
|
||||
local cmd = vim.cmd
|
||||
|
||||
-- Disable automatic commenting on newlines
|
||||
cmd[[autocmd FileType * setlocal formatoptions-=cro]]
|
||||
|
||||
-- Have vim jump to last position when reopening a file
|
||||
cmd[[autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif]]
|
||||
|
||||
-- Automatically delete all trailing whitespace on save
|
||||
cmd[[autocmd BufWritePre * %s/\s\+$//e]]
|
||||
|
||||
-- Enable spellcheck for certain file types
|
||||
cmd[[autocmd FileType tex,latex,markdown,gitcommit setlocal spell spelllang=en_us]]
|
||||
|
||||
-- Use auto-wrap for certain file types at 119 chars
|
||||
cmd[[autocmd FileType markdown setlocal textwidth=119]]
|
||||
|
||||
-- Don't show line numbers in terminal
|
||||
cmd[[autocmd BufEnter term://* setlocal nonumber | setlocal norelativenumber]]
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
-- Require additional scripts which contain individual configurations
|
||||
|
||||
require "core.options"
|
||||
require "core.theme"
|
||||
require "core.mappings"
|
||||
require "core.abbreviations"
|
||||
require "core.autocmd"
|
|
@ -1,111 +0,0 @@
|
|||
local m = require("utility.mappings")
|
||||
local vim = require("vim")
|
||||
local g = vim.g
|
||||
|
||||
|
||||
-- This is a bit silly, but I don't like passing the mode argument
|
||||
g.mapleader = "\\"
|
||||
|
||||
-- Unmap arrow keys in normal mode to remove bad habits
|
||||
m.keymap("n", "<Down>", "<nop>")
|
||||
m.keymap("n", "<Left>", "<nop>")
|
||||
m.keymap("n", "<Right>", "<nop>")
|
||||
m.keymap("n", "<Up>", "<nop>")
|
||||
|
||||
-- Tab navigation
|
||||
m.keymap("n", "<Tab>", "gt")
|
||||
m.keymap("n", "<S-Tab>", "gT")
|
||||
m.keymap("n", "<A-t>", ":tabnew<CR>")
|
||||
m.keymap("n", "<A-2>", ":tabmove +<CR>")
|
||||
m.keymap("n", "<A-1>", ":tabmove -<CR>")
|
||||
m.keymap("n", "<A-p>", ":tabp<CR>")
|
||||
m.keymap("n", "<A-n>", ":tabn<CR>")
|
||||
m.keymap("n", "<A-c>", ":tabc<CR>")
|
||||
|
||||
-- Buffer navigation
|
||||
m.keymap("n", "<A-N>", ":bn<CR>")
|
||||
m.keymap("n", "<A-P>", ":bp<CR>")
|
||||
m.keymap("n", "<A-d>", ":bd<CR>")
|
||||
|
||||
-- Set splits navigation to just ALT + hjkl
|
||||
m.keymap("n", "<C-h>", "<C-w>h")
|
||||
m.keymap("n", "<C-j>", "<C-w>j")
|
||||
m.keymap("n", "<C-k>", "<C-w>k")
|
||||
m.keymap("n", "<C-l>", "<C-w>l")
|
||||
|
||||
-- Split size adjusting
|
||||
m.keymap("n", "<C-Left>", ":vertical resize +3<CR>")
|
||||
m.keymap("n", "<C-Right>", ":vertical resize -3<CR>")
|
||||
m.keymap("n", "<C-Up>", ":resize +3<CR>")
|
||||
m.keymap("n", "<C-Down>", ":resize -3<CR>")
|
||||
|
||||
-- Define some common shortcuts
|
||||
m.keymap("n", "<C-s>", ":w<CR>")
|
||||
m.keymap("i", "<C-s>", "<Esc>:w<CR>i")
|
||||
m.keymap("n", "<C-z>", ":undo<CR>")
|
||||
m.keymap("n", "<C-y>", ":redo<CR>")
|
||||
|
||||
-- Terminal
|
||||
m.keymap("n", "<C-t>", ":split term://zsh<CR>:resize -7<CR>i")
|
||||
m.keymap("n", "<C-A-t>", ":vnew term://zsh<CR>i")
|
||||
m.keymap("n", "<A-T>", ":tabnew term://zsh<CR>i")
|
||||
m.keymap("t", "<Esc>", "<C-\\><C-n>")
|
||||
|
||||
-- Use space for folding/unfolding sections
|
||||
m.keymap("n", "<space>", "za")
|
||||
m.keymap("v", "<space>", "zf")
|
||||
|
||||
-- Use shift to quickly move 10 lines up/down
|
||||
m.keymap("n", "K", "10k")
|
||||
m.keymap("n", "J", "10j")
|
||||
|
||||
-- Moving lines around
|
||||
m.keymap("v", "<A-j>", ":m '>+1<CR>gv=gv")
|
||||
m.keymap("v", "<A-k>", ":m '<-2<CR>gv=gv")
|
||||
m.keymap("i", "<A-j>", "<esc>:m .+1<CR>==i")
|
||||
m.keymap("i", "<A-k>", "<esc>:m .-2<CR>==i")
|
||||
m.keymap("n", "<leader>j", ":m .+1<CR>==")
|
||||
m.keymap("n", "<leader>k", ":m .-2<CR>==")
|
||||
|
||||
-- Quick word replacing (use . for next word)
|
||||
m.keymap("n", "cn", "*``cgn")
|
||||
m.keymap("n", "cN", "*``cgN")
|
||||
|
||||
-- Enable/Disable auto commenting
|
||||
m.keymap("n", "<leader>c", ":setlocal formatoptions-=cro<CR>")
|
||||
m.keymap("n", "<leader>C", ":setlocal formatoptions+=cro<CR>")
|
||||
|
||||
-- Don't leave visual mode after indenting
|
||||
m.keymap("v", "<", "<gv")
|
||||
m.keymap("v", ">", ">gv")
|
||||
|
||||
-- Center (and unfold) after going to next/prev search item
|
||||
m.keymap("n", "n", "nzzzv")
|
||||
m.keymap("n", "N", "Nzzzv")
|
||||
|
||||
-- System clipboard copying
|
||||
m.keymap("v", "<C-c>", '"+y')
|
||||
|
||||
-- Alias replace all
|
||||
m.keymap("n", "<A-s>", ":%s//gI<Left><Left><Left>", {silent=false})
|
||||
|
||||
-- Stop search highlight with Esc
|
||||
m.keymap("n", "<esc>", ":noh<CR>")
|
||||
|
||||
-- Start spell-check
|
||||
m.keymap("n", "<leader>s", ":setlocal spell! spelllang=en_us<CR>")
|
||||
|
||||
-- Run shell check
|
||||
m.keymap("n", "<leader>p", ":!shellckeck %<CR>")
|
||||
|
||||
-- Compile opened file (using custom script)
|
||||
m.keymap("n", "<A-c>", ":w | !comp <c-r>%<CR>")
|
||||
|
||||
-- Close all opened buffers
|
||||
m.keymap("n", "<leader>Q", ":bufdo bdelete<CR>")
|
||||
|
||||
-- Don't set the incredibely annoying mappings that trigger dynamic SQL
|
||||
-- completion with dbext and keeps on freezing vim whenever pressed with
|
||||
-- a message saying that dbext plugin isn't installed
|
||||
-- See :h ft-sql.txt
|
||||
vim.g.omni_sql_no_default_maps = 1
|
|
@ -1,55 +0,0 @@
|
|||
local vim = require("vim")
|
||||
local cmd = vim.cmd
|
||||
local o = vim.opt
|
||||
|
||||
cmd[[filetype plugin on]]
|
||||
|
||||
-- Tab/Indent settings
|
||||
o.autoindent = true -- Enable autoindent
|
||||
o.expandtab = true -- Expand tabs to spaces
|
||||
o.tabstop = 4 -- Tab size in spaces
|
||||
o.shiftwidth = 4 -- Indentation size
|
||||
o.softtabstop = 4 -- Tabs/Spaces interlop
|
||||
o.tabpagemax = 50 -- More tabs
|
||||
o.shiftround = true -- Always round indent to multiple of shiftwidth
|
||||
|
||||
-- Folding
|
||||
o.foldmethod = "indent" -- Use indent to determine the fold levels
|
||||
o.foldnestmax = 8 -- Only fold up to given amount of levels
|
||||
o.foldlevel = 2 -- Set initial fold level (don't fold first 2 levels)
|
||||
o.foldenable = false -- Hide all folds by default
|
||||
|
||||
-- Split order
|
||||
o.splitbelow = true -- Put new windows below current
|
||||
o.splitright = true -- Put new vertical splits to right
|
||||
|
||||
-- In-file search (/)
|
||||
o.ignorecase = true -- Use case insensitive matching
|
||||
o.incsearch = true -- Show partial matches while typing
|
||||
o.hlsearch = true -- Highlight search matches
|
||||
|
||||
-- Show whitespace
|
||||
o.list = true -- Enable showing characters like <Tab>, <EOL>, ...
|
||||
o.listchars = {tab = " ", trail = "·"} -- Specify which characters to show
|
||||
|
||||
-- Command-mode search
|
||||
o.wildmode = {"longest", "list", "full"} -- Enable autocompletion
|
||||
o.wildmenu = true -- Display all matching files when we tab complete
|
||||
table.insert(o.path, "**") -- Search down into subfolders with tab completion
|
||||
o.wildignore = vim.tbl_extend( -- Ignore certain files/folders in wildmenu
|
||||
"force", o.wildignore, {
|
||||
"*.pyc", "*_build/*",
|
||||
"**/coverage/*", "**/node_modules/*",
|
||||
"**/android/*", "**/ios/*",
|
||||
"**/.git/*",
|
||||
}
|
||||
)
|
||||
|
||||
-- Files
|
||||
o.encoding = "utf-8" -- Use UTF-8 encoding
|
||||
o.autoread = true -- Automatically reload files on change
|
||||
|
||||
-- Misc
|
||||
o.mouse = "a" -- Enable mouse mode
|
||||
o.undolevels = 999 -- Lots of these
|
||||
o.history = 1000 -- More history
|
|
@ -1,43 +0,0 @@
|
|||
local vim = require("vim")
|
||||
local cmd = vim.cmd
|
||||
local g = vim.g
|
||||
local o = vim.opt
|
||||
|
||||
cmd[[syntax on]] -- Turn on syntax highlighting
|
||||
|
||||
o.cursorline = true -- Highlight cursor line
|
||||
o.laststatus = 2 -- Always show status line
|
||||
o.number = true -- Show line numbers
|
||||
o.relativenumber = true -- Use relative line numbers
|
||||
o.showmatch = true -- Show matching bracket
|
||||
o.scrolloff = 5 -- Keep 5 lines horizontal scrolloff
|
||||
o.sidescrolloff = 5 -- Keep 5 chars vertical scrolloff
|
||||
o.showmode = false -- Don't display mode (it's on status line anyway)
|
||||
|
||||
-- I wasn't able to find a way to set guioptions directly in lua
|
||||
cmd[[
|
||||
set guioptions-=m " Remove menubar
|
||||
set guioptions-=T " Remove toolbar
|
||||
set guioptions-=r " Remove right-hand scrollbar
|
||||
set guioptions-=L " Remove left-hand scrollbar
|
||||
]]
|
||||
|
||||
-- Override some colorscheme colors
|
||||
-- * Use more noticable cursor line color
|
||||
cmd[[
|
||||
augroup coloroverride
|
||||
autocmd!
|
||||
autocmd ColorScheme * highlight CursorLine guibg=#2b2b2b
|
||||
autocmd ColorScheme * highlight CursorLineNr guifg=#1F85DE ctermfg=LightBlue
|
||||
augroup END
|
||||
]]
|
||||
|
||||
-- Set the colorscheme to default to trigger the above autocmds
|
||||
-- This can be overridden from plugin definitions as this file is ran before those
|
||||
cmd[[colorscheme default]]
|
||||
|
||||
-- Don't use true colors in TTY
|
||||
o.termguicolors = os.getenv("DISPLAY") and true or false
|
||||
|
||||
-- Use proper syntax highlighting in fenced codeblocks
|
||||
g.markdown_fenced_languages = {"html", "javascript", "typescript", "css", "scss", "lua", "vim", "python"}
|
|
@ -1,5 +0,0 @@
|
|||
local vim = require("vim")
|
||||
local cmd = vim.cmd
|
||||
|
||||
-- Always automatically format on write for given filenames
|
||||
cmd[[autocmd BufWritePre *.js lua vim.lsp.buf.formatting_sync(nil, 100)]]
|
|
@ -1,31 +0,0 @@
|
|||
-- Neovim has built in support for the language server protocol (LSP). For
|
||||
-- which reason I decided to utilize it directly instead of relying on plugins
|
||||
-- such as COC, which reimplement it completely just to support default vim
|
||||
-- too, since I don't need pure vim support, utilizing this built in support
|
||||
-- makes a lot more sense and will be faster.
|
||||
--
|
||||
-- By default, setting up LSP doesn't technically require any plugins, however
|
||||
-- I still do use the recommended neovim/nvim-lspconfig plugin, along with
|
||||
-- williamboman/nvim-lsp-installer, because it makes things a lot easier to get
|
||||
-- working. The lspconfig holds the default configurations for the individual
|
||||
-- language servers, avoiding the need of tediously configuring them manually,
|
||||
-- and the lspinstaller gives us a way to automatically install selected
|
||||
-- language servers locally for nvim only, which means we won't need to look at
|
||||
-- the install instructions for each language server and install it user or
|
||||
-- system wide.
|
||||
--
|
||||
-- However, since this configuration shouldn't be plugin dependant, as it is
|
||||
-- outside of the plugins/ directory and LSP is supported by neovim directly,
|
||||
-- this folder is here to provide the non-plugin dependant LSP configuration,
|
||||
-- but I do not manually define the configuration for each language server,
|
||||
-- since I do actually utilize those plugins, but sturcturing like this still
|
||||
-- does give space for completely custom configurations written from scratch
|
||||
-- without relying on any external plugins at all. If you do want to do that,
|
||||
-- this would be the place to set this up.
|
||||
--
|
||||
-- NOTE: With my current configuration, this file is only ran by being required
|
||||
-- in the lsp plugin config file, if you don't wish to run with plugins, you'll
|
||||
-- want to require this file from init.lua directly.
|
||||
|
||||
require("lsp.keymaps")
|
||||
require("lsp.autoformat")
|
|
@ -1,57 +0,0 @@
|
|||
local m = require("utility.mappings")
|
||||
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below mapped functions
|
||||
|
||||
-- Check if certain plugins are installed, if so, they should be used
|
||||
-- to define some mappings
|
||||
local telescope_installed, _ = pcall(require, "telescope")
|
||||
local lsp_signature_installed, _ = pcall(require, "lsp_signature")
|
||||
|
||||
-- Lookups
|
||||
m.keymap("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>")
|
||||
m.keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>')
|
||||
m.keymap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>")
|
||||
m.keymap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>")
|
||||
m.keymap("n", "gt", "<cmd>lua vim.lsp.buf.type_definition()<CR>")
|
||||
|
||||
if telescope_installed then
|
||||
m.keymap('n', 'gd', '<cmd>lua require("telescope.builtin").lsp_definitions()<cr>')
|
||||
m.keymap('n', 'gr', '<cmd>lua require("telescope.builtin").lsp_references()<cr>')
|
||||
m.keymap('n', 'gi', '<cmd>lua require("telescope.builtin").lsp_implementations()<cr>')
|
||||
m.keymap('n', 'gt', '<cmd>lua require("telescope.builtin").lsp_type_definitions()<cr>')
|
||||
end
|
||||
|
||||
-- Formatting
|
||||
m.keymap('n', '<leader>gf', '<cmd>lua vim.lsp.buf.formatting()<cr>')
|
||||
m.keymap('v', '<leader>gf', '<cmd>lua vim.lsp.buf.range_formatting()<cr>')
|
||||
|
||||
-- Hover info
|
||||
m.keymap("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>")
|
||||
m.keymap("n", "M", "<cmd>lua vim.lsp.buf.hover()<CR>")
|
||||
|
||||
if lsp_signature_installed then
|
||||
m.keymap('n', '<C-M>', '<cmd>lua require("lsp_signature").signature()<cr>')
|
||||
end
|
||||
|
||||
-- Diagnostics
|
||||
m.keymap('n', '[g', '<cmd>lua vim.diagnostic.goto_prev()<cr>')
|
||||
m.keymap('n', ']g', '<cmd>lua vim.diagnostic.goto_next()<cr>')
|
||||
m.keymap('n', 'ge', '<cmd>lua vim.diagnostic.open_float(nil, { scope = "line", })<cr>')
|
||||
|
||||
if telescope_installed then
|
||||
m.keymap('n', '<leader>ge', '<cmd>lua require("telescope.builtin").lsp_document_diagnostics()<cr>')
|
||||
end
|
||||
|
||||
-- LSP Workspace
|
||||
m.keymap('n', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<cr>')
|
||||
m.keymap('n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<cr>')
|
||||
m.keymap('n', '<leader>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<cr>')
|
||||
|
||||
--Actions
|
||||
if telescope_installed then
|
||||
m.keymap('n', '<leader>ga', '<cmd>lua require("telescope.builtin").lsp_code_actions()<cr>')
|
||||
m.keymap('v', '<leader>ga', '<cmd>lua require("telescope.builtin").lsp_range_code_actions()<cr>')
|
||||
end
|
||||
|
||||
-- Use custom implementation for renaming all references
|
||||
m.keymap('n', 'gn', '<cmd>lua require("lsp.rename").rename()<cr>')
|
|
@ -1,147 +0,0 @@
|
|||
-- Nvim's LSP lacks rename-all functionality which plugins like Coc provide
|
||||
-- this is a manual implementation of this feature
|
||||
local vim = require("vim")
|
||||
local api = vim.api
|
||||
local cmd = vim.cmd
|
||||
local lsp = vim.lsp
|
||||
local fn = vim.fn
|
||||
|
||||
local M = {}
|
||||
|
||||
-- Unique name for the rename window, so we can access it
|
||||
-- from close_rename_win function.
|
||||
local unique_name = "lsp-rename-win"
|
||||
|
||||
-- File require string. Neede because we will be defining keymaps
|
||||
-- applied only to the rename window buffer which will refer to
|
||||
-- functions within this file, for that, they need to call require
|
||||
local file_require_string = "lsp.rename"
|
||||
|
||||
-- Check whether LSP is actually active.
|
||||
local function check_lsp_active()
|
||||
local active_clients = lsp.get_active_clients()
|
||||
if next(active_clients) == nil then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
-- Once in the rename window buffer, apply specific mappings to confirm or
|
||||
-- cancel renaming, and define a specific autocmd to close the window if
|
||||
-- we leave it.
|
||||
local function apply_actions()
|
||||
local prefix = string.format("lua require('%s')", file_require_string)
|
||||
local close_win_s = prefix .. ".close_rename_win()"
|
||||
local do_rename_s = prefix .. ".do_rename()"
|
||||
-- Automatically close the window if it's escaped
|
||||
api.nvim_command("autocmd QuitPre <buffer> ++nested ++once :silent " .. close_win_s)
|
||||
-- Define confirm and exit buffer-specific keymaps
|
||||
api.nvim_command("inoremap <buffer><nowait><silent><CR> <cmd>" .. do_rename_s .. "<CR>")
|
||||
api.nvim_command("nnoremap <buffer><silent>q <cmd>" .. close_win_s .. "<CR>")
|
||||
end
|
||||
|
||||
-- Closes the rename window (identified by the `unique_name`)
|
||||
function M.close_rename_win()
|
||||
if fn.mode() == "1" then
|
||||
cmd[[stopinsert]]
|
||||
end
|
||||
|
||||
local exists, winid = pcall(api.nvim_win_get_var, 0, unique_name)
|
||||
if exists then
|
||||
api.nvim_win_close(winid, true)
|
||||
end
|
||||
end
|
||||
|
||||
-- Trigger renaming
|
||||
function M.do_rename()
|
||||
local new_name = vim.trim(fn.getline('.'))
|
||||
M.close_rename_win()
|
||||
local current_name = fn.expand("<cword>")
|
||||
|
||||
if not new_name or #new_name == 0 or new_name == current_name then
|
||||
return
|
||||
end
|
||||
|
||||
local params = lsp.util.make_position_params()
|
||||
params.newName = new_name
|
||||
lsp.buf_request(0, "textDocument/rename", params, function(_, result, _, _)
|
||||
if not result then
|
||||
-- If the server returns an empty result, don't do anything
|
||||
return
|
||||
end
|
||||
|
||||
-- The result contains all places we need to update the name
|
||||
-- of the identifier, so we apply those edits.
|
||||
lsp.util.apply_workspace_edit(result)
|
||||
|
||||
if not result.changes then
|
||||
return
|
||||
end
|
||||
|
||||
-- Collect amounts of affected files and total renames.
|
||||
local total_files = 0
|
||||
local total_renames = 0
|
||||
for _, renames in pairs(result.changes) do
|
||||
total_files = total_files + 1
|
||||
for _ in pairs(renames) do
|
||||
total_renames = total_renames + 1
|
||||
end
|
||||
end
|
||||
|
||||
-- Once the changes were applied, these files won't be saved
|
||||
-- automatically, let's remind ourselves to save those...
|
||||
print(string.format(
|
||||
"Changed %s file%s (%s rename%s). To save %s, run ':w%s'",
|
||||
total_files,
|
||||
total_files > 1 and "s" or "",
|
||||
total_renames,
|
||||
total_renames > 1 and "s" or "",
|
||||
total_files > 1 and "them" or "it",
|
||||
total_files > 1 and "a" or ""
|
||||
))
|
||||
end)
|
||||
end
|
||||
|
||||
-- Create the rename window
|
||||
function M.rename()
|
||||
if not check_lsp_active() then
|
||||
print("No LSP client available, can't rename!")
|
||||
return
|
||||
end
|
||||
|
||||
-- In case there already is another rename window opened, close it
|
||||
M.close_rename_win()
|
||||
|
||||
|
||||
-- Read the current name here, before we're in the rename window
|
||||
local current_name = fn.expand('<cword>')
|
||||
|
||||
-- Create a window within our buffer with our `unique_name` so that it
|
||||
-- can be found from the close fucntion and automatically enter it
|
||||
local win_opts = {
|
||||
relative = 'cursor',
|
||||
row = 0,
|
||||
col = 0,
|
||||
width = 30,
|
||||
height = 1,
|
||||
style = 'minimal',
|
||||
border = 'single'
|
||||
}
|
||||
local buf = api.nvim_create_buf(false, true)
|
||||
local win = api.nvim_open_win(buf, true, win_opts)
|
||||
api.nvim_win_set_var(0, unique_name, win)
|
||||
|
||||
-- Automatically enter insert mode
|
||||
cmd[[startinsert]]
|
||||
|
||||
-- Pre-write the current name of given object into the rename window
|
||||
-- and set cursor behind it
|
||||
api.nvim_buf_set_lines(buf, 0, -1, false, {current_name})
|
||||
api.nvim_win_set_cursor(win, {1, #current_name})
|
||||
|
||||
-- Set actions for auto-closing the window and buffer-specific mappings
|
||||
-- to confirm or close rename
|
||||
apply_actions()
|
||||
end
|
||||
|
||||
return M
|
|
@ -1,36 +0,0 @@
|
|||
local vim = require("vim")
|
||||
local packer_m = require("plugins.packer")
|
||||
|
||||
-- Require packer_compiled to lazy-load all of the plugins and their settings
|
||||
-- automatically. If this fails, it means we probably didn't yet compile
|
||||
-- packer. This file is generated upon running :PackerCompile, so if we didn't
|
||||
-- find it, we inform the user to run it. We can't run it here directly,
|
||||
-- because packer may not yet be installed, bootstrapping happens only after
|
||||
-- this to allow this lazy loadning behavior. If we required packer before
|
||||
-- this, the lazy-loading would have no effect.
|
||||
local packer_compiled_ok, _ = pcall(require, "compiled.packer_compiled")
|
||||
if not packer_compiled_ok then
|
||||
vim.notify(
|
||||
"Run :PackerCompile or :PackerSync",
|
||||
vim.log.levels.WARN,
|
||||
{ title = "Notification" }
|
||||
)
|
||||
end
|
||||
|
||||
-- If packer isn't present, install it automatically it
|
||||
local present, packer = pcall(require, "packer")
|
||||
|
||||
local first_install = false
|
||||
if not present then
|
||||
first_install = packer_m.bootstrap_packer()
|
||||
if first_install then
|
||||
-- We know this will work now that packer was bootstrapped
|
||||
-- Otherwise we'd receive false in first_install
|
||||
---@diagnostic disable-next-line:different-requires
|
||||
packer = require("packer")
|
||||
end
|
||||
end
|
||||
|
||||
-- Obtain the plugins defined in plugin_list.ua
|
||||
local plugin_list = require("plugins.plugin_list")
|
||||
packer_m.startup(packer, plugin_list, first_install)
|
|
@ -1,114 +0,0 @@
|
|||
local vim = require("vim")
|
||||
local cmd = vim.cmd
|
||||
local fn = vim.fn
|
||||
|
||||
local M = {}
|
||||
|
||||
-- Define some paths used in the functions
|
||||
M.packer_install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
|
||||
M.packer_compile_path = fn.stdpath("config") .. "/lua/compiled/packer_compiled.lua"
|
||||
|
||||
-- Define basic default settings for packer
|
||||
M.packer_settings = {
|
||||
display = {
|
||||
open_fn = function()
|
||||
return require('packer.util').float({ border = "rounded" })
|
||||
end,
|
||||
prompt_border = "rounded",
|
||||
},
|
||||
git = {
|
||||
-- Timeout for git clones in seconds
|
||||
clone_timeout = 600,
|
||||
},
|
||||
profile = {
|
||||
enable = true,
|
||||
-- The time that a pluign's load time must surpass for it to be included
|
||||
-- in the profile (in miliseconds)
|
||||
threshold = 1,
|
||||
},
|
||||
compile_path = M.packer_compile_path,
|
||||
auto_clean = true,
|
||||
compile_on_sync = true
|
||||
}
|
||||
|
||||
-- Define default plugins which should always be used
|
||||
M.default_plugin_list = {
|
||||
-- Let packer manager itself, so that it gets updates
|
||||
{ "wbthomason/packer.nvim" },
|
||||
|
||||
-- Add plugin for speeding up `require` in lua by caching
|
||||
--{ "lewis6991/impatient.nvim" },
|
||||
|
||||
-- Replaces default filetype.vim sourced on startup, which includes
|
||||
-- 800+ autocommands setting the filetype based on the filename. This
|
||||
-- is very slow and this plugin merges them into single autocommand,
|
||||
-- which is 175x faster, improving startup time
|
||||
--{ "nathom/filetype.nvim" },
|
||||
}
|
||||
|
||||
-- Download and load packer plugin manager
|
||||
function M.bootstrap_packer()
|
||||
print("Clonning pakcer plugin manager, please wait...")
|
||||
-- First remove the directory in case it already exists but packer isn't present
|
||||
fn.delete(M.packer_install_path, "rf")
|
||||
fn.system({
|
||||
"git", "clone", "--depth", "1",
|
||||
"https://github.com/wbthomason/packer.nvim",
|
||||
M.packer_install_path
|
||||
})
|
||||
|
||||
-- Add packer plugin via nvim's internal plugin system
|
||||
-- and make sure that we can now require it.
|
||||
cmd("packadd packer.nvim")
|
||||
local present, packer = pcall(require, "packer")
|
||||
if present then
|
||||
print("Packer clonned successfully.")
|
||||
return true
|
||||
else
|
||||
print("Couldn't clone packer! Packer path: " .. M.packer_install_path .. "\n" .. packer)
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Run packer startup with the default config and given plugin settings
|
||||
-- Expects: `packer`, `plugin_list`, `run_sync`, `settings_override`
|
||||
function M.startup(packer, plugin_list, run_sync, settings_override)
|
||||
-- Initialize packer with default settings extended by
|
||||
-- the given settings override
|
||||
local settings = M.packer_settings
|
||||
if settings_override then
|
||||
settings = vim.tbl_extend("foce", settings, settings_override)
|
||||
end
|
||||
packer.reset()
|
||||
packer.init(settings)
|
||||
|
||||
-- Run packer startup and use all given plugins with their settings
|
||||
-- including the default plugins
|
||||
local use = packer.use
|
||||
return packer.startup(function()
|
||||
-- Use the default plugins (should be first)
|
||||
for _, plugin_settings in pairs(M.default_plugin_list) do
|
||||
use(plugin_settings)
|
||||
end
|
||||
|
||||
-- Use the obtained plugins
|
||||
if plugin_list and not vim.tbl_isempty(plugin_list) then
|
||||
for _, plugin_settings in pairs(plugin_list) do
|
||||
use(plugin_settings)
|
||||
end
|
||||
end
|
||||
|
||||
-- We can also automatically run sync to install all specified plugins
|
||||
-- immediately, this is useful if we've just bootstrapped packer.
|
||||
if run_sync then
|
||||
vim.notify(
|
||||
"Make sure to restart after packer sync!",
|
||||
vim.log.levels.WARN,
|
||||
{ title = "Notification" }
|
||||
)
|
||||
packer.sync()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
return M
|
|
@ -1,124 +0,0 @@
|
|||
local vim = require("vim")
|
||||
local fn = vim.fn
|
||||
|
||||
local plugin_directory = fn.stdpath("config") .. "/lua/plugins/settings"
|
||||
|
||||
-- Return the line (string) to be executed with lua that loads in given plugin file.
|
||||
-- This is useful for the `config` or `setup` parameters of packer's use to source
|
||||
-- both `.vim` and `.lua` files.
|
||||
-- Expects a `plugin_file` which is a relative path from the `plugin_directory` folder.
|
||||
local function get_plugin_file(plugin_file)
|
||||
local source_line = string.format('source %s/%s', plugin_directory, plugin_file)
|
||||
return string.format("vim.fn.execute('%s')", source_line)
|
||||
end
|
||||
|
||||
|
||||
-- Define packer plugins
|
||||
-- The individual tables will get passed into the packer's use function
|
||||
local plugin_list = {
|
||||
{ "airblade/vim-gitgutter" }, -- Git status in files
|
||||
{ "dhruvasagar/vim-table-mode" }, -- Easy way to construct markdown tables
|
||||
{ "wakatime/vim-wakatime" }, -- Track time spent coding
|
||||
{ "mhinz/vim-startify" }, -- Nice startup screen for vim when started withotu file/dir
|
||||
{ "dbeniamine/cheat.sh-vim" }, -- Quick interaction with cheat.sh cheatsheets
|
||||
{
|
||||
"tveskag/nvim-blame-line", -- Show commit affecting cursor line
|
||||
config = get_plugin_file("blame_line.lua")
|
||||
},
|
||||
{
|
||||
"vimwiki/vimwiki", -- Wiki pages for vim
|
||||
config = get_plugin_file("vimwiki.lua"),
|
||||
},
|
||||
{
|
||||
"tpope/vim-commentary", -- Adds ability to comment out sections of files
|
||||
config = get_plugin_file("commentary.lua")
|
||||
},
|
||||
{
|
||||
"tomasiser/vim-code-dark", -- Vim theme inspired by vscode's Dark+
|
||||
config = get_plugin_file("vim-code-dark.lua")
|
||||
},
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter", -- AST language analysis providing semantic highlighting
|
||||
config = get_plugin_file("treesitter.lua"),
|
||||
run = ':TSUpdate',
|
||||
requires = { "nvim-treesitter/playground", opt = true }
|
||||
},
|
||||
{
|
||||
"vim-airline/vim-airline", -- Status line
|
||||
config = get_plugin_file("airline.lua"),
|
||||
requires = {
|
||||
{ "vim-airline/vim-airline-themes" },
|
||||
{ "ryanoasis/vim-devicons" },
|
||||
},
|
||||
},
|
||||
-- TODO: Consider changing this to nvim-tree
|
||||
{
|
||||
"preservim/nerdtree", -- File tree
|
||||
config = get_plugin_file("nerdtree.lua"),
|
||||
requires = {
|
||||
{ "Xuyuanp/nerdtree-git-plugin" },
|
||||
{ "tiagofumo/vim-nerdtree-syntax-highlight" },
|
||||
{ "ryanoasis/vim-devicons" },
|
||||
},
|
||||
},
|
||||
{
|
||||
"mfussenegger/nvim-dap", -- Support for the debugging within vim
|
||||
config = get_plugin_file("nvim-dap.lua"),
|
||||
requires = { "mfussenegger/nvim-dap-python" },
|
||||
},
|
||||
{
|
||||
"junegunn/fzf.vim", -- Fuzzy finder (TODO: consider replacing with telescope)
|
||||
run = function() fn['fzf#install']() end,
|
||||
config = get_plugin_file("fzf.lua"),
|
||||
requires = {
|
||||
{ "junegunn/fzf" },
|
||||
{ "stsewd/fzf-checkout.vim" },
|
||||
}
|
||||
},
|
||||
{
|
||||
'glacambre/firenvim', -- Integrates neovim into the browser
|
||||
config = get_plugin_file("firenvim.lua"),
|
||||
run = function() vim.fn['firenvim#install'](0) end
|
||||
},
|
||||
{
|
||||
"williamboman/nvim-lsp-installer", -- LSP auto-installer
|
||||
config = get_plugin_file("lsp.lua"),
|
||||
requires = {
|
||||
-- Predefined LSP server configurations
|
||||
"neovim/nvim-lspconfig",
|
||||
-- Support for autocompletion
|
||||
"hrsh7th/nvim-cmp",
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-cmdline",
|
||||
},
|
||||
},
|
||||
|
||||
-- TODO: Consider testing out telescope as an alternative to FZF, I've heard a lot of
|
||||
-- positive feedback about it, but I haven't yet got the chance to meaningfully test
|
||||
-- it and configure it.
|
||||
--{
|
||||
-- "nvim-telescope/telescope.nvim",
|
||||
-- --config = get_plugin_file("telescope.lua")
|
||||
-- module = "telescope",
|
||||
-- cmd = "Telescope",
|
||||
-- requires = {
|
||||
-- { "nvim-lua/popup.nvim" },
|
||||
-- { "nvim-lua/plenary.nvim" },
|
||||
-- }
|
||||
--},
|
||||
|
||||
-- Coc is disabled because we're using LSP. It implements support from language servers from
|
||||
-- scratch, which is slower than neovim's built-in LSP and since this configuration won't work
|
||||
-- with pure vim, we can rely on nvim-only thigns. I left it here because LSP can sometimes
|
||||
-- cause issues and Coc is a lot more friendly to setup.
|
||||
-- {
|
||||
-- "neoclide/coc.nvim",
|
||||
-- branch = "release",
|
||||
-- config = get_plugin_file("coc.vim"),
|
||||
-- requires = { "antoinemadec/coc-fzf", opt = true },
|
||||
-- },
|
||||
}
|
||||
|
||||
return plugin_list
|
|
@ -1,36 +0,0 @@
|
|||
local vim = require("vim")
|
||||
local g = vim.g
|
||||
local cmd = vim.cmd
|
||||
|
||||
-- Don't use special separators
|
||||
g.airline_right_sep = "" -- (default: <)
|
||||
g.airline_left_sep = "" -- (default: >)
|
||||
|
||||
-- Tabline setup
|
||||
-- TODO: Figure out how to set # separated variables in lua (open for PRs)
|
||||
cmd[[let g:airline#extensions#tabline#enabled = 1]] -- Enable tabline (top line)
|
||||
cmd[[let g:airline#tabline#formatter = 'unique_tail']] -- Tabline filename formatter
|
||||
|
||||
-- Special symbols
|
||||
g.webdevicons_enable_airline_statusline = 0 -- Use special icons from vim-devicons (requires nerdfonts)
|
||||
g.airline_powerline_fonts = 1 -- Use special symbols from poweline fonts (line no, col no)
|
||||
if not os.getenv("DISPLAY") then -- Use ASCII-only if we're in TTY
|
||||
g.airline_symbols_ascii = 1
|
||||
end
|
||||
|
||||
-- Disable airline in nerdtree buffer
|
||||
-- TODO; For some reason, this fails even though it works in regular vimscript
|
||||
--[[
|
||||
cmd[[
|
||||
augroup filetype_nerdtree
|
||||
au!
|
||||
au FileType nerdtree call s:disable_airline_on_nerdtree()
|
||||
au WinEnter,BufWinEnter,TabEnter * call s:disable_airline_on_nerdtree()
|
||||
augroup END
|
||||
|
||||
fu s:disable_airline_on_nerdtree() abort
|
||||
let nerdtree_winnr = index(map(range(1, winnr('$')), {_,v -> getbufvar(winbufnr(v), '&ft')}), 'nerdtree') + 1
|
||||
call timer_start(0, {-> nerdtree_winnr && setwinvar(nerdtree_winnr, '&stl', '%#Normal#')})
|
||||
endfu
|
||||
]]
|
||||
--]]
|
|
@ -1,14 +0,0 @@
|
|||
local vim = require("vim")
|
||||
local m = require("utility.mappings")
|
||||
|
||||
m.keymap("n", "<A-b>", ":ToggleBlameLine<CR>")
|
||||
|
||||
-- Enable blame line automatically
|
||||
--vim.cmd[[autocmd BufEnter * EnableBlameLine]]
|
||||
|
||||
-- Specify the highlight group used for the virtual text ('Comment' by default)
|
||||
vim.g.blameLineVirtualTextHighlight = 'Question'
|
||||
|
||||
-- Don't show a blame line when it isn't yet commited
|
||||
-- there's no reason to show "Not yet commited" since we have git gutter
|
||||
vim.g.blameLineMessageWhenNotYetCommited = ''
|
|
@ -1,99 +0,0 @@
|
|||
" Converting these settings into lua isn't easy since we utilize
|
||||
" <SID> which needs to be in a vim script context, making it impossible
|
||||
" to replicate with simple vim.cmd call. It also contains a lot of function
|
||||
" definitions taken from the coc github page without provided lua alternatives
|
||||
" this makes it quite complicated to replicate this in pure lua,
|
||||
" however if anyone knows how to completely reproduce everything here in lua,
|
||||
" this is open to pull requests
|
||||
|
||||
let g:coc_global_extensions = [
|
||||
\ 'coc-pyright', 'coc-json', 'coc-git', 'coc-html', 'coc-css',
|
||||
\ 'coc-clangd', 'coc-cmake', 'coc-java', 'coc-sh', 'coc-toml',
|
||||
\ 'coc-yaml', 'coc-omnisharp', 'coc-markdownlint', 'coc-pairs',
|
||||
\ 'coc-lua'
|
||||
\ ]
|
||||
|
||||
nmap <leader>l :CocFzfList<cr>
|
||||
|
||||
" Use tab for trigger completion with characters ahead and navigate.
|
||||
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
|
||||
inoremap <silent><expr> <TAB>
|
||||
\ pumvisible() ? "\<C-n>" :
|
||||
\ <SID>check_back_space() ? "\<TAB>" :
|
||||
\ coc#refresh()
|
||||
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
|
||||
|
||||
|
||||
function! s:check_back_space() abort
|
||||
let col = col('.') - 1
|
||||
return !col || getline('.')[col - 1] =~# '\s'
|
||||
endfunction
|
||||
|
||||
" Use <c-space> to trigger completion.
|
||||
inoremap <silent><expr> <c-space> coc#refresh()
|
||||
|
||||
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
|
||||
" Coc only does snippet and additional edit on confirm.
|
||||
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
|
||||
" Or use `complete_info` if your vim support it, like:
|
||||
" inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
|
||||
|
||||
" Use `[g` and `]g` to navigate diagnostics
|
||||
nmap <silent> [g <Plug>(coc-diagnostic-prev)
|
||||
nmap <silent> ]g <Plug>(coc-diagnostic-next)
|
||||
|
||||
" Remap keys for gotos
|
||||
nmap <silent> gd <Plug>(coc-definition)
|
||||
nmap <silent> gy <Plug>(coc-type-definition)
|
||||
nmap <silent> gi <Plug>(coc-implementation)
|
||||
nmap <silent> gr <Plug>(coc-references)
|
||||
|
||||
function! s:show_documentation()
|
||||
if (index(['vim','help'], &filetype) >= 0)
|
||||
execute 'h '.expand('<cword>')
|
||||
else
|
||||
call CocAction('doHover')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Remap for rename current word
|
||||
nmap <leader>rn <Plug>(coc-rename)
|
||||
|
||||
" Remap for format selected region
|
||||
xmap <leader>f <Plug>(coc-format-selected)
|
||||
nmap <leader>f <Plug>(coc-format-selected)
|
||||
|
||||
augroup CocGroup
|
||||
autocmd!
|
||||
" Setup formatexpr specified filetype(s).
|
||||
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
|
||||
" Update signature help on jump placeholder
|
||||
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
|
||||
augroup end
|
||||
|
||||
" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
|
||||
xmap <leader>a <Plug>(coc-codeaction-selected)
|
||||
nmap <leader>a <Plug>(coc-codeaction-selected)
|
||||
|
||||
" Remap for do codeAction of current line
|
||||
nmap <leader>ac <Plug>(coc-codeaction)
|
||||
" Fix autofix problem of current line
|
||||
nmap <leader>qf <Plug>(coc-fix-current)
|
||||
|
||||
" Create mappings for function text object, requires document symbols feature of languageserver.
|
||||
xmap if <Plug>(coc-funcobj-i)
|
||||
xmap af <Plug>(coc-funcobj-a)
|
||||
omap if <Plug>(coc-funcobj-i)
|
||||
omap af <Plug>(coc-funcobj-a)
|
||||
|
||||
" Use `:Format` to format current buffer
|
||||
command! -nargs=0 Format :call CocAction('format')
|
||||
|
||||
" Use `:Fold` to fold current buffer
|
||||
command! -nargs=? Fold :call CocAction('fold', <f-args>)
|
||||
|
||||
" use `:OR` for organize import of current buffer
|
||||
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
|
||||
|
||||
" Add status line support, for integration with other plugin, checkout `:h coc-status`
|
||||
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
|
|
@ -1,10 +0,0 @@
|
|||
local m = require("utility.mappings")
|
||||
local vim = require("vim")
|
||||
local cmd = vim.cmd
|
||||
|
||||
-- Set up shortcuts to quickly comment some code
|
||||
m.keymap("n", "<A-/>", ":Commentary<CR>")
|
||||
m.keymap("v", "<A-/>", ":Commentary<CR>")
|
||||
|
||||
-- Set up comments for unhandled file types
|
||||
cmd[[autocmd FileType apache setlocal commentstring=#\ %s]]
|
|
@ -1,31 +0,0 @@
|
|||
local vim = require("vim")
|
||||
local cmd = vim.cmd
|
||||
local fn = vim.fn
|
||||
|
||||
-- Unused because the extension significantly slows down the opening time for vim.
|
||||
-- Also, while the semantic highlighting in it is neat, for me, it isn't worth in.
|
||||
--
|
||||
-- The extension default colorscheme makes the code look like unicorn vommit.
|
||||
-- I'd prefer a simpler extension that only really distinguishes between classes,
|
||||
-- functions and perhaps unused variables. I don't need to see a different color
|
||||
-- when I access something as an attribute, but it would be neat to see what that
|
||||
-- attribute actually holds, is it a class or a fucntion. But from my searching,
|
||||
-- I wasn't able to find anything like this. This is open to pull requests.
|
||||
-- Plugin: numirias/semshi
|
||||
|
||||
if (fn.has("python3")) then
|
||||
fn.system({"pip", "install", "nvim", "--upgrade"})
|
||||
end
|
||||
|
||||
cmd[[
|
||||
function MyCustomHighlights()
|
||||
hi semshiParameter ctermfg=117 guifg=#93CCED
|
||||
hi semshiParameterUnused ctermfg=117 guifg=#5e8193 cterm=underline gui=underline
|
||||
hi semshiBuiltin ctermfg=29 guifg=#48bda5
|
||||
hi semshiAttribute ctermfg=254 guifg=#d1d1d1
|
||||
hi semshiImported ctermfg=214 guifg=#f8c466 cterm=bold gui=bold
|
||||
hi semshiLocal ctermfg=209 guifg=#ff875f
|
||||
endfunction
|
||||
|
||||
autocmd FileType python call MyCustomHighlights()
|
||||
]]
|
|
@ -1,27 +0,0 @@
|
|||
local vim = require("vim")
|
||||
local cmd = vim.cmd
|
||||
local g = vim.g
|
||||
|
||||
-- Detect filetype based on filename for certain websites
|
||||
cmd[[
|
||||
autocmd BufEnter github.com_*.txt set filetype=markdown
|
||||
autocmd BufEnter txti.es_*.txt set filetype=typescript
|
||||
]]
|
||||
|
||||
-- Define firenvim configuration
|
||||
g.firenvim_config = {
|
||||
globalSettings = { alt="all" },
|
||||
localSettings = {
|
||||
[".*"] = {
|
||||
cmdline = "neovim",
|
||||
content = "text",
|
||||
priority = 0,
|
||||
selector = "textarea",
|
||||
-- Don't automatically take over, require the shortcut
|
||||
takeover = "never",
|
||||
},
|
||||
-- Enable automatic takeover on certain websites where it makes sense
|
||||
["https?://github.com"] = { takeover = "always", priority=1 },
|
||||
["https?://txti.es"] = { takeover = "always", priority = 1 },
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
local m = require("utility.mappings")
|
||||
local vim = require("vim")
|
||||
local cmd = vim.cmd
|
||||
local g = vim.g
|
||||
|
||||
g.fzf_layout = {
|
||||
up = '~90%',
|
||||
window = {
|
||||
width = 0.8,
|
||||
height = 0.8,
|
||||
yoffset = 0.5,
|
||||
offset = 0.5
|
||||
}
|
||||
}
|
||||
|
||||
cmd[[let $FZF_DEFAULT_OPTS = '--layout=reverse --info=inline']]
|
||||
|
||||
-- Customize the Files command to use ripgrep which respects .gitignore files
|
||||
cmd[[
|
||||
command! -bang -nargs=? -complete=dir Files
|
||||
\ call fzf#run(fzf#wrap('files', fzf#vim#with_preview({ 'dir': <q-args>, 'sink': 'e', 'source': 'rg --files --hidden' }), <bang>0))
|
||||
]]
|
||||
|
||||
-- Add an AllFiles variation that shows ignored files too
|
||||
cmd[[
|
||||
command! -bang -nargs=? -complete=dir AllFiles
|
||||
\ call fzf#run(fzf#wrap('allfiles', fzf#vim#with_preview({ 'dir': <q-args>, 'sink': 'e', 'source': 'rg --files --hidden --no-ignore' }), <bang>0))
|
||||
]]
|
||||
|
||||
m.keymap("n", "<leader>f", ":Files<CR>")
|
||||
m.keymap("n", "<leader>F", ":AllFiles<CR>")
|
||||
m.keymap("n", "<leader>b", ":Buffers<CR>")
|
||||
m.keymap("n", "<leader>h", ":History<CR>")
|
||||
m.keymap("n", "<leader>r", ":Rg<CR>")
|
||||
m.keymap("n", "<leader>R", ":Rg<space>", { silent = false })
|
||||
m.keymap("n", "<leader>gb", ":GBranches<CR>")
|
|
@ -1,87 +0,0 @@
|
|||
local vim = require("vim")
|
||||
local fn = vim.fn
|
||||
|
||||
-- Load in our default plugin independant LSP settings.
|
||||
-- These are loaded from here, because we don't need them if we aren't using
|
||||
-- these plugins, which actually load in the LSP configurations and install the
|
||||
-- individual language servers. However it is possible to configure nvim
|
||||
-- without these plugins and so this config is separated from the plugin
|
||||
-- config. for more info, check the comments in lsp/init.lua
|
||||
require("lsp")
|
||||
|
||||
|
||||
-- Configure nvim-cmp to respect LSP completions.
|
||||
local cmp = require("cmp")
|
||||
|
||||
cmp.setup({
|
||||
sources = {
|
||||
{ name = "nvim_lsp" }
|
||||
}
|
||||
})
|
||||
|
||||
-- The nvim-cmp almost supports LSP's capabilities so you should advertise it to LSP servers
|
||||
local cmp_capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
cmp_capabilities = require("cmp_nvim_lsp").update_capabilities(cmp_capabilities)
|
||||
|
||||
-- Load in the needed settigns for nvim-lsp-installer plugin.
|
||||
-- This ensures automatic installation for the individual language servers.
|
||||
local lsp_installer = require("nvim-lsp-installer")
|
||||
|
||||
-- Define some settings for the UI and installation path for the language
|
||||
-- servers.
|
||||
lsp_installer.settings({
|
||||
ui = {
|
||||
icons = {
|
||||
server_installed = "✓",
|
||||
server_pending = "➜",
|
||||
server_uninstalled = "✗"
|
||||
},
|
||||
keymaps = {
|
||||
toggle_server_expand = "<CR>",
|
||||
install_server = "i",
|
||||
update_server = "u",
|
||||
uninstall_server = "X",
|
||||
},
|
||||
},
|
||||
install_root_dir = fn.stdpath("data") .. "/lsp_servers",
|
||||
})
|
||||
|
||||
-- Define a table of requested language servers which should be automatically
|
||||
-- installed.
|
||||
--
|
||||
-- NOTE: pylsp requires external installaion with
|
||||
-- :PylspInstall pyls-flake8 pyls-mypy pyls-isort
|
||||
local requested_servers = {
|
||||
"clangd", "cmake", "omnisharp",
|
||||
"cssls", "dockerls", "gopls", "html",
|
||||
"hls", "jsonls", "jdtls", "tsserver",
|
||||
"sumneko_lua", "pyright", "pylsp",
|
||||
"sqlls", "vimls", "yamlls"
|
||||
}
|
||||
|
||||
-- Go through the requested servers and ensure installation
|
||||
-- Once the servers are ready, run setup() on them. This setup is basically
|
||||
-- running the lspconfig.server.setup() which means lspconfig is needed to do
|
||||
-- this.
|
||||
local lsp_installer_servers = require('nvim-lsp-installer.servers')
|
||||
for _, requested_server in pairs(requested_servers) do
|
||||
local server_available, server = lsp_installer_servers.get_server(requested_server)
|
||||
if server_available then
|
||||
-- Setup the server once it will become ready
|
||||
server:on_ready(function()
|
||||
-- Advertise completion capabilities by nvim-cmp
|
||||
local opts = { capabilities = cmp_capabilities }
|
||||
server:setup(opts)
|
||||
end)
|
||||
-- If the server isn't yet installed, schedule the installation
|
||||
if not server:is_installed() then
|
||||
server:install()
|
||||
end
|
||||
else
|
||||
vim.notify(
|
||||
"Can't install: Language server " .. server .. " was not found - SKIPPED",
|
||||
vim.log.levels.WARN,
|
||||
{ title = "Notification" }
|
||||
)
|
||||
end
|
||||
end
|
|
@ -1,62 +0,0 @@
|
|||
local m = require("utility.mappings")
|
||||
local vim = require("vim")
|
||||
local g = vim.g
|
||||
local fn = vim.fn
|
||||
local cmd = vim.cmd
|
||||
|
||||
-- Implement manual NERDTreeToggle, but use NERDTreeFind for openning.
|
||||
-- This makes NERDTree open with the current file pre-selected
|
||||
m.keymap("n", "<C-n>", "g:NERDTree.IsOpen() ? ':NERDTreeClose<CR>' : @% == '' ? ':NERDTree<CR>' : ':NERDTreeFind<CR>'", {expr=true})
|
||||
|
||||
g.NERDTreeShowHidden = 1
|
||||
g.NERDTreeMinimalUI = 1
|
||||
g.NERDTreeShowLineNumbers = 0
|
||||
g.NERDTreeWinSize = 25
|
||||
|
||||
g.NERDTreeDirArrowExpandable = '►'
|
||||
g.NERDTreeDirArrowCollapsible = '▼'
|
||||
|
||||
-- Disable devicons for nerdtree in TTY
|
||||
if not os.getenv("DISPLAY") then
|
||||
g.webdevicons_enable_nerdtree = 0
|
||||
else
|
||||
g.DevIconsEnableFoldersOpenClose = 1
|
||||
end
|
||||
|
||||
-- If a directory is specified, start NERDTree
|
||||
cmd[[
|
||||
autocmd StdinReadPre * let s:std_in=1
|
||||
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') |
|
||||
\ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] |
|
||||
\ endif
|
||||
]]
|
||||
|
||||
-- Exit Vim if NERDTree is the only window left.
|
||||
-- WARNING: This causes issues when closing buffers
|
||||
--[[
|
||||
cmd[[
|
||||
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() |
|
||||
\ quit | endif
|
||||
]]
|
||||
|
||||
-- If another buffer tries to replace NerdTree, put it in another window, and bring back NerdTree.
|
||||
cmd[[
|
||||
autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 |
|
||||
\ let buf=bufnr() | buffer# | execute "normal! \<C-W>w" | execute 'buffer'.buf | endif
|
||||
]]
|
||||
|
||||
-- Use $NERDTREE_BOOKMARKS environment variable for the location of .NERDTreeBookmarks file
|
||||
local bookmark_loc = os.getenv("NERDTREE_BOOKMARKS")
|
||||
if bookmark_loc then
|
||||
-- Check if file exists (lua doesn't have a built-in function for this)
|
||||
local file_exists = os.rename(bookmark_loc, bookmark_loc) and true or false
|
||||
|
||||
if not file_exists then
|
||||
-- While this is possible with os.execute in lua, we would need to do some hacky
|
||||
-- things to capture output from os.execute and it's simpler to just use vimscript
|
||||
local dir = fn.system("dirname $NERDTREE_BOOKMARKS")
|
||||
fn.system({"mkdir", "-p", dir})
|
||||
fn.system("touch $NERDTREE_BOOKMARKS")
|
||||
end
|
||||
g.NERDTreeBookmarksFile = bookmark_loc
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
local m = require("utility.mappings")
|
||||
local vim = require("vim")
|
||||
local cmd = vim.cmd
|
||||
|
||||
-- Define dap mappings (:help dap-mapping)
|
||||
local prefix = ":lua require('dap')."
|
||||
m.keymap("n", "<F5>", prefix .. "continue()<CR>")
|
||||
m.keymap("n", "<F10>", prefix .. "step_over()<CR>")
|
||||
m.keymap("n", "<F11>", prefix .. "step_into()<CR>")
|
||||
m.keymap("n", "<leader><F11>", prefix .. "step_out()<CR>")
|
||||
m.keymap("n", "<F9>", prefix .. "toggle_breakpoint()<CR>")
|
||||
m.keymap("n", "<leader><F9>", prefix .. "set_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>")
|
||||
m.keymap("n", "<F8>", prefix .. "set_breakpoint(nil, nil, vim.fn.input('Log point message: '))<CR>")
|
||||
m.keymap("n", "<leader>di", prefix .. "repl.open()<CR>")
|
||||
m.keymap("n", "<leader>dl", prefix .. "run_last()<CR>")
|
||||
|
||||
-- Setup dap for python (requires nvim-dap-python plugin)
|
||||
require('dap-python').setup('/usr/bin/python') -- Path to python with `debugpy` library installed
|
||||
require('dap-python').test_runner = 'pytest' -- Use pytest to run unit tests
|
||||
|
||||
-- Python mappings
|
||||
local pyprefix = ":lua require('dap-python')."
|
||||
m.keymap("n", "<leader>dptm", pyprefix .. "test_method()<CR>")
|
||||
m.keymap("n", "<leader>dptc", pyprefix .. "test_class()<CR>")
|
||||
m.keymap("v", "<leader>ds", "<ESC>" .. pyprefix .. "debug_selection()<CR>")
|
|
@ -1,28 +0,0 @@
|
|||
local vim = require("vim")
|
||||
local g = vim.g
|
||||
|
||||
-- Enable treesitter highlight for all languages
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
-- Always automatically install parsers for these languages
|
||||
ensure_installed = {
|
||||
"bash", "python", "lua", "rust", "go", "haskell",
|
||||
"c", "cpp", "cmake", "c_sharp", "java", "dockerfile",
|
||||
"json", "toml", "yaml", "regex", "vim", "html", "css",
|
||||
"typescript", "javascript",
|
||||
},
|
||||
highlight = {
|
||||
enable = true,
|
||||
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
||||
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
||||
-- Using this option may slow down your editor, and you may see some duplicate highlights.
|
||||
-- Instead of true it can also be a list of languages
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
}
|
||||
|
||||
-- Use git instead of curl for downloading parsers
|
||||
require("nvim-treesitter.install").prefer_git = true
|
||||
|
||||
-- Use treesitter for syntax-aware folding
|
||||
g.foldmethod = "expr"
|
||||
g.foldexpr = "nvim_treesitter#foldexpr()"
|
|
@ -1,4 +0,0 @@
|
|||
local vim = require("vim")
|
||||
local cmd = vim.cmd
|
||||
|
||||
cmd[[colorscheme codedark]]
|
|
@ -1,12 +0,0 @@
|
|||
local vim = require("vim")
|
||||
local cmd = vim.cmd
|
||||
local g = vim.g
|
||||
|
||||
local wiki_conf = {}
|
||||
wiki_conf["path"] = "~/Personal/vimwiki"
|
||||
wiki_conf["path_html"] = "~/Personal/vimwiki-html"
|
||||
wiki_conf["html_template"] = "~/Personal/vimwiki-html/template.tpl"
|
||||
wiki_conf["syntax"] = "markdown"
|
||||
wiki_conf["ext"] = ".md"
|
||||
g.vimwiki_list = {wiki_conf}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
local vim = require("vim")
|
||||
local api = vim.api
|
||||
local cmd = vim.cmd
|
||||
|
||||
local M = {}
|
||||
|
||||
-- Define a keymap
|
||||
function M.keymap(mode, shortcut, command, options)
|
||||
-- Assume silent, noremap unless specified otherwise
|
||||
local opts = {noremap=true, silent=true}
|
||||
|
||||
if options then opts = vim.tbl_extend("force", opts, options) end
|
||||
api.nvim_set_keymap(mode, shortcut, command, opts)
|
||||
end
|
||||
|
||||
-- Define an abbreviation
|
||||
function M.abbrev(mode, input, result, reabbrev)
|
||||
-- Assume noreabbrev unless specified otherwise
|
||||
reabbrev = reabbrev or false
|
||||
local command
|
||||
if reabbrev then
|
||||
command = mode .. "abbrev"
|
||||
else
|
||||
command = mode .. "noreabbrev"
|
||||
end
|
||||
cmd(command .. " " .. input .. " " .. result)
|
||||
end
|
||||
|
||||
return M
|
|
@ -1,7 +0,0 @@
|
|||
-- This file is here to allow running `local vim = require("vim")`, which
|
||||
-- avoids the hassle of having to ignore vim as undefined-global for lua
|
||||
-- language server diagnostics. Another advantage is that it actually allows
|
||||
-- us to detect the attributes of vim so we will get suggestions.
|
||||
|
||||
---@diagnostic disable-next-line:undefined-global
|
||||
return vim
|
Loading…
Reference in a new issue