summaryrefslogtreecommitdiff
path: root/.config/nvim/lua
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2021-12-02 23:02:50 +0100
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2021-12-02 23:02:50 +0100
commit8213801b89e9d2a27c6b1df50881b8476679b870 (patch)
treeecd4a1e2489cff11c4e3c703dc80111d26b97a7a /.config/nvim/lua
parenta3690ed8ca90823787fbaddb72f0a1874f1e999d (diff)
LunarVim updates
Diffstat (limited to '.config/nvim/lua')
-rw-r--r--.config/nvim/lua/core/autocmds.lua2
-rw-r--r--.config/nvim/lua/core/autopairs.lua2
-rw-r--r--.config/nvim/lua/core/bufferline.lua8
-rw-r--r--.config/nvim/lua/core/info.lua24
-rw-r--r--.config/nvim/lua/core/lualine/components.lua3
-rw-r--r--.config/nvim/lua/core/lualine/conditions.lua2
-rw-r--r--.config/nvim/lua/core/nvimtree.lua46
-rw-r--r--.config/nvim/lua/core/which-key.lua10
-rw-r--r--.config/nvim/lua/keymappings.lua230
-rw-r--r--.config/nvim/lua/lsp/manager.lua56
-rw-r--r--.config/nvim/lua/lsp/null-ls/code_actions.lua81
-rw-r--r--.config/nvim/lua/lsp/null-ls/formatters.lua8
-rw-r--r--.config/nvim/lua/lsp/null-ls/linters.lua8
-rw-r--r--.config/nvim/lua/plugin-loader.lua14
-rw-r--r--.config/nvim/lua/plugins.lua91
15 files changed, 367 insertions, 218 deletions
diff --git a/.config/nvim/lua/core/autocmds.lua b/.config/nvim/lua/core/autocmds.lua
index ecdcf36..046b7c0 100644
--- a/.config/nvim/lua/core/autocmds.lua
+++ b/.config/nvim/lua/core/autocmds.lua
@@ -3,7 +3,7 @@ local Log = require "core.log"
--- Load the default set of autogroups and autocommands.
function M.load_augroups()
- local user_config_file = vim.fn.resolve(require("config"):get_user_config_path())
+ local user_config_file = require("config"):get_user_config_path()
return {
_general_settings = {
diff --git a/.config/nvim/lua/core/autopairs.lua b/.config/nvim/lua/core/autopairs.lua
index ec7f651..0759fd6 100644
--- a/.config/nvim/lua/core/autopairs.lua
+++ b/.config/nvim/lua/core/autopairs.lua
@@ -9,6 +9,7 @@ function M.config()
all = "(",
tex = "{",
},
+ enable_check_bracket_line = false,
---@usage check treesitter
check_ts = true,
ts_config = {
@@ -26,6 +27,7 @@ M.setup = function()
autopairs.setup {
check_ts = options.builtin.autopairs.check_ts,
+ enable_check_bracket_line = options.builtin.autopairs.enable_check_bracket_line,
ts_config = options.builtin.autopairs.ts_config,
}
diff --git a/.config/nvim/lua/core/bufferline.lua b/.config/nvim/lua/core/bufferline.lua
index 68b08ce..ebd7a64 100644
--- a/.config/nvim/lua/core/bufferline.lua
+++ b/.config/nvim/lua/core/bufferline.lua
@@ -5,17 +5,13 @@ M.config = function()
active = true,
on_config_done = nil,
keymap = {
- normal_mode = {
- ["<S-l>"] = ":BufferNext<CR>",
- ["<S-h>"] = ":BufferPrevious<CR>",
- },
+ normal_mode = {},
},
}
end
M.setup = function()
- local keymap = require "keymappings"
- keymap.append_to_defaults(options.builtin.bufferline.keymap)
+ require("keymappings").load(options.builtin.bufferline.keymap)
if options.builtin.bufferline.on_config_done then
options.builtin.bufferline.on_config_done()
diff --git a/.config/nvim/lua/core/info.lua b/.config/nvim/lua/core/info.lua
index d448492..646cf71 100644
--- a/.config/nvim/lua/core/info.lua
+++ b/.config/nvim/lua/core/info.lua
@@ -34,6 +34,23 @@ local function make_formatters_info(ft)
return section
end
+local function make_code_actions_info(ft)
+ local null_actions = require "lsp.null-ls.code_actions"
+ local registered_actions = null_actions.list_registered_providers(ft)
+ local supported_actions = null_actions.list_available(ft)
+ local section = {
+ "Code actions info",
+ fmt(
+ "* Active: %s%s",
+ table.concat(registered_actions, "  , "),
+ vim.tbl_count(registered_actions) > 0 and "  " or ""
+ ),
+ fmt("* Supported: %s", str_list(supported_actions)),
+ }
+
+ return section
+end
+
local function make_linters_info(ft)
local null_linters = require "lsp.null-ls.linters"
local supported_linters = null_linters.list_available(ft)
@@ -123,6 +140,8 @@ function M.toggle_popup(ft)
local linters_info = make_linters_info(ft)
+ local code_actions_info = make_code_actions_info(ft)
+
local content_provider = function(popup)
local content = {}
@@ -153,6 +172,7 @@ function M.toggle_popup(ft)
vim.cmd [[let m=matchadd("NvimInfoHeader", "Language Server Protocol (LSP) info")]]
vim.cmd [[let m=matchadd("NvimInfoHeader", "Formatters info")]]
vim.cmd [[let m=matchadd("NvimInfoHeader", "Linters info")]]
+ vim.cmd [[let m=matchadd("NvimInfoHeader", "Code actions info")]]
vim.cmd('let m=matchadd("NvimInfoIdentifier", " ' .. ft .. '$")')
vim.cmd 'let m=matchadd("string", "true")'
vim.cmd 'let m=matchadd("string", "active")'
@@ -168,6 +188,10 @@ function M.toggle_popup(ft)
require("lsp.null-ls.linters").list_available(ft),
"NvimInfoIdentifier"
)
+ tbl_set_highlight(
+ require("lsp.null-ls.code_actions").list_available(ft),
+ "NvimInfoIdentifier"
+ )
end
local Popup = require("interface.popup"):new {
diff --git a/.config/nvim/lua/core/lualine/components.lua b/.config/nvim/lua/core/lualine/components.lua
index 6ef1cff..42ec112 100644
--- a/.config/nvim/lua/core/lualine/components.lua
+++ b/.config/nvim/lua/core/lualine/components.lua
@@ -125,9 +125,8 @@ return {
local supported_linters = linters.list_registered_providers(buf_ft)
vim.list_extend(buf_client_names, supported_linters)
- return table.concat(buf_client_names, ", ")
+ return "[" .. table.concat(buf_client_names, ", ") .. "]"
end,
- icon = " ",
color = { fg = colors.fg, bg = colors.bg },
cond = conditions.hide_in_width,
},
diff --git a/.config/nvim/lua/core/lualine/conditions.lua b/.config/nvim/lua/core/lualine/conditions.lua
index 3ee4fbb..6e120b2 100644
--- a/.config/nvim/lua/core/lualine/conditions.lua
+++ b/.config/nvim/lua/core/lualine/conditions.lua
@@ -1,4 +1,4 @@
-local window_width_limit = 80
+local window_width_limit = 70
local conditions = {
buffer_not_empty = function()
diff --git a/.config/nvim/lua/core/nvimtree.lua b/.config/nvim/lua/core/nvimtree.lua
index 2ca2fb1..b525351 100644
--- a/.config/nvim/lua/core/nvimtree.lua
+++ b/.config/nvim/lua/core/nvimtree.lua
@@ -6,12 +6,22 @@ function M.config()
active = true,
on_config_done = nil,
setup = {
+ disable_netrw = true,
+ hijack_netrw = true,
open_on_setup = false,
- auto_close = true,
- open_on_tab = false,
- update_focused_file = {
+ ignore_ft_on_setup = {
+ "startify",
+ "dashboard",
+ "alpha",
+ },
+ update_to_buf_dir = {
enable = true,
+ auto_open = true,
},
+ auto_close = true,
+ open_on_tab = false,
+ hijack_cursor = false,
+ update_cwd = false,
diagnostics = {
enable = true,
icons = {
@@ -21,14 +31,36 @@ function M.config()
error = "",
},
},
+ update_focused_file = {
+ enable = true,
+ update_cwd = true,
+ ignore_list = {},
+ },
+ system_open = {
+ cmd = nil,
+ args = {},
+ },
+ git = {
+ enable = true,
+ ignore = true,
+ timeout = 200,
+ },
view = {
width = 30,
+ height = 30,
side = "left",
auto_resize = true,
+ number = false,
+ relativenumber = false,
mappings = {
custom_only = false,
+ list = {},
},
},
+ filters = {
+ dotfiles = true,
+ custom = { ".git", "node_modules", ".cache" },
+ },
},
show_icons = {
git = 1,
@@ -37,13 +69,10 @@ function M.config()
folder_arrows = 1,
tree_width = 30,
},
- ignore = { ".git", "node_modules", ".cache" },
quit_on_open = 0,
- hide_dotfiles = 0,
git_hl = 1,
+ disable_window_picker = 0,
root_folder_modifier = ":t",
- allow_resize = 1,
- auto_ignore_ft = { "startify", "dashboard" },
icons = {
default = "",
symlink = "",
@@ -65,6 +94,7 @@ function M.config()
},
},
}
+ options.builtin.which_key.mappings["e"] = { "<cmd>NvimTreeToggle<CR>", "Explorer" }
end
function M.setup()
@@ -98,8 +128,6 @@ function M.setup()
}
end
- options.builtin.which_key.mappings["e"] = { "<cmd>NvimTreeToggle<CR>", "Explorer" }
-
local tree_view = require "nvim-tree.view"
-- Add nvim_tree open callback
diff --git a/.config/nvim/lua/core/which-key.lua b/.config/nvim/lua/core/which-key.lua
index 85f766c..333ce6d 100644
--- a/.config/nvim/lua/core/which-key.lua
+++ b/.config/nvim/lua/core/which-key.lua
@@ -61,7 +61,10 @@ M.config = function()
-- NOTE: Prefer using : over <cmd> as the latter avoids going back in normal-mode.
-- see https://neovim.io/doc/user/map.html#:map-cmd
vmappings = {
- ["k"] = { "<ESC><CMD>lua ___comment_gc(vim.fn.visualmode())<CR>", "Comment" },
+ ["k"] = {
+ "<ESC><CMD>lua require('Comment.api').gc(vim.fn.visualmode())<CR>",
+ "Comment",
+ },
},
mappings = {
["w"] = { "<cmd>w!<CR>", "Save" },
@@ -189,10 +192,7 @@ M.config = function()
"<cmd>edit " .. get_config_dir() .. "/config.lua<cr>",
"Edit config.lua",
},
- k = {
- "<cmd>lua require('keymappings').print()<cr>",
- "View NeoVim's default keymappings",
- },
+ k = { "<cmd>Telescope keymaps<cr>", "View NeoVim's keymappings" },
i = {
"<cmd>lua require('core.info').toggle_popup(vim.bo.filetype)<cr>",
"Toggle NeoVim Info",
diff --git a/.config/nvim/lua/keymappings.lua b/.config/nvim/lua/keymappings.lua
index 74f4233..8319ab3 100644
--- a/.config/nvim/lua/keymappings.lua
+++ b/.config/nvim/lua/keymappings.lua
@@ -21,15 +21,113 @@ local mode_adapters = {
command_mode = "c",
}
+local defaults = {
+ ---@usage change or add keymappings for insert mode
+ 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.
+ ["<A-k>"] = "<Esc>:m .-2<CR>==gi",
+ -- navigation
+ ["<A-Up>"] = "<C-\\><C-N><C-w>k",
+ ["<A-Down>"] = "<C-\\><C-N><C-w>j",
+ ["<A-Left>"] = "<C-\\><C-N><C-w>h",
+ ["<A-Right>"] = "<C-\\><C-N><C-w>l",
+ },
+
+ ---@usage change or add keymappings for normal mode
+ normal_mode = {
+ -- Better window movement
+ ["<C-h>"] = "<C-w>h",
+ ["<C-j>"] = "<C-w>j",
+ ["<C-k>"] = "<C-w>k",
+ ["<C-l>"] = "<C-w>l",
+
+ -- Resize with arrows
+ ["<C-Up>"] = ":resize -2<CR>",
+ ["<C-Down>"] = ":resize +2<CR>",
+ ["<C-Left>"] = ":vertical resize -2<CR>",
+ ["<C-Right>"] = ":vertical resize +2<CR>",
+
+ -- Tab switch buffer
+ ["<S-l>"] = ":BufferNext<CR>",
+ ["<S-h>"] = ":BufferPrevious<CR>",
+
+ -- Move current line / block with Alt-j/k a la vscode.
+ ["<A-j>"] = ":m .+1<CR>==",
+ ["<A-k>"] = ":m .-2<CR>==",
+
+ -- QuickFix
+ ["]q"] = ":cnext<CR>",
+ ["[q"] = ":cprev<CR>",
+ ["<C-q>"] = ":call QuickFixToggle()<CR>",
+ },
+
+ ---@usage change or add keymappings for terminal mode
+ term_mode = {
+ -- Terminal window navigation
+ ["<C-h>"] = "<C-\\><C-N><C-w>h",
+ ["<C-j>"] = "<C-\\><C-N><C-w>j",
+ ["<C-k>"] = "<C-\\><C-N><C-w>k",
+ ["<C-l>"] = "<C-\\><C-N><C-w>l",
+ },
+
+ ---@usage change or add keymappings for visual mode
+ visual_mode = {
+ -- Better indenting
+ ["<"] = "<gv",
+ [">"] = ">gv",
+
+ -- ["p"] = '"0p',
+ -- ["P"] = '"0P',
+ },
+
+ ---@usage change or add keymappings for visual block mode
+ visual_block_mode = {
+ -- Move selected line / block of text in visual mode
+ ["K"] = ":move '<-2<CR>gv-gv",
+ ["J"] = ":move '>+1<CR>gv-gv",
+
+ -- Move current line / block with Alt-j/k ala vscode.
+ ["<A-j>"] = ":m '>+1<CR>gv-gv",
+ ["<A-k>"] = ":m '<-2<CR>gv-gv",
+ },
+
+ ---@usage change or add keymappings for command mode
+ command_mode = {
+ -- navigate tab completion with <c-j> and <c-k>
+ -- runs conditionally
+ ["<C-j>"] = {
+ 'pumvisible() ? "\\<C-n>" : "\\<C-j>"',
+ { expr = true, noremap = true },
+ },
+ ["<C-k>"] = {
+ 'pumvisible() ? "\\<C-p>" : "\\<C-k>"',
+ { expr = true, noremap = true },
+ },
+ },
+}
+
+if vim.fn.has "mac" == 1 then
+ defaults.normal_mode["<A-Up>"] = defaults.normal_mode["<C-Up>"]
+ defaults.normal_mode["<A-Down>"] = defaults.normal_mode["<C-Down>"]
+ defaults.normal_mode["<A-Left>"] = defaults.normal_mode["<C-Left>"]
+ defaults.normal_mode["<A-Right>"] = defaults.normal_mode["<C-Right>"]
+ Log:debug "Activated mac keymappings"
+end
+
-- Append key mappings to lunarvim's defaults for a given mode
-- @param keymaps The table of key mappings containing a list per mode (normal_mode, insert_mode, ..)
function M.append_to_defaults(keymaps)
- local default = M.get_defaults()
- options.keys = options.keys or default
for mode, mappings in pairs(keymaps) do
- options.keys[mode] = options.keys[mode] or default[mode]
for k, v in pairs(mappings) do
- options.keys[mode][k] = v
+ defaults[mode][k] = v
end
end
end
@@ -39,7 +137,7 @@ end
function M.clear(keymaps)
local default = M.get_defaults()
for mode, mappings in pairs(keymaps) do
- local translated_mode = mode_adapters[mode] and mode_adapters[mode] or mode
+ local translated_mode = mode_adapters[mode] or mode
for key, _ in pairs(mappings) do
-- some plugins may override default bindings that the user hasn't manually overriden
if
@@ -57,7 +155,7 @@ end
-- @param key The key of keymap
-- @param val Can be form as a mapping or tuple of mapping and user defined opt
function M.set_keymaps(mode, key, val)
- local opt = generic_opts[mode] and generic_opts[mode] or generic_opts_any
+ local opt = generic_opts[mode] or generic_opts_any
if type(val) == "table" then
opt = val[2]
val = val[1]
@@ -73,7 +171,7 @@ end
-- @param mode The keymap mode, can be one of the keys of mode_adapters
-- @param keymaps The list of key mappings
function M.load_mode(mode, keymaps)
- mode = mode_adapters[mode] and mode_adapters[mode] or mode
+ mode = mode_adapters[mode] or mode
for k, v in pairs(keymaps) do
M.set_keymaps(mode, k, v)
end
@@ -88,118 +186,18 @@ function M.load(keymaps)
end
end
-function M.get_defaults()
- local keys = {
- ---@usage change or add keymappings for insert mode
- 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.
- ["<A-k>"] = "<Esc>:m .-2<CR>==gi",
- -- navigation
- ["<A-Up>"] = "<C-\\><C-N><C-w>k",
- ["<A-Down>"] = "<C-\\><C-N><C-w>j",
- ["<A-Left>"] = "<C-\\><C-N><C-w>h",
- ["<A-Right>"] = "<C-\\><C-N><C-w>l",
- },
-
- ---@usage change or add keymappings for normal mode
- normal_mode = {
- -- Better window movement
- ["<C-h>"] = "<C-w>h",
- ["<C-j>"] = "<C-w>j",
- ["<C-k>"] = "<C-w>k",
- ["<C-l>"] = "<C-w>l",
-
- -- Resize with arrows
- ["<C-Up>"] = ":resize -2<CR>",
- ["<C-Down>"] = ":resize +2<CR>",
- ["<C-Left>"] = ":vertical resize -2<CR>",
- ["<C-Right>"] = ":vertical resize +2<CR>",
-
- -- Tab switch buffer
- ["<S-l>"] = ":BufferNext<CR>",
- ["<S-h>"] = ":BufferPrevious<CR>",
-
- -- Move current line / block with Alt-j/k a la vscode.
- ["<A-j>"] = ":m .+1<CR>==",
- ["<A-k>"] = ":m .-2<CR>==",
-
- -- QuickFix
- ["]q"] = ":cnext<CR>",
- ["[q"] = ":cprev<CR>",
- ["<C-q>"] = ":call QuickFixToggle()<CR>",
- },
-
- ---@usage change or add keymappings for terminal mode
- term_mode = {
- -- Terminal window navigation
- ["<C-h>"] = "<C-\\><C-N><C-w>h",
- ["<C-j>"] = "<C-\\><C-N><C-w>j",
- ["<C-k>"] = "<C-\\><C-N><C-w>k",
- ["<C-l>"] = "<C-\\><C-N><C-w>l",
- },
-
- ---@usage change or add keymappings for visual mode
- visual_mode = {
- -- Better indenting
- ["<"] = "<gv",
- [">"] = ">gv",
-
- -- ["p"] = '"0p',
- -- ["P"] = '"0P',
- },
-
- ---@usage change or add keymappings for visual block mode
- visual_block_mode = {
- -- Move selected line / block of text in visual mode
- ["K"] = ":move '<-2<CR>gv-gv",
- ["J"] = ":move '>+1<CR>gv-gv",
-
- -- Move current line / block with Alt-j/k ala vscode.
- ["<A-j>"] = ":m '>+1<CR>gv-gv",
- ["<A-k>"] = ":m '<-2<CR>gv-gv",
- },
-
- ---@usage change or add keymappings for command mode
- command_mode = {
- -- navigate tab completion with <c-j> and <c-k>
- -- runs conditionally
- ["<C-j>"] = {
- 'pumvisible() ? "\\<C-n>" : "\\<C-j>"',
- { expr = true, noremap = true },
- },
- ["<C-k>"] = {
- 'pumvisible() ? "\\<C-p>" : "\\<C-k>"',
- { expr = true, noremap = true },
- },
- },
- }
-
- if vim.fn.has "mac" == 1 then
- keys.normal_mode["<A-Up>"] = keys.normal_mode["<C-Up>"]
- keys.normal_mode["<A-Down>"] = keys.normal_mode["<C-Down>"]
- keys.normal_mode["<A-Left>"] = keys.normal_mode["<C-Left>"]
- keys.normal_mode["<A-Right>"] = keys.normal_mode["<C-Right>"]
- Log:debug "Activated mac keymappings"
+-- Load the default keymappings
+function M.load_defaults()
+ M.load(M.get_defaults())
+ options.keys = {}
+ for idx, _ in pairs(defaults) do
+ options.keys[idx] = {}
end
-
- return keys
end
-function M.print(mode)
- print "List of LunarVim's default keymappings (not including which-key)"
- if mode then
- print(vim.inspect(options.keys[mode]))
- else
- print(vim.inspect(options.keys))
- end
+-- Get the default keymappings
+function M.get_defaults()
+ return defaults
end
return M
diff --git a/.config/nvim/lua/lsp/manager.lua b/.config/nvim/lua/lsp/manager.lua
index 24fb6e3..268e90d 100644
--- a/.config/nvim/lua/lsp/manager.lua
+++ b/.config/nvim/lua/lsp/manager.lua
@@ -54,42 +54,42 @@ function M.setup(server_name, user_config)
if lsp_utils.is_client_active(server_name) then
return
end
- local servers = require "nvim-lsp-installer.servers"
local config = resolve_config(server_name, user_config)
+ local servers = require "nvim-lsp-installer.servers"
local server_available, requested_server = servers.get_server(server_name)
- if server_available then
- local install_notification = false
-
- if not requested_server:is_installed() then
- if options.lsp.automatic_servers_installation then
- Log:debug "Automatic server installation detected"
- requested_server:install()
- install_notification = true
- else
- Log:debug(requested_server.name .. " is not managed by the automatic installer")
- end
- end
-
- requested_server:on_ready(function()
- if install_notification then
- vim.notify(
- string.format("Installation complete for [%s] server", requested_server.name),
- vim.log.levels.INFO
- )
- end
- install_notification = false
- requested_server:setup(config)
- end)
- else
- -- since it may not be installed, don't attempt to configure the LSP unless there is a custom provider
- local has_custom_provider, _ = pcall(require, "lsp/providers/" .. server_name)
- if has_custom_provider then
+ local is_overridden = vim.tbl_contains(options.lsp.override, server_name)
+ if not server_available or is_overridden then
+ pcall(function()
require("lspconfig")[server_name].setup(config)
buf_try_add(server_name)
+ end)
+ return
+ end
+
+ local install_notification = false
+
+ if not requested_server:is_installed() then
+ if options.lsp.automatic_servers_installation then
+ Log:debug "Automatic server installation detected"
+ requested_server:install()
+ install_notification = true
+ else
+ Log:debug(requested_server.name .. " is not managed by the automatic installer")
end
end
+
+ requested_server:on_ready(function()
+ if install_notification then
+ vim.notify(
+ string.format("Installation complete for [%s] server", requested_server.name),
+ vim.log.levels.INFO
+ )
+ end
+ install_notification = false
+ requested_server:setup(config)
+ end)
end
return M
diff --git a/.config/nvim/lua/lsp/null-ls/code_actions.lua b/.config/nvim/lua/lsp/null-ls/code_actions.lua
new file mode 100644
index 0000000..70cecda
--- /dev/null
+++ b/.config/nvim/lua/lsp/null-ls/code_actions.lua
@@ -0,0 +1,81 @@
+local M = {}
+
+local null_ls = require "null-ls"
+local services = require "lsp.null-ls.services"
+local Log = require "core.log"
+
+local METHOD = null_ls.methods.CODE_ACTION
+
+local is_registered = function(name)
+ local query = {
+ name = name,
+ method = METHOD,
+ }
+ return require("null-ls.sources").is_registered(query)
+end
+
+function M.list_registered_providers(filetype)
+ local registered_providers = services.list_registered_providers_names(filetype)
+ return registered_providers[METHOD] or {}
+end
+
+function M.list_available(filetype)
+ local availables = require("null-ls.sources").get_available(filetype, METHOD)
+ local actors = vim.tbl_map(function(src)
+ return src.name
+ end, availables)
+ table.sort(actors)
+ return actors
+end
+
+function M.list_configured(actions_configs)
+ local actors, errors = {}, {}
+
+ for _, config in ipairs(actions_configs) do
+ vim.validate {
+ ["config.name"] = { config.name, "string" },
+ }
+
+ local name = config.name:gsub("-", "_")
+ local actor = null_ls.builtins.code_actions[name]
+
+ if not actor then
+ Log:error("Not a valid code_actions: " .. config.name)
+ errors[name] = {} -- Add data here when necessary
+ elseif is_registered(config.name) then
+ Log:trace "Skipping registering the source more than once"
+ else
+ local command
+ if actor._opts.command then
+ command = services.find_command(actor._opts.command)
+ end
+ if not command and actor._opts.command ~= nil then
+ Log:warn("Not found: " .. actor._opts.command)
+ errors[name] = {} -- Add data here when necessary
+ else
+ Log:debug("Using code_actions: " .. (command or config.name))
+ table.insert(
+ actors,
+ actor.with {
+ command = command, -- could be nil
+ extra_args = config.args,
+ filetypes = config.filetypes,
+ }
+ )
+ end
+ end
+ end
+
+ return { supported = actors, unsupported = errors }
+end
+
+function M.setup(actions_configs)
+ if vim.tbl_isempty(actions_configs) then
+ return
+ end
+
+ local actions = M.list_configured(actions_configs)
+ null_ls.register { sources = actions.supported }
+end
+
+return M
diff --git a/.config/nvim/lua/lsp/null-ls/formatters.lua b/.config/nvim/lua/lsp/null-ls/formatters.lua
index 7bd4dc4..72d622a 100644
--- a/.config/nvim/lua/lsp/null-ls/formatters.lua
+++ b/.config/nvim/lua/lsp/null-ls/formatters.lua
@@ -4,7 +4,13 @@ local null_ls = require "null-ls"
local services = require "lsp.null-ls.services"
local Log = require "core.log"
-local is_registered = require("null-ls.sources").is_registered
+local is_registered = function(name)
+ local query = {
+ name = name,
+ method = require("null-ls").methods.FORMATTING,
+ }
+ return require("null-ls.sources").is_registered(query)
+end
function M.list_registered_providers(filetype)
local null_ls_methods = require "null-ls.methods"
diff --git a/.config/nvim/lua/lsp/null-ls/linters.lua b/.config/nvim/lua/lsp/null-ls/linters.lua
index 0d34365..ec5e25a 100644
--- a/.config/nvim/lua/lsp/null-ls/linters.lua
+++ b/.config/nvim/lua/lsp/null-ls/linters.lua
@@ -4,7 +4,13 @@ local null_ls = require "null-ls"
local services = require "lsp.null-ls.services"
local Log = require "core.log"
-local is_registered = require("null-ls.sources").is_registered
+local is_registered = function(name)
+ local query = {
+ name = name,
+ method = require("null-ls").methods.DIAGNOSTICS,
+ }
+ return require("null-ls.sources").is_registered(query)
+end
function M.list_registered_providers(filetype)
local null_ls_methods = require "null-ls.methods"
diff --git a/.config/nvim/lua/plugin-loader.lua b/.config/nvim/lua/plugin-loader.lua
index 1754b5b..9c83e46 100644
--- a/.config/nvim/lua/plugin-loader.lua
+++ b/.config/nvim/lua/plugin-loader.lua
@@ -5,8 +5,6 @@ local Log = require "core.log"
-- we need to reuse this outside of init()
local compile_path = get_config_dir() .. "/plugin/packer_compiled.lua"
-local _, packer = pcall(require, "packer")
-
function plugin_loader.init(opts)
opts = opts or {}
@@ -26,10 +24,15 @@ function plugin_loader.init(opts)
vim.cmd "packadd packer.nvim"
end
+ if options.log and options.log.level then
+ log_level = options.log.level
+ end
+
+ local _, packer = pcall(require, "packer")
packer.init {
package_root = package_root,
compile_path = compile_path,
- log = { level = "warn" },
+ log = { level = log_level },
git = { clone_timeout = 300 },
max_jobs = 50,
display = {
@@ -67,6 +70,11 @@ end
function plugin_loader.load(configurations)
Log:debug "loading plugins configuration"
+ local packer_available, packer = pcall(require, "packer")
+ if not packer_available then
+ Log:warn "skipping loading plugins until Packer is installed"
+ return
+ end
local status_ok, _ = xpcall(function()
packer.startup(function(use)
for _, plugins in ipairs(configurations) do
diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua
index b653803..a83fdf9 100644
--- a/.config/nvim/lua/plugins.lua
+++ b/.config/nvim/lua/plugins.lua
@@ -1,50 +1,50 @@
local commit = {
- packer = "7f62848f3a92eac61ae61def5f59ddb5e2cc6823",
- lsp_config = "903a1fbca91b74e6fbc905366ce38364b9d7ba98",
- nlsp_settings = "29f49afe27b43126d45a05baf3161a28b929f2f1",
- null_ls = "cf2bc3185af066cb25f1bf6faa99727e2c47ef77",
- fix_cursor_hold = "0e4e22d21975da60b0fd2d302285b3b603f9f71e",
- lsp_installer = "37d9326f4ca4093b04eabdb697fec3764e226f88",
- structlog = "6f1403a192791ff1fa7ac845a73de9e860f781f1",
- popup = "f91d80973f80025d4ed00380f2e06c669dfda49d",
- plenary = "96e821e8001c21bc904d3c15aa96a70c11462c5f",
- telescope = "078a48db9e0720b07bfcb8b59342c5305a1d1fdc",
- telescope_fzf_native = "59e38e1661ffdd586cb7fc22ca0b5a05c7caf988",
- nvim_cmp = "ca6386854982199a532150cf3bd711395475ebd2",
- friendly_snippets = "94f1d917435c71bc6494d257afa90d4c9449aed2",
- autopairs = "f858ab38b532715dbaf7b2773727f8622ba04322",
- treesitter = "47cfda2c6711077625c90902d7722238a8294982",
- context_commentstring = "159c5b9a2cdb8a8fe342078b7ac8139de76bad62",
- nvim_tree = "f92b7e7627c5a36f4af6814c408211539882c4f3",
- gitsigns = "61a81b0c003de3e12555a5626d66fb6a060d8aca",
- which_key = "d3032b6d3e0adb667975170f626cb693bfc66baa",
- comment = "620445b87a0d1640fac6991f9c3338af8dec1884",
- project = "3a1f75b18f214064515ffba48d1eb7403364cc6a",
- nvim_web_devicons = "ee101462d127ed6a5561ce9ce92bfded87d7d478",
- lualine = "3f5cdc51a08c437c7705e283eebd4cf9fbb18f80",
barbar = "6e638309efcad2f308eb9c5eaccf6f62b794bbab",
- toggleterm = "5f9ba91157a25be5ee7395fbc11b1a8f25938365",
- luasnip = "bab7cc2c32fba00776d2f2fc4704bed4eee2d082",
+ cmp_buffer = "a706dc69c49110038fe570e5c9c33d6d4f67015b",
cmp_luasnip = "16832bb50e760223a403ffa3042859845dd9ef9d",
- cmp_buffer = "d1ca295ce584ec80763a6dc043080874b57ccffc",
- cmp_nvim_lsp = "accbe6d97548d8d3471c04d512d36fa61d0e4be8",
- cmp_path = "97661b00232a2fe145fe48e295875bc3299ed1f7",
+ cmp_nvim_lsp = "134117299ff9e34adde30a735cd8ca9cf8f3db81",
cmp_nvim_lua = "d276254e7198ab7d00f117e88e223b4bd8c02d21",
+ cmp_path = "e30d3fdee650a07330654efab1951b2f1b91435e",
+ comment = "a6e1c127fa7f19ec4e3edbffab1aacb2852b6db3",
+ fixcursorhold = "0e4e22d21975da60b0fd2d302285b3b603f9f71e",
+ friendly_snippets = "e3506d575e120253b4aa47ec2100786fd1e9c38d",
+ gitsigns = "9678750f209671551c335c4f22658a6554c2f439",
+ lualine = "1ae4f0aa74f0b34222c5ef3281b34602a76b2b00",
+ luasnip = "7fc3cc24f3c1f1a43e861f589ca48ff3dff0b213",
+ nlsp_settings = "199bc1b2859206488423b676da4a7d010b1a3373",
+ null_ls = "128b8d85506e44f1e7e0f4acd9f2ba02fc7cee05",
+ nvim_autopairs = "fba2503bd8cd0d8861054523aae39c4ac0680c07",
+ nvim_cmp = "d17d41bdbd4731759d1b3d368204dc18ce3c84f3",
+ nvim_lsp_installer = "a4016db22296e4eefbcda2e8b94de74db2d7cb65",
+ nvim_lspconfig = "5b8624c1bcd332e9fd7ae33a2ca910adb31a7ae7",
+ nvim_tree = "e842f088847c98da59e14eb543bde11c45c87ef7",
+ nvim_treesitter = "8d1547f0bcd0831876678eeb238c3ba9a528189b",
+ nvim_ts_context_commentstring = "9f5e422e1030e7073e593ad32c5354aa0bcb0176",
+ nvim_web_devicons = "8df4988ecf8599fc1f8f387bbf2eae790e4c5ffb",
+ packer = "db3c3e3379613443d94e677a6ac3f61278e36e47",
+ plenary = "1c31adb35fcebe921f65e5c6ff6d5481fa5fa5ac",
+ popup = "b7404d35d5d3548a82149238289fa71f7f6de4ac",
+ project = "71d0e23dcfc43cfd6bb2a97dc5a7de1ab47a6538",
+ structlog = "6f1403a192791ff1fa7ac845a73de9e860f781f1",
+ telescope = "ef245548a858690fa8f2db1f1a0eaf41b93a6ef6",
+ telescope_fzf_native = "b8662b076175e75e6497c59f3e2799b879d7b954",
+ toggleterm = "265bbff68fbb8b2a5fb011272ec469850254ec9f",
+ which_key = "d3032b6d3e0adb667975170f626cb693bfc66baa",
}
return {
-- Packer can manage itself as an optional plugin
{ "wbthomason/packer.nvim", commit = commit.packer },
- { "neovim/nvim-lspconfig", commit = commit.lsp_config },
+ { "neovim/nvim-lspconfig", commit = commit.nvim_lspconfig },
{ "tamago324/nlsp-settings.nvim", commit = commit.nlsp_settings },
{
"jose-elias-alvarez/null-ls.nvim",
commit = commit.null_ls,
},
- { "antoinemadec/FixCursorHold.nvim", commit = commit.fix_cursor_hold }, -- Needed while issue https://github.com/neovim/neovim/issues/12587 is still open
+ { "antoinemadec/FixCursorHold.nvim", commit = commit.fixcursorhold }, -- Needed while issue https://github.com/neovim/neovim/issues/12587 is still open
{
"williamboman/nvim-lsp-installer",
- commit = commit.lsp_installer,
+ commit = commit.nvim_lsp_installer,
},
{ "Tastyep/structlog.nvim", commit = commit.structlog },
@@ -70,26 +70,31 @@ return {
"hrsh7th/nvim-cmp",
commit = commit.nvim_cmp,
config = function()
- require("core.cmp").setup()
- end,
- run = function()
- -- cmp's config requires cmp to be installed to run the first time
- if not options.builtin.cmp then
- require("core.cmp").config()
+ if options.builtin.cmp then
+ require("core.cmp").setup()
end
end,
+ requires = {
+ "L3MON4D3/LuaSnip",
+ "rafamadriz/friendly-snippets",
+ },
},
{
"rafamadriz/friendly-snippets",
commit = commit.friendly_snippets,
- -- event = "InsertCharPre",
- -- disable = not options.builtin.compe.active,
},
{
"L3MON4D3/LuaSnip",
+ config = function()
+ require("luasnip/loaders/from_vscode").lazy_load()
+ end,
commit = commit.luasnip,
},
{
+ "hrsh7th/cmp-nvim-lsp",
+ commit = commit.cmp_nvim_lsp,
+ },
+ {
"saadparwaiz1/cmp_luasnip",
commit = commit.cmp_luasnip,
},
@@ -98,10 +103,6 @@ return {
commit = commit.cmp_buffer,
},
{
- "hrsh7th/cmp-nvim-lsp",
- commit = commit.cmp_nvim_lsp,
- },
- {
"hrsh7th/cmp-path",
commit = commit.cmp_path,
},
@@ -113,7 +114,7 @@ return {
-- Autopairs
{
"windwp/nvim-autopairs",
- commit = commit.autopairs,
+ commit = commit.nvim_autopairs,
-- event = "InsertEnter",
config = function()
require("core.autopairs").setup()
@@ -133,7 +134,7 @@ return {
},
{
"JoosepAlviste/nvim-ts-context-commentstring",
- commit = commit.context_commentstring,
+ commit = commit.nvim_ts_context_commentstring,
event = "BufReadPost",
},