summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2021-09-06 21:53:56 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2021-09-06 21:53:56 +0200
commit6a1732982287ef5aff2a6de171192b9e2bb90758 (patch)
tree543f94f80d548b9ed7a9d0daecb08575a01a9a45
parentb89e893bfc7b8893dc4c13aa55f627096b32758a (diff)
Updates to nvim from lvim
-rw-r--r--.config/nvim/config.lua2
-rw-r--r--.config/nvim/ftplugin/dockerfile.lua2
-rw-r--r--.config/nvim/init.lua11
-rw-r--r--.config/nvim/lua/config/defaults.lua24
-rw-r--r--.config/nvim/lua/config/init.lua6
-rw-r--r--.config/nvim/lua/core/autocmds.lua5
-rw-r--r--.config/nvim/lua/core/dashboard.lua3
-rw-r--r--.config/nvim/lua/core/info.lua325
-rw-r--r--.config/nvim/lua/core/log.lua66
-rw-r--r--.config/nvim/lua/core/lualine/components.lua53
-rw-r--r--.config/nvim/lua/core/lualine/conditions.lua10
-rw-r--r--.config/nvim/lua/core/lualine/styles.lua7
-rw-r--r--.config/nvim/lua/core/nvimtree.lua7
-rw-r--r--.config/nvim/lua/core/terminal.lua4
-rw-r--r--.config/nvim/lua/core/which-key.lua23
-rw-r--r--.config/nvim/lua/keymappings.lua24
-rw-r--r--.config/nvim/lua/lsp/handlers.lua135
-rw-r--r--.config/nvim/lua/lsp/init.lua18
-rw-r--r--.config/nvim/lua/lsp/null-ls/formatters.lua8
-rw-r--r--.config/nvim/lua/lsp/null-ls/init.lua2
-rw-r--r--.config/nvim/lua/lsp/null-ls/linters.lua8
-rw-r--r--.config/nvim/lua/lsp/peek.lua25
-rw-r--r--.config/nvim/lua/plugin-loader.lua14
-rw-r--r--.config/nvim/lua/plugins.lua5
-rw-r--r--.config/nvim/lua/utils/ft.lua2
-rw-r--r--.config/nvim/lua/utils/init.lua12
26 files changed, 444 insertions, 357 deletions
diff --git a/.config/nvim/config.lua b/.config/nvim/config.lua
index 803e7d0..b0582f0 100644
--- a/.config/nvim/config.lua
+++ b/.config/nvim/config.lua
@@ -10,7 +10,7 @@ options.keys.normal_mode["<esc><esc>"] = "<cmd>nohlsearch<cr>"
-- LSP
options.lsp.diagnostics.virtual_text = false
-require("extra.json_schemas").setup()
+-- require("extra.json_schemas").setup()
-- After changing plugin config it is recommended to run :PackerCompile
options.builtin.compe.active = true
diff --git a/.config/nvim/ftplugin/dockerfile.lua b/.config/nvim/ftplugin/dockerfile.lua
index 72ec7f9..98fa710 100644
--- a/.config/nvim/ftplugin/dockerfile.lua
+++ b/.config/nvim/ftplugin/dockerfile.lua
@@ -1 +1 @@
-require("lsp").setup "docker"
+require("lsp").setup "dockerfile"
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua
index ff6c632..033963e 100644
--- a/.config/nvim/init.lua
+++ b/.config/nvim/init.lua
@@ -1,3 +1,5 @@
+local home_dir = vim.loop.os_homedir()
+
-- TODO: we need something like this: vim.opt.packpath = vim.opt.rtp
vim.cmd [[let &packpath = &runtimepath]]
-- }}}
@@ -6,12 +8,13 @@ local config = require "config"
config:init()
config:load()
-local autocmds = require "core.autocmds"
-autocmds.define_augroups(options.autocommands)
-
local plugins = require "plugins"
local plugin_loader = require("plugin-loader").init()
plugin_loader:load { plugins, options.plugins }
+
+local Log = require "core.log"
+Log:info "Starting nvim"
+
vim.g.colors_name = options.colorscheme -- Colorscheme must get called after plugins are loaded or it will break new installs.
vim.cmd("colorscheme " .. options.colorscheme)
@@ -31,7 +34,7 @@ end
local lsp_settings_status_ok, lsp_settings = pcall(require, "nlspsettings")
if lsp_settings_status_ok then
lsp_settings.setup {
- config_home = os.getenv "HOME" .. "/.config/nvim/lsp-settings",
+ config_home = home_dir .. "/.config/nvim/lsp-settings",
}
end
diff --git a/.config/nvim/lua/config/defaults.lua b/.config/nvim/lua/config/defaults.lua
index 82c08a4..f62fd87 100644
--- a/.config/nvim/lua/config/defaults.lua
+++ b/.config/nvim/lua/config/defaults.lua
@@ -1,3 +1,4 @@
+local home_dir = vim.loop.os_homedir()
CONFIG_PATH = vim.fn.stdpath "config"
DATA_PATH = vim.fn.stdpath "data"
CACHE_PATH = vim.fn.stdpath "cache"
@@ -11,7 +12,7 @@ options = {
line_wrap_cursor_movement = true,
transparent_window = false,
format_on_save = true,
- vsnip_dir = os.getenv "HOME" .. "/.config/snippets",
+ vsnip_dir = home_dir .. "/.config/snippets",
database = { save_location = "~/.config/nvim_db", auto_execute = 1 },
keys = {},
@@ -336,7 +337,7 @@ options.lang = {
},
},
},
- docker = {
+ dockerfile = {
formatters = {},
linters = {},
lsp = {
@@ -953,15 +954,16 @@ options.lang = {
},
},
tailwindcss = {
- active = false,
- filetypes = {
- "html",
- "css",
- "scss",
- "javascript",
- "javascriptreact",
- "typescript",
- "typescriptreact",
+ lsp = {
+ active = false,
+ provider = "tailwindcss",
+ setup = {
+ cmd = {
+ DATA_PATH
+ .. "/lspinstall/tailwindcss/node_modules/.bin/tailwindcss-language-server",
+ "--stdio",
+ },
+ },
},
},
terraform = {
diff --git a/.config/nvim/lua/config/init.lua b/.config/nvim/lua/config/init.lua
index e6d6389..7d42ad1 100644
--- a/.config/nvim/lua/config/init.lua
+++ b/.config/nvim/lua/config/init.lua
@@ -1,5 +1,6 @@
+local home_dir = vim.loop.os_homedir()
local M = {
- path = string.format("%s/.config/nvim/config.lua", os.getenv "HOME"),
+ path = string.format("%s/.config/nvim/config.lua", home_dir),
}
--- Initialize nvim default configuration
@@ -19,6 +20,7 @@ end
--- Override the configuration with a user provided one
-- @param config_path The path to the configuration overrides
function M:load(config_path)
+ local autocmds = require "core.autocmds"
config_path = config_path or self.path
local ok, err = pcall(vim.cmd, "luafile " .. config_path)
if not ok then
@@ -29,6 +31,8 @@ function M:load(config_path)
self.path = config_path
+ autocmds.define_augroups(options.autocommands)
+
local settings = require "config.settings"
settings.load_commands()
end
diff --git a/.config/nvim/lua/core/autocmds.lua b/.config/nvim/lua/core/autocmds.lua
index 036cc80..3432e14 100644
--- a/.config/nvim/lua/core/autocmds.lua
+++ b/.config/nvim/lua/core/autocmds.lua
@@ -9,6 +9,11 @@ options.autocommands = {
"lua require('utils.ft').do_filetype(vim.fn.expand(\"<amatch>\"))",
},
{
+ "FileType",
+ "qf",
+ "nnoremap <silent> <buffer> q :q<CR>",
+ },
+ {
"TextYankPost",
"*",
"lua require('vim.highlight').on_yank({higroup = 'Search', timeout = 200})",
diff --git a/.config/nvim/lua/core/dashboard.lua b/.config/nvim/lua/core/dashboard.lua
index f9eec22..70e862e 100644
--- a/.config/nvim/lua/core/dashboard.lua
+++ b/.config/nvim/lua/core/dashboard.lua
@@ -1,4 +1,5 @@
local M = {}
+local home_dir = vim.loop.os_homedir()
M.config = function(config)
options.builtin.dashboard = {
@@ -6,7 +7,7 @@ M.config = function(config)
on_config_done = nil,
search_handler = "telescope",
disable_at_vim_enter = 0,
- session_directory = os.getenv "HOME" .. "/.cache/options/sessions",
+ session_directory = home_dir .. "/.cache/options/sessions",
custom_header = {
" ##############..... ############## ",
" ##############......############## ",
diff --git a/.config/nvim/lua/core/info.lua b/.config/nvim/lua/core/info.lua
index 5b7ef53..83e3542 100644
--- a/.config/nvim/lua/core/info.lua
+++ b/.config/nvim/lua/core/info.lua
@@ -1,208 +1,201 @@
-local M = {}
-local u = require "utils"
-local null_ls_handler = require "lsp.null-ls"
-local indent = " "
-
-M.banner = {
- "",
- "",
- " ⠀⠀⠀ ⠀⠀ ⣺⡿⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀",
- " ⣿⣯ ⣿⡟⠀ ⣤⣤⠀⠀⠀⠀⣠⣤⣤⣤⣄⣤⣤",
- "⠀⣿⣿⠀⣰⡟⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⣿⡟⢸⣿⡇⢀⣿",
- "⠀⢻⣿⢰⣿⠀⠀⠀⠀⠀⠀⣾⡇⠀⠀⠀⢸⣿⠇⢸⣿⠀⢸⡏",
- "⠀⢸⣿⣿⠋⠀⠀⠀⢠⣤⣤⣿⣥⣤⡄⠀⣼⣿⠀⣸⡏⠀⣿⠃",
- "⠀⠈⠉⠉⠀⠀⠀⠀⠈⠉⠉⠉⠉⠉⠁⠀⠉⠁⠀⠉⠁⠀⠉⠀",
- "",
- "",
+local M = {
+ banner = {
+ "",
+ [[ _ ___ ]],
+ [[| | / (_)___ ___ ]],
+ [[| | / / / __ `__ \]],
+ [[| |/ / / / / / / /]],
+ [[|___/_/_/ /_/ /_/ ]],
+ },
}
+local fmt = string.format
+
local function str_list(list)
- return "[ " .. table.concat(list, ", ") .. " ]"
+ return fmt("[ %s ]", table.concat(list, ", "))
end
local function get_formatter_suggestion_msg(ft)
- local supported_formatters = u.get_supported_formatters_by_filetype(ft)
- return {
- "-------------------------------------------------------------------",
- "",
- "  HINT ",
- "",
- indent .. "* List of supported formatters: " .. str_list(supported_formatters),
- "",
- indent .. "You can enable a supported formatter by adding this to your config.lua",
- "",
- indent
- .. "options.lang."
- .. tostring(ft)
- .. [[.formatting = { { exe = ']]
- .. table.concat(supported_formatters, "|")
- .. [[' } }]],
+ local config = require "config"
+ local null_formatters = require "lsp.null-ls.formatters"
+ local supported_formatters = null_formatters.list_available(ft)
+ local section = {
+ " HINT ",
"",
- "-------------------------------------------------------------------",
+ fmt("* List of supported formatters: %s", str_list(supported_formatters)),
}
+
+ if not vim.tbl_isempty(supported_formatters) then
+ vim.list_extend(section, {
+ "* Configured formatter needs to be installed and executable.",
+ fmt("* Enable installed formatter(s) with following config in %s", config.path),
+ "",
+ fmt(
+ " options.lang.%s.formatters = { { exe = '%s' } }",
+ ft,
+ table.concat(supported_formatters, "│")
+ ),
+ })
+ end
+
+ return section
end
local function get_linter_suggestion_msg(ft)
- local supported_linters = u.get_supported_linters_by_filetype(ft)
- return {
- "-------------------------------------------------------------------",
- "",
- "  HINT ",
+ local config = require "config"
+ local null_linters = require "lsp.null-ls.linters"
+ local supported_linters = null_linters.list_available(ft)
+ local section = {
+ " HINT ",
"",
- indent .. "* List of supported linters: " .. str_list(supported_linters),
- "",
- indent .. "You can enable a supported linter by adding this to your config.lua",
- "",
- indent
- .. "options.lang."
- .. tostring(ft)
- .. [[.linters = { { exe = ']]
- .. table.concat(supported_linters, "|")
- .. [[' } }]],
- "",
- "-------------------------------------------------------------------",
+ fmt("* List of supported linters: %s", str_list(supported_linters)),
}
-end
----creates an average size popup
----@param buf_lines a list of lines to print
----@param callback could be used to set syntax highlighting rules for example
----@return bufnr buffer number of the created buffer
----@return win_id window ID of the created popup
-function M.create_simple_popup(buf_lines, callback)
- -- runtime/lua/vim/lsp/util.lua
- local bufnr = vim.api.nvim_create_buf(false, true)
- local height_percentage = 0.7
- local width_percentage = 0.8
- local row_start_percentage = (1 - height_percentage) / 2
- local col_start_percentage = (1 - width_percentage) / 2
- local opts = {}
- opts.relative = "editor"
- opts.height = math.ceil(vim.o.lines * height_percentage)
- opts.row = math.ceil(vim.o.lines * row_start_percentage)
- opts.col = math.floor(vim.o.columns * col_start_percentage)
- opts.width = math.floor(vim.o.columns * width_percentage)
- opts.border = {
- "┌",
- "-",
- "┐",
- "|",
- "┘",
- "-",
- "└",
- "|",
- }
+ if not vim.tbl_isempty(supported_linters) then
+ vim.list_extend(section, {
+ "* Configured linter needs to be installed and executable.",
+ fmt("* Enable installed linter(s) with following config in %s", config.path),
+ "",
+ fmt(
+ " options.lang.%s.linters = { { exe = '%s' } }",
+ ft,
+ table.concat(supported_linters, "│")
+ ),
+ })
+ end
- local win_id = vim.api.nvim_open_win(bufnr, true, opts)
-
- vim.api.nvim_win_set_buf(win_id, bufnr)
- -- this needs to be window option!
- vim.api.nvim_win_set_option(win_id, "number", false)
- vim.cmd "setlocal nocursorcolumn"
- vim.cmd "setlocal wrap"
- -- set buffer options
- vim.api.nvim_buf_set_option(bufnr, "filetype", "lspinfo")
- vim.lsp.util.close_preview_autocmd({ "BufHidden", "BufLeave" }, win_id)
- buf_lines = vim.lsp.util._trim(buf_lines, {})
- vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, buf_lines)
- vim.api.nvim_buf_set_option(bufnr, "modifiable", false)
- if type(callback) == "function" then
- callback()
+ return section
+end
+
+local function tbl_set_highlight(terms, highlight_group)
+ for _, v in pairs(terms) do
+ vim.cmd('let m=matchadd("' .. highlight_group .. '", "' .. v .. "[ ,│']\")")
end
- return bufnr, win_id
end
function M.toggle_popup(ft)
- local client = u.get_active_client_by_ft(ft)
- local is_client_active = not client.is_stopped()
- local client_enabled_caps = require("lsp").get_ls_capabilities(client.id)
- local num_caps = vim.tbl_count(client_enabled_caps)
- local null_ls_providers = null_ls_handler.get_registered_providers_by_filetype(ft)
-
- local missing_linters = options.lang[ft].linters._failed_requests or {}
- local missing_formatters = options.lang[ft].formatters._failed_requests or {}
-
- local buf_lines = {}
- vim.list_extend(buf_lines, M.banner)
+ local lsp_utils = require "lsp.utils"
+ local client = lsp_utils.get_active_client_by_ft(ft)
+ local is_client_active = false
+ local client_enabled_caps = {}
+ local client_name = ""
+ local client_id = 0
+ local document_formatting = false
+ if client ~= nil then
+ is_client_active = not client.is_stopped()
+ client_enabled_caps = require("lsp").get_ls_capabilities(client.id)
+ client_name = client.name
+ client_id = client.id
+ document_formatting = client.resolved_capabilities.document_formatting
+ end
local header = {
- "Detected filetype is: " .. tostring(ft),
- "",
- "Treesitter active: " .. tostring(next(vim.treesitter.highlighter.active) ~= nil),
- "",
- "",
+ fmt("Detected filetype: %s", ft),
+ fmt(
+ "Treesitter active: %s",
+ tostring(next(vim.treesitter.highlighter.active) ~= nil)
+ ),
}
- vim.list_extend(buf_lines, header)
+ local text = require "interface.text"
local lsp_info = {
- "Associated language-server: " .. client.name,
- indent .. "* Active: " .. tostring(is_client_active) .. ", id: " .. tostring(
- client.id
- ),
- indent .. "* Formatting support: " .. tostring(
- client.resolved_capabilities.document_formatting
- ),
- indent .. "* Capabilities list: " .. table.concat(
- vim.list_slice(client_enabled_caps, 1, num_caps / 2),
- ", "
- ),
- indent .. indent .. indent .. table.concat(
- vim.list_slice(client_enabled_caps, ((num_caps / 2) + 1)),
- ", "
- ),
- "",
+ "Language Server Protocol (LSP) info",
+ fmt("* Associated server: %s", client_name),
+ fmt("* Active: %s (id: %d)", tostring(is_client_active), client_id),
+ fmt("* Supports formatting: %s", tostring(document_formatting)),
}
- vim.list_extend(buf_lines, lsp_info)
-
+ if not vim.tbl_isempty(client_enabled_caps) then
+ local caps_text = "* Capabilities list: "
+ local caps_text_len = caps_text:len()
+ local enabled_caps = text.format_table(client_enabled_caps, 3, " | ")
+ enabled_caps = text.shift_left(enabled_caps, caps_text_len)
+ enabled_caps[1] = fmt("%s%s", caps_text, enabled_caps[1]:sub(caps_text_len + 1))
+ vim.list_extend(lsp_info, enabled_caps)
+ end
+ local null_ls = require "lsp.null-ls"
+ local registered_providers = null_ls.list_supported_provider_names(ft)
+ local registered_count = vim.tbl_count(registered_providers)
local null_ls_info = {
- "Configured providers: " .. table.concat(null_ls_providers, "  , ") .. "  ",
- "",
+ "Formatters and linters",
+ fmt(
+ "* Configured providers: %s%s",
+ table.concat(registered_providers, "  , "),
+ registered_count > 0 and "  " or ""
+ ),
}
- vim.list_extend(buf_lines, null_ls_info)
- local missing_formatters_status
- if vim.tbl_count(missing_formatters) > 0 then
+ local null_formatters = require "lsp.null-ls.formatters"
+ local missing_formatters = null_formatters.list_unsupported_names(ft)
+ local missing_formatters_status = {}
+ if not vim.tbl_isempty(missing_formatters) then
missing_formatters_status = {
- "Missing formatters: " .. table.concat(missing_formatters, "  , ") .. "  ",
- "",
+ fmt(
+ "* Missing formatters: %s",
+ table.concat(missing_formatters, "  , ") .. "  "
+ ),
}
- vim.list_extend(buf_lines, missing_formatters_status)
end
- local missing_linters_status
- if vim.tbl_count(missing_linters) > 0 then
+ local null_linters = require "lsp.null-ls.linters"
+ local missing_linters = null_linters.list_unsupported_names(ft)
+ local missing_linters_status = {}
+ if not vim.tbl_isempty(missing_linters) then
missing_linters_status = {
- "Missing linters: " .. table.concat(missing_linters, "  , ") .. "  ",
- "",
+ fmt(
+ "* Missing linters: %s",
+ table.concat(missing_linters, "  , ") .. "  "
+ ),
}
- vim.list_extend(buf_lines, missing_linters_status)
end
- vim.list_extend(buf_lines, get_formatter_suggestion_msg(ft))
-
- vim.list_extend(buf_lines, get_linter_suggestion_msg(ft))
+ local content_provider = function(popup)
+ local content = {}
+
+ for _, section in ipairs {
+ M.banner,
+ { "" },
+ { "" },
+ header,
+ { "" },
+ lsp_info,
+ { "" },
+ null_ls_info,
+ missing_formatters_status,
+ missing_linters_status,
+ { "" },
+ { "" },
+ get_formatter_suggestion_msg(ft),
+ { "" },
+ { "" },
+ get_linter_suggestion_msg(ft),
+ } do
+ vim.list_extend(content, section)
+ end
+
+ return text.align(popup, content, 0.5)
+ end
local function set_syntax_hl()
- --TODO: highlighting is either inconsistent or not working :\
- vim.cmd("syntax match Identifier /filetype is: .*\\zs\\<" .. ft .. "\\>/")
- vim.cmd("syntax match Identifier /server: .*\\zs\\<" .. client.name .. "\\>/")
- vim.cmd(
- "syntax match Identifier /providers: .*\\zs\\<"
- .. table.concat(null_ls_providers, ", ")
- .. "\\>/"
- )
- vim.cmd(
- "syntax match Identifier /formatters: .*\\zs\\<"
- .. table.concat(missing_formatters, ", ")
- .. "\\>/"
- )
- vim.cmd(
- "syntax match Identifier /linters: .*\\zs\\<"
- .. table.concat(missing_linters, ", ")
- .. "\\>/"
- )
+ vim.cmd [[highlight NvimInfoIdentifier gui=bold]]
+ vim.cmd [[highlight link NvimInfoHeader Type]]
+ vim.cmd [[let m=matchadd("NvimInfoHeader", "Language Server Protocol (LSP) info")]]
+ vim.cmd [[let m=matchadd("NvimInfoHeader", "Formatters and linters")]]
+ vim.cmd('let m=matchadd("NvimInfoIdentifier", " ' .. ft .. '$")')
+ vim.cmd 'let m=matchadd("string", "true")'
+ vim.cmd 'let m=matchadd("error", "false")'
+ tbl_set_highlight(registered_providers, "NvimInfoIdentifier")
+ tbl_set_highlight(missing_formatters, "NvimInfoIdentifier")
+ tbl_set_highlight(missing_linters, "NvimInfoIdentifier")
+ vim.cmd('let m=matchadd("NvimInfoIdentifier", "' .. client_name .. '")')
end
- return M.create_simple_popup(buf_lines, set_syntax_hl)
+ local Popup = require("interface.popup"):new {
+ win_opts = { number = false },
+ buf_opts = { modifiable = false, filetype = "lspinfo" },
+ }
+ Popup:display(content_provider)
+ set_syntax_hl()
+
+ return Popup
end
return M
diff --git a/.config/nvim/lua/core/log.lua b/.config/nvim/lua/core/log.lua
index 35ba4be..bcc68e4 100644
--- a/.config/nvim/lua/core/log.lua
+++ b/.config/nvim/lua/core/log.lua
@@ -1,29 +1,59 @@
local Log = {}
---- Creates a log handle based on Plenary.log
----@param opts these are passed verbatim to Plenary.log
----@return log handle
-function Log:new(opts)
- local status_ok, _ = pcall(require, "plenary.log")
- if not status_ok then
- return nil
+--- Adds a log entry using Plenary.log
+---@param msg any
+---@param level string [same as vim.log.log_levels]
+function Log:add_entry(msg, level)
+ assert(type(level) == "string")
+ if self.__handle then
+ -- plenary uses lower-case log levels
+ self.__handle[level:lower()](msg)
end
+ local status_ok, plenary = pcall(require, "plenary")
+ if status_ok then
+ local default_opts = { plugin = "nvim", level = options.log.level }
+ local handle = plenary.log.new(default_opts)
+ handle[level:lower()](msg)
+ self.__handle = handle
+ end
+ -- don't do anything if plenary is not available
+end
- local obj = require("plenary.log").new(opts)
- local path = string.format("%s/%s.log", vim.api.nvim_call_function("stdpath", { "cache" }), opts.plugin)
+---Retrieves the path of the logfile
+---@return string path of the logfile
+function Log:get_path()
+ return string.format("%s/%s.log", vim.fn.stdpath "cache", "nvim")
+end
- obj.get_path = function()
- return path
- end
+---Add a log entry at TRACE level
+---@param msg any
+function Log:trace(msg)
+ self:add_entry(msg, "TRACE")
+end
+
+---Add a log entry at DEBUG level
+---@param msg any
+function Log:debug(msg)
+ self:add_entry(msg, "DEBUG")
+end
+
+---Add a log entry at INFO level
+---@param msg any
+function Log:info(msg)
+ self:add_entry(msg, "INFO")
+end
- return obj
+---Add a log entry at WARN level
+---@param msg any
+function Log:warn(msg)
+ self:add_entry(msg, "WARN")
end
---- Creates or retrieves a log handle for the default logfile
---- based on Plenary.log
----@return log handle
-function Log:get_default()
- return Log:new { plugin = "lunarvim", level = options.log.level }
+---Add a log entry at ERROR level
+---@param msg any
+function Log:error(msg)
+ self:add_entry(msg, "ERROR")
end
+setmetatable({}, Log)
return Log
diff --git a/.config/nvim/lua/core/lualine/components.lua b/.config/nvim/lua/core/lualine/components.lua
index 4777392..adae368 100644
--- a/.config/nvim/lua/core/lualine/components.lua
+++ b/.config/nvim/lua/core/lualine/components.lua
@@ -1,6 +1,17 @@
local conditions = require "core.lualine.conditions"
local colors = require "core.lualine.colors"
+local function diff_source()
+ local gitsigns = vim.b.gitsigns_status_dict
+ if gitsigns then
+ return {
+ added = gitsigns.added,
+ modified = gitsigns.changed,
+ removed = gitsigns.removed,
+ }
+ end
+end
+
return {
mode = {
function()
@@ -22,34 +33,29 @@ return {
end,
left_padding = 0,
right_padding = 0,
- condition = function()
- return true
- end,
+ condition = nil,
color = { fg = colors.fg, bg = colors.bg },
},
branch = {
- "branch",
+ "b:gitsigns_head",
icon = " ",
- condition = function()
- return conditions.hide_in_width() and conditions.check_git_workspace()
- end,
color = { gui = "bold", fg = colors.fg, bg = colors.bg },
+ condition = conditions.hide_in_width,
},
filename = {
"filename",
- condition = function()
- return true
- end,
color = { fg = colors.fg, bg = colors.bg },
+ condition = nil,
},
diff = {
"diff",
+ source = diff_source,
symbols = { added = "  ", modified = "柳", removed = " " },
color_added = { fg = colors.green },
color_modified = { fg = colors.yellow },
color_removed = { fg = colors.red },
- condition = conditions.hide_in_width,
color = {},
+ condition = nil,
},
python_env = {
function()
@@ -67,15 +73,15 @@ return {
end
return ""
end,
- condition = conditions.hide_in_width,
color = { fg = colors.green },
+ condition = conditions.hide_in_width,
},
diagnostics = {
"diagnostics",
sources = { "nvim_lsp" },
symbols = { error = " ", warn = " ", info = " ", hint = " " },
- condition = conditions.hide_in_width,
color = {},
+ condition = conditions.hide_in_width,
},
treesitter = {
function()
@@ -84,14 +90,17 @@ return {
end
return ""
end,
- condition = conditions.hide_in_width,
color = { fg = colors.green },
+ condition = conditions.hide_in_width,
},
lsp = {
function(msg)
- msg = msg or "LSP Inactive"
+ msg = msg or "LS Inactive"
local buf_clients = vim.lsp.buf_get_clients()
if next(buf_clients) == nil then
+ if type(msg) == "boolean" or #msg == 0 then
+ return "LS Inactive"
+ end
return msg
end
local buf_ft = vim.bo.filetype
@@ -120,18 +129,18 @@ return {
return table.concat(buf_client_names, ", ")
end,
icon = " ",
- condition = conditions.hide_in_width,
color = { fg = colors.fg, bg = colors.bg },
+ condition = conditions.hide_in_width,
},
location = {
"location",
- condition = conditions.hide_in_width,
color = { fg = colors.fg, bg = colors.bg },
+ condition = conditions.hide_in_width,
},
progress = {
"progress",
- condition = conditions.hide_in_width,
color = { fg = colors.fg, bg = colors.bg },
+ condition = conditions.hide_in_width,
},
spaces = {
function()
@@ -141,14 +150,14 @@ return {
end
return label .. vim.api.nvim_buf_get_option(0, "shiftwidth") .. " "
end,
- condition = conditions.hide_in_width,
color = {},
+ condition = conditions.hide_in_width,
},
encoding = {
"o:encoding",
upper = true,
- condition = conditions.hide_in_width,
color = { fg = colors.fg, bg = colors.bg },
+ condition = conditions.hide_in_width,
},
filetype = { "filetype", condition = conditions.hide_in_width, color = {} },
scrollbar = {
@@ -172,9 +181,7 @@ return {
end,
left_padding = 0,
right_padding = 0,
- condition = function()
- return true
- end,
+ condition = nil,
color = { fg = colors.yellow, bg = colors.bg },
},
}
diff --git a/.config/nvim/lua/core/lualine/conditions.lua b/.config/nvim/lua/core/lualine/conditions.lua
index 2d2d81e..3ee4fbb 100644
--- a/.config/nvim/lua/core/lualine/conditions.lua
+++ b/.config/nvim/lua/core/lualine/conditions.lua
@@ -7,11 +7,11 @@ local conditions = {
hide_in_width = function()
return vim.fn.winwidth(0) > window_width_limit
end,
- check_git_workspace = function()
- local filepath = vim.fn.expand "%:p:h"
- local gitdir = vim.fn.finddir(".git", filepath .. ";")
- return gitdir and #gitdir > 0 and #gitdir < #filepath
- end,
+ -- check_git_workspace = function()
+ -- local filepath = vim.fn.expand "%:p:h"
+ -- local gitdir = vim.fn.finddir(".git", filepath .. ";")
+ -- return gitdir and #gitdir > 0 and #gitdir < #filepath
+ -- end,
}
return conditions
diff --git a/.config/nvim/lua/core/lualine/styles.lua b/.config/nvim/lua/core/lualine/styles.lua
index 014ba81..e13e214 100644
--- a/.config/nvim/lua/core/lualine/styles.lua
+++ b/.config/nvim/lua/core/lualine/styles.lua
@@ -14,7 +14,7 @@ styles.clean = {
icons_enabled = true,
component_separators = "",
section_separators = "",
- disabled_filetypes = { "dashboard" },
+ disabled_filetypes = { "dashboard", "NvimTree", "Outline" },
},
sections = {
lualine_a = {
@@ -160,14 +160,13 @@ function M.get_style(style)
local style_keys = vim.tbl_keys(styles)
if not vim.tbl_contains(style_keys, style) then
local Log = require "core.log"
- local logger = Log:get_default()
- logger.error(
+ Log:error(
"Invalid lualine style",
string.format('"%s"', style),
"options are: ",
string.format('"%s"', table.concat(style_keys, '", "'))
)
- logger.info '"lvim" style is applied.'
+ Log:debug '"lvim" style is applied.'
style = "lvim"
end
diff --git a/.config/nvim/lua/core/nvimtree.lua b/.config/nvim/lua/core/nvimtree.lua
index c640583..1e764c7 100644
--- a/.config/nvim/lua/core/nvimtree.lua
+++ b/.config/nvim/lua/core/nvimtree.lua
@@ -15,7 +15,7 @@ function M.config()
tree_width = 30,
},
ignore = { ".git", "node_modules", ".cache" },
- auto_open = 1,
+ auto_open = 0,
auto_close = 1,
quit_on_open = 0,
follow = 1,
@@ -52,7 +52,7 @@ end
function M.setup()
local status_ok, nvim_tree_config = pcall(require, "nvim-tree.config")
if not status_ok then
- Log:get_default().error "Failed to load nvim-tree.config"
+ Log:error("Failed to load nvim-tree.config")
return
end
local g = vim.g
@@ -65,6 +65,9 @@ function M.setup()
if options.builtin.project.active then
vim.g.nvim_tree_update_cwd = 1
vim.g.nvim_tree_respect_buf_cwd = 1
+ vim.g.nvim_tree_disable_netrw = 0
+ vim.g.nvim_tree_hijack_netrw = 0
+ vim.g.netrw_banner = 0
end
local tree_cb = nvim_tree_config.nvim_tree_callback
diff --git a/.config/nvim/lua/core/terminal.lua b/.config/nvim/lua/core/terminal.lua
index 80dc9d0..01b7709 100644
--- a/.config/nvim/lua/core/terminal.lua
+++ b/.config/nvim/lua/core/terminal.lua
@@ -82,7 +82,7 @@ M._exec_toggle = function(exec)
local binary = M._split(exec)[1]
if vim.fn.executable(binary) ~= 1 then
local Log = require "core.log"
- Log:get_default().error("Unable to run executable " .. binary .. ". Please make sure it is installed properly.")
+ Log:error("Unable to run executable " .. binary .. ". Please make sure it is installed properly.")
return
end
local Terminal = require("toggleterm.terminal").Terminal
@@ -122,7 +122,7 @@ M.toggle_log_view = function(name)
local Terminal = require("toggleterm.terminal").Terminal
local log_view = Terminal:new(term_opts)
- -- require("core.log"):get_default().debug("term", vim.inspect(term_opts))
+ -- require("core.log"):debug("term", vim.inspect(term_opts))
log_view:toggle()
end
diff --git a/.config/nvim/lua/core/which-key.lua b/.config/nvim/lua/core/which-key.lua
index 7ea86a8..d4ef1a2 100644
--- a/.config/nvim/lua/core/which-key.lua
+++ b/.config/nvim/lua/core/which-key.lua
@@ -72,32 +72,33 @@ M.config = function()
["n"] = { "<cmd>nohlsearch<CR>", "No Highlight" },
b = {
name = "Buffers",
- j = { "<cmd>BufferPick<cr>", "jump to buffer" },
- f = { "<cmd>Telescope buffers<cr>", "Find buffer" },
- w = { "<cmd>BufferWipeout<cr>", "wipeout buffer" },
+ j = { "<cmd>BufferPick<cr>", "Jump" },
+ f = { "<cmd>Telescope buffers<cr>", "Find" },
+ b = { "<cmd>b#<cr>", "Previous" },
+ w = { "<cmd>BufferWipeout<cr>", "Wipeout" },
e = {
"<cmd>BufferCloseAllButCurrent<cr>",
- "close all but current buffer",
+ "Close all but current",
},
- h = { "<cmd>BufferCloseBuffersLeft<cr>", "close all buffers to the left" },
+ h = { "<cmd>BufferCloseBuffersLeft<cr>", "Close all to the left" },
l = {
"<cmd>BufferCloseBuffersRight<cr>",
- "close all BufferLines to the right",
+ "Close all to the right",
},
D = {
"<cmd>BufferOrderByDirectory<cr>",
- "sort BufferLines automatically by directory",
+ "Sort by directory",
},
L = {
"<cmd>BufferOrderByLanguage<cr>",
- "sort BufferLines automatically by language",
+ "Sort by language",
},
},
p = {
name = "Packer",
c = { "<cmd>PackerCompile<cr>", "Compile" },
i = { "<cmd>PackerInstall<cr>", "Install" },
- r = { "<cmd>lua require('utils').reload_lv_config()<cr>", "Reload" },
+ r = { "<cmd>lua require('utils').reload_config()<cr>", "Reload" },
s = { "<cmd>PackerSync<cr>", "Sync" },
S = { "<cmd>PackerStatus<cr>", "Status" },
u = { "<cmd>PackerUpdate<cr>", "Update" },
@@ -130,6 +131,10 @@ M.config = function()
"<cmd>Telescope git_bcommits<cr>",
"Checkout commit(for current file)",
},
+ d = {
+ "<cmd>Gitsigns diffthis HEAD<cr>",
+ "Git Diff",
+ },
},
l = {
diff --git a/.config/nvim/lua/keymappings.lua b/.config/nvim/lua/keymappings.lua
index f7d91d8..cc6865a 100644
--- a/.config/nvim/lua/keymappings.lua
+++ b/.config/nvim/lua/keymappings.lua
@@ -83,8 +83,14 @@ function M.config()
["<A-Right>"] = "<C-\\><C-N><C-w>l",
-- 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 } },
+ ["<C-j>"] = {
+ 'pumvisible() ? "\\<C-n>" : "\\<C-j>"',
+ { expr = true, noremap = true },
+ },
+ ["<C-k>"] = {
+ 'pumvisible() ? "\\<C-p>" : "\\<C-k>"',
+ { expr = true, noremap = true },
+ },
},
---@usage change or add keymappings for normal mode
@@ -149,8 +155,14 @@ function M.config()
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 } },
+ ["<C-j>"] = {
+ 'pumvisible() ? "\\<C-n>" : "\\<C-j>"',
+ { expr = true, noremap = true },
+ },
+ ["<C-k>"] = {
+ 'pumvisible() ? "\\<C-p>" : "\\<C-k>"',
+ { expr = true, noremap = true },
+ },
},
}
@@ -159,9 +171,7 @@ function M.config()
options.keys.normal_mode["<A-Down>"] = options.keys.normal_mode["<C-Down>"]
options.keys.normal_mode["<A-Left>"] = options.keys.normal_mode["<C-Left>"]
options.keys.normal_mode["<A-Right>"] = options.keys.normal_mode["<C-Right>"]
- if Log:get_default() then
- Log:get_default().info "Activated mac keymappings"
- end
+ Log:debug "Activated mac keymappings"
end
end
diff --git a/.config/nvim/lua/lsp/handlers.lua b/.config/nvim/lua/lsp/handlers.lua
index e273261..d19cb33 100644
--- a/.config/nvim/lua/lsp/handlers.lua
+++ b/.config/nvim/lua/lsp/handlers.lua
@@ -3,69 +3,108 @@
local M = {}
function M.setup()
- vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
- vim.lsp.diagnostic.on_publish_diagnostics,
- {
+ vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
+ virtual_text = options.lsp.diagnostics.virtual_text,
+ signs = options.lsp.diagnostics.signs.active,
+ underline = options.lsp.document_highlight,
+ })
+
+ vim.lsp.handlers["textDocument/publishDiagnostics"] = function(_, _, params, client_id, _)
+ local config = { -- your config
virtual_text = options.lsp.diagnostics.virtual_text,
- signs = options.lsp.diagnostics.signs.active,
- underline = options.lsp.document_highlight,
+ signs = options.lsp.diagnostics.signs,
+ underline = options.lsp.diagnostics.underline,
+ update_in_insert = options.lsp.diagnostics.update_in_insert,
+ severity_sort = options.lsp.diagnostics.severity_sort,
}
- )
+ local uri = params.uri
+ local bufnr = vim.uri_to_bufnr(uri)
- vim.lsp.handlers["textDocument/publishDiagnostics"] =
- function(_, _, params, client_id, _)
- local config = { -- your config
- virtual_text = options.lsp.diagnostics.virtual_text,
- signs = options.lsp.diagnostics.signs,
- underline = options.lsp.diagnostics.underline,
- update_in_insert = options.lsp.diagnostics.update_in_insert,
- severity_sort = options.lsp.diagnostics.severity_sort,
- }
- local uri = params.uri
- local bufnr = vim.uri_to_bufnr(uri)
+ if not bufnr then
+ return
+ end
- if not bufnr then
- return
- end
+ local diagnostics = params.diagnostics
- local diagnostics = params.diagnostics
+ vim.lsp.diagnostic.save(diagnostics, bufnr, client_id)
- for i, v in ipairs(diagnostics) do
- local source = v.source
- if source then
- if string.find(source, "/") then
- source = string.sub(v.source, string.find(v.source, "([%w-_]+)$"))
- end
- diagnostics[i].message = string.format("%s: %s", source, v.message)
- else
- diagnostics[i].message = string.format("%s", v.message)
- end
+ if not vim.api.nvim_buf_is_loaded(bufnr) then
+ return
+ end
+ vim.lsp.diagnostic.display(diagnostics, bufnr, client_id, config)
+ end
- if vim.tbl_contains(vim.tbl_keys(v), "code") then
- diagnostics[i].message = diagnostics[i].message
- .. string.format(" [%s]", v.code)
- end
- end
+ vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
+ border = options.lsp.popup_border,
+ })
- vim.lsp.diagnostic.save(diagnostics, bufnr, client_id)
+ vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
+ border = options.lsp.popup_border,
+ })
+end
+
+function M.show_line_diagnostics()
+ local diagnostics = vim.lsp.diagnostic.get_line_diagnostics()
+ local diags = vim.deepcopy(diagnostics)
+ local height = #diagnostics
+ local width = 0
+ local opts = {}
+ local close_events = { "CursorMoved", "CursorMovedI", "BufHidden", "InsertCharPre" }
+ local diagnostic_severities = {
+ "Error",
+ "Warning",
+ "Information",
+ "Hint",
+ }
+ if height == 0 then
+ return
+ end
+ local bufnr = vim.api.nvim_create_buf(false, true)
- if not vim.api.nvim_buf_is_loaded(bufnr) then
- return
+ for i, diagnostic in ipairs(diagnostics) do
+ local source = diagnostic.source
+ if source then
+ if string.find(source, "/") then
+ source = string.sub(diagnostic.source, string.find(diagnostic.source, "([%w-_]+)$"))
end
+ diags[i].message = string.format("%s: %s", source, diagnostic.message)
+ else
+ diags[i].message = string.format("%s", diagnostic.message)
+ end
- vim.lsp.diagnostic.display(diagnostics, bufnr, client_id, config)
+ if diagnostic.code then
+ diags[i].message = string.format("%s [%s]", diags[i].message, diagnostic.code)
+ end
+ if diags[i].message:len() > width then
+ width = string.len(diags[i].message)
end
+ end
- vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
- border = options.lsp.popup_border,
- })
+ opts = vim.lsp.util.make_floating_popup_options(width, height, opts)
+ opts["style"] = "minimal"
+ opts["border"] = "rounded"
- vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
- vim.lsp.handlers.signature_help,
- {
- border = options.lsp.popup_border,
- }
+ vim.api.nvim_buf_set_option(bufnr, "bufhidden", "wipe")
+ local winnr = vim.api.nvim_open_win(bufnr, false, opts)
+ vim.api.nvim_win_set_option(winnr, "winblend", 0)
+ vim.api.nvim_buf_set_var(bufnr, "lsp_floating_window", winnr)
+ for i, diag in ipairs(diags) do
+ local message = diag.message:gsub("[\n\r]", " ")
+ vim.api.nvim_buf_set_lines(bufnr, i - 1, i - 1, 0, { message })
+ vim.api.nvim_buf_add_highlight(
+ bufnr,
+ -1,
+ "LspDiagnosticsFloating" .. diagnostic_severities[diag.severity],
+ i - 1,
+ 0,
+ diag.message:len()
+ )
+ end
+
+ vim.api.nvim_command(
+ "autocmd QuitPre <buffer> ++nested ++once lua pcall(vim.api.nvim_win_close, " .. winnr .. ", true)"
)
+ vim.lsp.util.close_preview_autocmd(close_events, winnr)
end
return M
diff --git a/.config/nvim/lua/lsp/init.lua b/.config/nvim/lua/lsp/init.lua
index b693dec..f0f7b45 100644
--- a/.config/nvim/lua/lsp/init.lua
+++ b/.config/nvim/lua/lsp/init.lua
@@ -19,9 +19,9 @@ local function lsp_highlight_document(client)
if client.resolved_capabilities.document_highlight then
vim.api.nvim_exec(
[[
- hi LspReferenceRead cterm=bold ctermbg=red guibg=#464646
- hi LspReferenceText cterm=bold ctermbg=red guibg=#464646
- hi LspReferenceWrite cterm=bold ctermbg=red guibg=#464646
+ hi LspReferenceRead cterm=bold ctermbg=red guibg=#353d46
+ hi LspReferenceText cterm=bold ctermbg=red guibg=#353d46
+ hi LspReferenceWrite cterm=bold ctermbg=red guibg=#353d46
augroup lsp_document_highlight
autocmd! * <buffer>
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
@@ -44,11 +44,11 @@ local function add_lsp_buffer_keybindings(bufnr)
["gd"] = { "<cmd>lua vim.lsp.buf.definition()<CR>", "Goto Definition" },
["gD"] = { "<cmd>lua vim.lsp.buf.declaration()<CR>", "Goto declaration" },
["gr"] = { "<cmd>lua vim.lsp.buf.references()<CR>", "Goto references" },
- ["gi"] = { "<cmd>lua vim.lsp.buf.implementation()<CR>", "Goto implementation" },
+ ["gI"] = { "<cmd>lua vim.lsp.buf.implementation()<CR>", "Goto Implementation" },
["gs"] = { "<cmd>lua vim.lsp.buf.signature_help()<CR>", "show signature help" },
["gp"] = { "<cmd>lua require'lsp.peek'.Peek('definition')<CR>", "Peek definition" },
["gl"] = {
- "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics({ show_header = false, border = 'single' })<CR>",
+ "<cmd>lua require'lsp.handlers'.show_line_diagnostics()<CR>",
"Show line diagnostics",
},
}
@@ -99,14 +99,14 @@ end
function M.common_on_init(client, bufnr)
if options.lsp.on_init_callback then
options.lsp.on_init_callback(client, bufnr)
- Log:get_default().info "Called lsp.on_init_callback"
+ Log:debug "Called lsp.on_init_callback"
return
end
local formatters = options.lang[vim.bo.filetype].formatters
if not vim.tbl_isempty(formatters) and formatters[1]["exe"] ~= nil and formatters[1].exe ~= "" then
client.resolved_capabilities.document_formatting = false
- Log:get_default().info(
+ Log:debug(
string.format("Overriding language server [%s] with format provider [%s]", client.name, formatters[1].exe)
)
end
@@ -115,7 +115,7 @@ end
function M.common_on_attach(client, bufnr)
if options.lsp.on_attach_callback then
options.lsp.on_attach_callback(client, bufnr)
- Log:get_default().info "Called lsp.on_init_callback"
+ Log:debug "Called lsp.on_init_callback"
end
lsp_highlight_document(client)
add_lsp_buffer_keybindings(bufnr)
@@ -125,7 +125,7 @@ end
function M.setup(lang)
local lsp_utils = require "lsp.utils"
local lsp = options.lang[lang].lsp
- if lsp_utils.is_client_active(lsp.provider) then
+ if (lsp.active ~= nil and not lsp.active) or lsp_utils.is_client_active(lsp.provider) then
return
end
diff --git a/.config/nvim/lua/lsp/null-ls/formatters.lua b/.config/nvim/lua/lsp/null-ls/formatters.lua
index cf62615..651d6f1 100644
--- a/.config/nvim/lua/lsp/null-ls/formatters.lua
+++ b/.config/nvim/lua/lsp/null-ls/formatters.lua
@@ -3,7 +3,7 @@ local formatters_by_ft = {}
local null_ls = require "null-ls"
local services = require "lsp.null-ls.services"
-local logger = require("core.log"):get_default()
+local Log = require("core.log")
local function list_names(formatters, option)
option = option or {}
@@ -45,15 +45,15 @@ function M.list_configured(formatter_configs)
local formatter = null_ls.builtins.formatting[fmt_config.exe]
if not formatter then
- logger.error("Not a valid formatter:", fmt_config.exe)
+ Log:error("Not a valid formatter:" .. fmt_config.exe)
errors[fmt_config.exe] = {} -- Add data here when necessary
else
local formatter_cmd = services.find_command(formatter._opts.command)
if not formatter_cmd then
- logger.warn("Not found:", formatter._opts.command)
+ Log:warn("Not found:" .. formatter._opts.command)
errors[fmt_config.exe] = {} -- Add data here when necessary
else
- logger.info("Using formatter:", formatter_cmd)
+ Log:debug("Using formatter:" .. formatter_cmd)
formatters[fmt_config.exe] = formatter.with {
command = formatter_cmd,
extra_args = fmt_config.args,
diff --git a/.config/nvim/lua/lsp/null-ls/init.lua b/.config/nvim/lua/lsp/null-ls/init.lua
index f2b1042..d12b40a 100644
--- a/.config/nvim/lua/lsp/null-ls/init.lua
+++ b/.config/nvim/lua/lsp/null-ls/init.lua
@@ -30,7 +30,7 @@ function M.setup(filetype, option)
local ok, _ = pcall(require, "null-ls")
if not ok then
- require("core.log"):get_default().error "Missing null-ls dependency"
+ require("core.log"):error "Missing null-ls dependency"
return
end
diff --git a/.config/nvim/lua/lsp/null-ls/linters.lua b/.config/nvim/lua/lsp/null-ls/linters.lua
index a4eaa89..0f6cbc1 100644
--- a/.config/nvim/lua/lsp/null-ls/linters.lua
+++ b/.config/nvim/lua/lsp/null-ls/linters.lua
@@ -3,7 +3,7 @@ local linters_by_ft = {}
local null_ls = require "null-ls"
local services = require "lsp.null-ls.services"
-local logger = require("core.log"):get_default()
+local Log = require("core.log")
local function list_names(linters, option)
option = option or {}
@@ -45,15 +45,15 @@ function M.list_configured(linter_configs)
local linter = null_ls.builtins.diagnostics[lnt_config.exe]
if not linter then
- logger.error("Not a valid linter:", lnt_config.exe)
+ Log:error("Not a valid linter: " .. lnt_config.exe)
errors[lnt_config.exe] = {} -- Add data here when necessary
else
local linter_cmd = services.find_command(linter._opts.command)
if not linter_cmd then
- logger.warn("Not found:", linter._opts.command)
+ Log:warn("Not found: " .. linter._opts.command)
errors[lnt_config.exe] = {} -- Add data here when necessary
else
- logger.info("Using linter:", linter_cmd)
+ Log:debug("Using linter: " .. linter_cmd)
linters[lnt_config.exe] = linter.with {
command = linter_cmd,
extra_args = lnt_config.args,
diff --git a/.config/nvim/lua/lsp/peek.lua b/.config/nvim/lua/lsp/peek.lua
index e4f4e1e..dbc6741 100644
--- a/.config/nvim/lua/lsp/peek.lua
+++ b/.config/nvim/lua/lsp/peek.lua
@@ -12,8 +12,7 @@ local function create_floating_file(location, opts)
-- Set some defaults
opts = opts or {}
- local close_events = opts.close_events
- or { "CursorMoved", "CursorMovedI", "BufHidden", "InsertCharPre" }
+ local close_events = opts.close_events or { "CursorMoved", "CursorMovedI", "BufHidden", "InsertCharPre" }
-- location may be LocationLink or Location
local uri = location.targetUri or location.uri
@@ -30,10 +29,7 @@ local function create_floating_file(location, opts)
local contents = vim.api.nvim_buf_get_lines(
bufnr,
range.start.line,
- math.min(
- range["end"].line + 1 + (opts.context or 10),
- range.start.line + (opts.max_height or 15)
- ), -- Don't let the window be more that 15 lines long(height)
+ math.min(range["end"].line + 1 + (opts.context or 10), range.start.line + (opts.max_height or 15)), -- Don't let the window be more that 15 lines long(height)
false
)
local width, height = vim.lsp.util._make_floating_popup_size(contents, opts)
@@ -46,13 +42,12 @@ local function create_floating_file(location, opts)
local winnr = vim.api.nvim_open_win(bufnr, false, opts)
vim.api.nvim_win_set_option(winnr, "winblend", 0)
+ vim.api.nvim_win_set_cursor(winnr, { range.start.line + 1, range.start.character })
vim.api.nvim_buf_set_var(bufnr, "lsp_floating_window", winnr)
-- Set some autocmds to close the window
vim.api.nvim_command(
- "autocmd QuitPre <buffer> ++nested ++once lua pcall(vim.api.nvim_win_close, "
- .. winnr
- .. ", true)"
+ "autocmd QuitPre <buffer> ++nested ++once lua pcall(vim.api.nvim_win_close, " .. winnr .. ", true)"
)
vim.lsp.util.close_preview_autocmd(close_events, winnr)
@@ -134,18 +129,10 @@ function M.Peek(what)
else
-- Make a new request and then create the new window in the callback
local params = vim.lsp.util.make_position_params()
- local success, _ = pcall(
- vim.lsp.buf_request,
- 0,
- "textDocument/" .. what,
- params,
- preview_location_callback
- )
+ local success, _ = pcall(vim.lsp.buf_request, 0, "textDocument/" .. what, params, preview_location_callback)
if not success then
print(
- 'peek: Error calling LSP method "textDocument/'
- .. what
- .. '". The current language lsp might not support it.'
+ 'peek: Error calling LSP method "textDocument/' .. what .. '". The current language lsp might not support it.'
)
end
end
diff --git a/.config/nvim/lua/plugin-loader.lua b/.config/nvim/lua/plugin-loader.lua
index cbe849b..fed4995 100644
--- a/.config/nvim/lua/plugin-loader.lua
+++ b/.config/nvim/lua/plugin-loader.lua
@@ -1,13 +1,15 @@
local plugin_loader = {}
function plugin_loader:init()
- local execute = vim.api.nvim_command
- local fn = vim.fn
-
local install_path = "~/.local/share/nvim/site/pack/packer/start/packer.nvim"
- if fn.empty(fn.glob(install_path)) > 0 then
- execute("!git clone https://github.com/wbthomason/packer.nvim " .. install_path)
- execute "packadd packer.nvim"
+ if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
+ vim.fn.system {
+ "git",
+ "clone",
+ "https://github.com/wbthomason/packer.nvim",
+ install_path,
+ }
+ vim.cmd "packadd packer.nvim"
end
local packer_ok, packer = pcall(require, "packer")
diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua
index 6eb71be..5b342f0 100644
--- a/.config/nvim/lua/plugins.lua
+++ b/.config/nvim/lua/plugins.lua
@@ -4,6 +4,7 @@ return {
{ "neovim/nvim-lspconfig" },
{ "tamago324/nlsp-settings.nvim" },
{ "jose-elias-alvarez/null-ls.nvim" },
+ { "antoinemadec/FixCursorHold.nvim" }, -- Needed while issue https://github.com/neovim/neovim/issues/12587 is still open
{
"kabouzeid/nvim-lspinstall",
event = "VimEnter",
@@ -102,7 +103,7 @@ return {
"terrortylor/nvim-comment",
event = "BufRead",
config = function()
- require("nvim_comment").setup()
+ require("core.comment").setup()
end,
disable = not options.builtin.comment.active,
},
@@ -169,7 +170,7 @@ return {
-- Terminal
{
- "akinsho/nvim-toggleterm.lua",
+ "akinsho/toggleterm.nvim",
event = "BufWinEnter",
config = function()
require("core.terminal").setup()
diff --git a/.config/nvim/lua/utils/ft.lua b/.config/nvim/lua/utils/ft.lua
index fcebd1e..e9852e6 100644
--- a/.config/nvim/lua/utils/ft.lua
+++ b/.config/nvim/lua/utils/ft.lua
@@ -1,3 +1,5 @@
+-- Here be dragons
+-- Opening files with telescope will not start LSP without this
local ft = {}
ft.find_lua_ftplugins = function(filetype)
diff --git a/.config/nvim/lua/utils/init.lua b/.config/nvim/lua/utils/init.lua
index 65bc6f5..1695d19 100644
--- a/.config/nvim/lua/utils/init.lua
+++ b/.config/nvim/lua/utils/init.lua
@@ -70,9 +70,7 @@ function utils.toggle_autoformat()
},
},
}
- if Log:get_default() then
- Log:get_default().info "Format on save active"
- end
+ Log:debug "Format on save active"
end
if not options.format_on_save then
@@ -81,9 +79,7 @@ function utils.toggle_autoformat()
:autocmd! autoformat
endif
]]
- if Log:get_default() then
- Log:get_default().info "Format on save off"
- end
+ Log:debug "Format on save off"
end
end
@@ -104,7 +100,7 @@ function utils.reload_config()
-- vim.cmd ":PackerClean"
local null_ls = require "lsp.null-ls"
null_ls.setup(vim.bo.filetype, { force_reload = true })
- Log:get_default().info "Reloaded configuration"
+ Log:info "Reloaded configuration"
end
function utils.unrequire(m)
@@ -132,5 +128,3 @@ function utils.is_file(filename)
end
return utils
-
--- TODO: find a new home for these autocommands