Initial commit
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
local utils = require('utils')
|
||||
|
||||
-- Install lazy.nvim
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
if utils.os_name == "Linux" then
|
||||
utils.assert_any_available({ 'curl', 'wget' })
|
||||
utils.assert_available('unzip')
|
||||
utils.assert_available('gzip')
|
||||
elseif utils.os_name == "Windows_NT" then
|
||||
utils.assert_any_available({ 'pwsh', 'powershell' })
|
||||
utils.assert_any_available({ '7z', 'peazip', 'arc', 'wzzip', 'rar' })
|
||||
else
|
||||
error('OS not supported: ' .. utils.os_name)
|
||||
end
|
||||
|
||||
utils.assert_available('git')
|
||||
utils.assert_available('tar')
|
||||
|
||||
vim.fn.system({
|
||||
"git",
|
||||
"clone",
|
||||
"--filter=blob:none",
|
||||
"https://github.com/folke/lazy.nvim.git",
|
||||
"--branch=stable", -- latest stable release
|
||||
lazypath,
|
||||
})
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
@@ -0,0 +1,253 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
require("aerial").setup({
|
||||
-- Priority list of preferred backends for aerial.
|
||||
-- This can be a filetype map (see :help aerial-filetype-map)
|
||||
backends = { "treesitter", "lsp", "markdown" },
|
||||
|
||||
layout = {
|
||||
-- These control the width of the aerial window.
|
||||
-- They can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
|
||||
-- min_width and max_width can be a list of mixed types.
|
||||
-- max_width = {40, 0.2} means "the lesser of 40 columns or 20% of total"
|
||||
max_width = { 40, 0.2 },
|
||||
width = nil,
|
||||
min_width = 40,
|
||||
|
||||
-- Determines the default direction to open the aerial window. The 'prefer'
|
||||
-- options will open the window in the other direction *if* there is a
|
||||
-- different buffer in the way of the preferred direction
|
||||
-- Enum: prefer_right, prefer_left, right, left, float
|
||||
default_direction = "left",
|
||||
|
||||
-- Determines where the aerial window will be opened
|
||||
-- edge - open aerial at the far right/left of the editor
|
||||
-- window - open aerial to the right/left of the current window
|
||||
placement = "edge",
|
||||
},
|
||||
|
||||
-- Determines how the aerial window decides which buffer to display symbols for
|
||||
-- window - aerial window will display symbols for the buffer in the window from which it was opened
|
||||
-- global - aerial window will display symbols for the current window
|
||||
attach_mode = "window",
|
||||
|
||||
-- List of enum values that configure when to auto-close the aerial window
|
||||
-- unfocus - close aerial when you leave the original source window
|
||||
-- switch_buffer - close aerial when you change buffers in the source window
|
||||
-- unsupported - close aerial when attaching to a buffer that has no symbol source
|
||||
close_automatic_events = {},
|
||||
|
||||
-- Set to false to remove the default keybindings for the aerial buffer
|
||||
default_bindings = true,
|
||||
|
||||
-- Disable aerial on files with this many lines
|
||||
disable_max_lines = 10000,
|
||||
|
||||
-- Disable aerial on files this size or larger (in bytes)
|
||||
disable_max_size = 10000000, -- Default 2MB
|
||||
|
||||
-- A list of all symbols to display. Set to false to display all symbols.
|
||||
-- This can be a filetype map (see :help aerial-filetype-map)
|
||||
-- To see all available values, see :help SymbolKind
|
||||
filter_kind = {
|
||||
"Class",
|
||||
"Constructor",
|
||||
"Enum",
|
||||
"Function",
|
||||
"Interface",
|
||||
"Module",
|
||||
"Method",
|
||||
"Struct",
|
||||
},
|
||||
|
||||
-- Determines line highlighting mode when multiple splits are visible.
|
||||
-- split_width Each open window will have its cursor location marked in the
|
||||
-- aerial buffer. Each line will only be partially highlighted
|
||||
-- to indicate which window is at that location.
|
||||
-- full_width Each open window will have its cursor location marked as a
|
||||
-- full-width highlight in the aerial buffer.
|
||||
-- last Only the most-recently focused window will have its location
|
||||
-- marked in the aerial buffer.
|
||||
-- none Do not show the cursor locations in the aerial window.
|
||||
highlight_mode = "split_width",
|
||||
|
||||
-- Highlight the closest symbol if the cursor is not exactly on one.
|
||||
highlight_closest = true,
|
||||
|
||||
-- Highlight the symbol in the source buffer when cursor is in the aerial win
|
||||
highlight_on_hover = true,
|
||||
|
||||
-- When jumping to a symbol, highlight the line for this many ms.
|
||||
-- Set to false to disable
|
||||
highlight_on_jump = 300,
|
||||
|
||||
-- Define symbol icons. You can also specify "<Symbol>Collapsed" to change the
|
||||
-- icon when the tree is collapsed at that symbol, or "Collapsed" to specify a
|
||||
-- default collapsed icon. The default icon set is determined by the
|
||||
-- "nerd_font" option below.
|
||||
-- If you have lspkind-nvim installed, it will be the default icon set.
|
||||
-- This can be a filetype map (see :help aerial-filetype-map)
|
||||
icons = {},
|
||||
|
||||
-- Control which windows and buffers aerial should ignore.
|
||||
-- If attach_mode is "global", focusing an ignored window/buffer will
|
||||
-- not cause the aerial window to update.
|
||||
-- If open_automatic is true, focusing an ignored window/buffer will not
|
||||
-- cause an aerial window to open.
|
||||
-- If open_automatic is a function, ignore rules have no effect on aerial
|
||||
-- window opening behavior; it's entirely handled by the open_automatic
|
||||
-- function.
|
||||
ignore = {
|
||||
-- Ignore unlisted buffers. See :help buflisted
|
||||
unlisted_buffers = true,
|
||||
|
||||
-- List of filetypes to ignore.
|
||||
filetypes = {},
|
||||
|
||||
-- Ignored buftypes.
|
||||
-- Can be one of the following:
|
||||
-- false or nil - No buftypes are ignored.
|
||||
-- "special" - All buffers other than normal buffers are ignored.
|
||||
-- table - A list of buftypes to ignore. See :help buftype for the
|
||||
-- possible values.
|
||||
-- function - A function that returns true if the buffer should be
|
||||
-- ignored or false if it should not be ignored.
|
||||
-- Takes two arguments, `bufnr` and `buftype`.
|
||||
buftypes = "special",
|
||||
|
||||
-- Ignored wintypes.
|
||||
-- Can be one of the following:
|
||||
-- false or nil - No wintypes are ignored.
|
||||
-- "special" - All windows other than normal windows are ignored.
|
||||
-- table - A list of wintypes to ignore. See :help win_gettype() for the
|
||||
-- possible values.
|
||||
-- function - A function that returns true if the window should be
|
||||
-- ignored or false if it should not be ignored.
|
||||
-- Takes two arguments, `winid` and `wintype`.
|
||||
wintypes = "special",
|
||||
},
|
||||
|
||||
-- When you fold code with za, zo, or zc, update the aerial tree as well.
|
||||
-- Only works when manage_folds = true
|
||||
link_folds_to_tree = true,
|
||||
|
||||
-- Fold code when you open/collapse symbols in the tree.
|
||||
-- Only works when manage_folds = true
|
||||
link_tree_to_folds = true,
|
||||
|
||||
-- Use symbol tree for folding. Set to true or false to enable/disable
|
||||
-- 'auto' will manage folds if your previous foldmethod was 'manual'
|
||||
manage_folds = false,
|
||||
|
||||
-- Set default symbol icns to use patched font icons (see https://www.nerdfonts.com/)
|
||||
-- "auto" will set it to true if nvim-web-devicons or lspkind-nvim is installed.
|
||||
nerd_font = "auto",
|
||||
|
||||
-- Call this function when aerial attaches to a buffer.
|
||||
-- Useful for setting keymaps. Takes a single `bufnr` argument.
|
||||
on_attach = function(bufnr)
|
||||
-- Toggle the aerial window with <leader>a
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>at', '<cmd>AerialToggle!<CR>', {})
|
||||
-- Jump forwards/backwards with '{' and '}'
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '{', '<cmd>AerialPrev<CR>', {})
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '}', '<cmd>AerialNext<CR>', {})
|
||||
-- Jump up the tree with '[[' or ']]'
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '[[', '<cmd>AerialPrevUp<CR>', {})
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', ']]', '<cmd>AerialNextUp<CR>', {})
|
||||
end,
|
||||
|
||||
-- Call this function when aerial first sets symbols on a buffer.
|
||||
-- Takes a single `bufnr` argument.
|
||||
on_first_symbols = nil,
|
||||
|
||||
-- Automatically open aerial when entering supported buffers.
|
||||
-- This can be a function (see :help aerial-open-automatic)
|
||||
open_automatic = false,
|
||||
|
||||
-- Run this command after jumping to a symbol (false will disable)
|
||||
post_jump_cmd = "normal! zz",
|
||||
|
||||
-- When true, aerial will automatically close after jumping to a symbol
|
||||
close_on_select = false,
|
||||
|
||||
-- Show box drawing characters for the tree hierarchy
|
||||
show_guides = true,
|
||||
|
||||
-- The autocmds that trigger symbols update (not used for LSP backend)
|
||||
update_events = "TextChanged,InsertLeave",
|
||||
|
||||
-- Customize the characters used when show_guides = true
|
||||
guides = {
|
||||
-- When the child item has a sibling below it
|
||||
mid_item = "├─",
|
||||
-- When the child item is the last in the list
|
||||
last_item = "└─",
|
||||
-- When there are nested child guides to the right
|
||||
nested_top = "│ ",
|
||||
-- Raw indentation
|
||||
whitespace = " ",
|
||||
},
|
||||
|
||||
-- Options for opening aerial in a floating win
|
||||
float = {
|
||||
-- Controls border appearance. Passed to nvim_open_win
|
||||
border = "rounded",
|
||||
|
||||
-- Determines location of floating window
|
||||
-- cursor - Opens float on top of the cursor
|
||||
-- editor - Opens float centered in the editor
|
||||
-- win - Opens float centered in the window
|
||||
relative = "cursor",
|
||||
|
||||
-- These control the height of the floating window.
|
||||
-- They can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
|
||||
-- min_height and max_height can be a list of mixed types.
|
||||
-- min_height = {8, 0.1} means "the greater of 8 rows or 10% of total"
|
||||
max_height = 0.9,
|
||||
height = nil,
|
||||
min_height = { 8, 0.1 },
|
||||
|
||||
override = function(conf, source_winid)
|
||||
-- This is the config that will be passed to nvim_open_win.
|
||||
-- Change values here to customize the layout
|
||||
return conf
|
||||
end,
|
||||
},
|
||||
|
||||
lsp = {
|
||||
-- Fetch document symbols when LSP diagnostics update.
|
||||
-- If false, will update on buffer changes.
|
||||
diagnostics_trigger_update = true,
|
||||
|
||||
-- Set to false to not update the symbols when there are LSP errors
|
||||
update_when_errors = true,
|
||||
|
||||
-- How long to wait (in ms) after a buffer change before updating
|
||||
-- Only used when diagnostics_trigger_update = false
|
||||
update_delay = 300,
|
||||
},
|
||||
|
||||
treesitter = {
|
||||
-- How long to wait (in ms) after a buffer change before updating
|
||||
update_delay = 300,
|
||||
},
|
||||
|
||||
markdown = {
|
||||
-- How long to wait (in ms) after a buffer change before updating
|
||||
update_delay = 300,
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,215 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
local utils = require 'utils'
|
||||
|
||||
local hl_CustomHeader
|
||||
local head_cache
|
||||
--- @param trunc_width number trunctates component when screen width is less then trunc_width
|
||||
--- @param trunc_len number truncates component to trunc_len number of chars
|
||||
--- @param hide_width number hides component when window width is smaller then hide_width
|
||||
--- @param no_ellipsis boolean whether to disable adding '...' at end after truncation
|
||||
--- return function that can format the component accordingly
|
||||
local function trunc(trunc_width, trunc_len, hide_width, no_ellipsis)
|
||||
return function(str)
|
||||
local win_width = vim.fn.winwidth(0)
|
||||
if hide_width and win_width < hide_width then
|
||||
return ''
|
||||
elseif trunc_width and trunc_len and win_width < trunc_width and #str >
|
||||
trunc_len then
|
||||
return str:sub(1, trunc_len) .. (no_ellipsis and '' or '...')
|
||||
end
|
||||
return str
|
||||
end
|
||||
end
|
||||
|
||||
--- @param trunc_len number truncates component to trunc_len number of chars
|
||||
--- @param no_ellipsis boolean whether to disable adding '...' at start before truncation
|
||||
--- return function that can format the component accordingly
|
||||
local function l_trunc(trunc_len, no_ellipsis)
|
||||
return function(str)
|
||||
if #str > trunc_len then
|
||||
if no_ellipsis then
|
||||
return str:sub(#str - trunc_len)
|
||||
else
|
||||
return '...' .. str:sub(#str - trunc_len + 3)
|
||||
end
|
||||
else
|
||||
return str
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- @param trunc_len number truncates component to trunc_len number of chars
|
||||
--- @param no_ellipsis boolean whether to disable adding '...' at start before truncation
|
||||
--- return function that can format the component accordingly
|
||||
local function r_trunc(trunc_len, no_ellipsis)
|
||||
return function(str)
|
||||
if #str > trunc_len then
|
||||
if no_ellipsis then
|
||||
return str:sub(1, trunc_len)
|
||||
elseif #str < trunc_len then
|
||||
return str
|
||||
else
|
||||
return str:sub(1, trunc_len - 3) ..
|
||||
(no_ellipsis and '' or '...')
|
||||
end
|
||||
end
|
||||
return str
|
||||
end
|
||||
end
|
||||
|
||||
local function short_path(len)
|
||||
return function(str)
|
||||
if #str > len then return vim.fn.pathshorten(str, 1) end
|
||||
return str
|
||||
end
|
||||
end
|
||||
|
||||
local function header()
|
||||
if hl_CustomHeader == nil then
|
||||
local header_hl = require('utils').get_hl('NvimTreeNormal')
|
||||
if header_hl ~= nil then
|
||||
hl_CustomHeader = 'gui=bold guifg=' .. header_hl.foreground ..
|
||||
' guibg=' .. header_hl.background
|
||||
vim.api.nvim_command('hi CustomHeader ' .. hl_CustomHeader)
|
||||
end
|
||||
end
|
||||
-- local header = short_path(40)(vim.fn.getcwd())
|
||||
-- NOTE: Decided not to use this. Probably doesn't work.
|
||||
local gitdir = vim.fn.FugitiveExtractGitDir(vim.fn.getcwd())
|
||||
local text = ''
|
||||
if gitdir == '' then
|
||||
text = vim.fn.fnamemodify(vim.fn.getcwd(), ':~')
|
||||
else
|
||||
text = vim.fn.fnamemodify(gitdir, ':~:h')
|
||||
-- text = vim.fn.fnamemodify(vim.fn.FugitiveWorkTree(), ':~')
|
||||
-- local branch = r_trunc(15, false)(vim.fn.FugitiveHead())
|
||||
local head = vim.fn.FugitiveHead(8, gitdir)
|
||||
if head == '' then
|
||||
if head_cache[gitdir] ~= nil then
|
||||
head = head_cache[gitdir]
|
||||
else
|
||||
local f = io.open(gitdir, 'r')
|
||||
if f then
|
||||
io.input(f)
|
||||
local line = io.read('*l')
|
||||
local head = line:gsub(
|
||||
'ref: /refs/(heads/|remotes/|tags/)', ''
|
||||
)
|
||||
head_cache[gitdir] = head
|
||||
end
|
||||
end
|
||||
end
|
||||
if head ~= '' then text = text .. ' ' .. head end
|
||||
end
|
||||
|
||||
-- return l_trunc(40-2, false)(short_path(40-2)(text))
|
||||
return l_trunc(40 - 2, false)(text)
|
||||
end
|
||||
|
||||
require('bufferline').setup(
|
||||
{
|
||||
options = {
|
||||
mode = 'buffers',
|
||||
numbers = function(ordinal, id, lower, raise) return '' end,
|
||||
close_command = 'bdelete %d', -- can be a string | function, see "Mouse actions"
|
||||
right_mouse_command = 'bdelete %d', -- can be a string | function, see "Mouse actions"
|
||||
left_mouse_command = 'buffer %d', -- can be a string | function, see "Mouse actions"
|
||||
middle_mouse_command = nil, -- can be a string | function, see "Mouse actions"
|
||||
indicator = {
|
||||
icon = '▎', -- this should be omitted if indicator style is not 'icon'
|
||||
style = 'icon'
|
||||
},
|
||||
buffer_close_icon = '',
|
||||
modified_icon = '●',
|
||||
close_icon = '',
|
||||
left_trunc_marker = '',
|
||||
right_trunc_marker = '',
|
||||
--- name_formatter can be used to change the buffer's label in the bufferline.
|
||||
--- Please note some names can/will break the
|
||||
--- bufferline so use this at your discretion knowing that it has
|
||||
--- some limitations that will *NOT* be fixed.
|
||||
name_formatter = function(buf) -- buf contains:
|
||||
-- name | str | the basename of the active file
|
||||
-- path | str | the full path of the active file
|
||||
-- bufnr (buffer only) | int | the number of the active buffer
|
||||
-- buffers (tabs only) | table(int) | the numbers of the buffers in the tab
|
||||
-- tabnr (tabs only) | int | the "handle" of the tab, can be converted to its ordinal number using: `vim.api.nvim_tabpage_get_number(buf.tabnr)`
|
||||
return buf.name
|
||||
end,
|
||||
max_name_length = 18,
|
||||
max_prefix_length = 15, -- prefix used when a buffer is de-duplicated
|
||||
truncate_names = true,
|
||||
tab_size = 18,
|
||||
diagnostics = 'nvim_lsp',
|
||||
diagnostics_update_in_insert = false,
|
||||
diagnostics_indicator = function(count, _, _, _)
|
||||
return '(' .. count .. ')'
|
||||
end,
|
||||
-- NOTE: this will be called a lot so don't do any heavy processing here
|
||||
custom_filter = function(buf, _)
|
||||
local disabled_ft = { 'NvimTree', 'fugitive' }
|
||||
|
||||
if utils.has_value(disabled_ft, vim.bo[buf].filetype) then
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end,
|
||||
offsets = {
|
||||
{
|
||||
filetype = 'NvimTree',
|
||||
text = 'File Explorer', -- header,
|
||||
text_align = 'center',
|
||||
seperator = true
|
||||
-- padding = 1,
|
||||
-- highlight = "CustomHeader",
|
||||
},
|
||||
{
|
||||
filetype = 'fugitive',
|
||||
text = 'Fugitive', -- header,
|
||||
text_align = 'center',
|
||||
seperator = true
|
||||
-- padding = 1,
|
||||
-- highlight = "CustomHeader",
|
||||
},
|
||||
{
|
||||
filetype = 'aerial',
|
||||
text = 'Aerial', -- header,
|
||||
text_align = 'center',
|
||||
seperator = true
|
||||
-- padding = 1,
|
||||
-- highlight = "CustomHeader",
|
||||
}
|
||||
},
|
||||
color_icons = true, -- whether or not to add the filetype icon highlights
|
||||
show_buffer_icons = true, -- disable filetype icons for buffers
|
||||
show_buffer_close_icons = false,
|
||||
show_buffer_default_icon = true, -- whether or not an unrecognised filetype should show a default icon
|
||||
show_close_icon = false,
|
||||
show_tab_indicators = true,
|
||||
persist_buffer_sort = true, -- whether or not custom sorted buffers should persist
|
||||
-- can also be a table containing 2 custom separators
|
||||
-- [focused and unfocused]. eg: { '|', '|' }
|
||||
separator_style = 'thin', -- | "thick" | "thin" | { 'any', 'any' },
|
||||
enforce_regular_tabs = true,
|
||||
always_show_bufferline = true,
|
||||
hover = { enabled = true, delay = 200, reveal = { 'close' } },
|
||||
sort_by = 'id'
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,76 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
local colors = require("catppuccin.palettes").get_palette() -- fetch colors from g:catppuccin_flavour palette
|
||||
vim.g.catppuccin_flavour = "mocha" -- latte, frappe, macchiato, mocha
|
||||
require("catppuccin").setup({
|
||||
compile_path = vim.fn.stdpath("cache") .. "/catppuccin",
|
||||
transparent_background = false,
|
||||
term_colors = false,
|
||||
dim_inactive = {
|
||||
enabled = false,
|
||||
shade = "dark",
|
||||
percentage = 0.15,
|
||||
},
|
||||
styles = {
|
||||
comments = {},
|
||||
conditionals = {},
|
||||
loops = {},
|
||||
functions = {},
|
||||
keywords = {},
|
||||
strings = {},
|
||||
variables = {},
|
||||
numbers = {},
|
||||
booleans = {},
|
||||
properties = {},
|
||||
types = {},
|
||||
operators = {},
|
||||
},
|
||||
integrations = {
|
||||
cmp = true,
|
||||
gitsigns = true,
|
||||
nvimtree = true,
|
||||
telescope = true,
|
||||
treesitter = true,
|
||||
aerial = true,
|
||||
native_lsp = {
|
||||
enabled = true,
|
||||
virtual_text = {
|
||||
errors = { "italic" },
|
||||
hints = { "italic" },
|
||||
warnings = { "italic" },
|
||||
information = { "italic" },
|
||||
},
|
||||
underlines = {
|
||||
errors = { "underline" },
|
||||
hints = { "underline" },
|
||||
warnings = { "underline" },
|
||||
information = { "underline" },
|
||||
},
|
||||
},
|
||||
-- For more plugins integrations please see https://github.com/catppuccin/nvim#integrations
|
||||
},
|
||||
color_overrides = {},
|
||||
custom_highlights = {
|
||||
-- Comment = { fg = colors.flamingo },
|
||||
-- TSConstBuiltin = { fg = colors.peach, style = {} },
|
||||
-- TSConstant = { fg = colors.sky },
|
||||
-- TSComment = { fg = colors.surface2, style = { "italic" } }
|
||||
['@parameter'] = { style = {} }
|
||||
}
|
||||
})
|
||||
|
||||
vim.cmd("colorscheme catppuccin")
|
||||
@@ -0,0 +1,86 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
require('Comment').setup(
|
||||
{
|
||||
---Add a space b/w comment and the line
|
||||
---@type boolean|fun():boolean
|
||||
padding = true,
|
||||
|
||||
---Whether the cursor should stay at its position
|
||||
---NOTE: This only affects NORMAL mode mappings and doesn't work with dot-repeat
|
||||
---@type boolean
|
||||
sticky = true,
|
||||
|
||||
---Lines to be ignored while comment/uncomment.
|
||||
---Could be a regex string or a function that returns a regex string.
|
||||
---Example: Use '^$' to ignore empty lines
|
||||
---@type string|fun():string
|
||||
ignore = '^$',
|
||||
|
||||
---LHS of toggle mappings in NORMAL + VISUAL mode
|
||||
---@type table
|
||||
toggler = {
|
||||
---Line-comment toggle keymap
|
||||
line = 'gcc',
|
||||
---Block-comment toggle keymap
|
||||
block = 'gbc',
|
||||
},
|
||||
|
||||
---LHS of operator-pending mappings in NORMAL + VISUAL mode
|
||||
---@type table
|
||||
opleader = {
|
||||
---Line-comment keymap
|
||||
line = 'gc',
|
||||
---Block-comment keymap
|
||||
block = 'gb',
|
||||
},
|
||||
|
||||
---LHS of extra mappings
|
||||
---@type table
|
||||
extra = {
|
||||
---Add comment on the line above
|
||||
above = 'gcO',
|
||||
---Add comment on the line below
|
||||
below = 'gco',
|
||||
---Add comment at the end of line
|
||||
eol = 'gcA',
|
||||
},
|
||||
|
||||
---Create basic (operator-pending) and extended mappings for NORMAL + VISUAL mode
|
||||
---@type table
|
||||
mappings = {
|
||||
---Operator-pending mapping
|
||||
---Includes `gcc`, `gbc`, `gc[count]{motion}` and `gb[count]{motion}`
|
||||
---NOTE: These mappings can be changed individually by `opleader` and `toggler` config
|
||||
basic = true,
|
||||
---Extra mapping
|
||||
---Includes `gco`, `gcO`, `gcA`
|
||||
extra = true,
|
||||
---Extended mapping
|
||||
---Includes `g>`, `g<`, `g>[count]{motion}` and `g<[count]{motion}`
|
||||
extended = false,
|
||||
},
|
||||
|
||||
---Pre-hook, called before commenting the line
|
||||
---@type fun(ctx: Ctx):string
|
||||
pre_hook = nil,
|
||||
|
||||
---Post-hook, called after commenting is done
|
||||
---@type fun(ctx: Ctx)
|
||||
post_hook = nil,
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,17 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
vim.cmd("colorscheme darkplus")
|
||||
@@ -0,0 +1,121 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
local cb = require'diffview.config'.diffview_callback
|
||||
|
||||
require'diffview'.setup {
|
||||
diff_binaries = false, -- Show diffs for binaries
|
||||
enhanced_diff_hl = true, -- See ':h diffview-config-enhanced_diff_hl'
|
||||
use_icons = true, -- Requires nvim-web-devicons
|
||||
icons = { -- Only applies when use_icons is true.
|
||||
folder_closed = "",
|
||||
folder_open = "",
|
||||
},
|
||||
signs = {
|
||||
fold_closed = "",
|
||||
fold_open = "",
|
||||
},
|
||||
file_panel = {
|
||||
position = "left", -- One of 'left', 'right', 'top', 'bottom'
|
||||
width = 35, -- Only applies when position is 'left' or 'right'
|
||||
height = 10, -- Only applies when position is 'top' or 'bottom'
|
||||
listing_style = "tree", -- One of 'list' or 'tree'
|
||||
tree_options = { -- Only applies when listing_style is 'tree'
|
||||
flatten_dirs = true, -- Flatten dirs that only contain one single dir
|
||||
folder_statuses = "only_folded", -- One of 'never', 'only_folded' or 'always'.
|
||||
},
|
||||
},
|
||||
file_history_panel = {
|
||||
position = "bottom",
|
||||
width = 35,
|
||||
height = 16,
|
||||
log_options = {
|
||||
max_count = 256, -- Limit the number of commits
|
||||
follow = false, -- Follow renames (only for single file)
|
||||
all = false, -- Include all refs under 'refs/' including HEAD
|
||||
merges = false, -- List only merge commits
|
||||
no_merges = false, -- List no merge commits
|
||||
reverse = false, -- List commits in reverse order
|
||||
},
|
||||
},
|
||||
default_args = { -- Default args prepended to the arg-list for the listed commands
|
||||
DiffviewOpen = {},
|
||||
DiffviewFileHistory = {},
|
||||
},
|
||||
hooks = {}, -- See ':h diffview-config-hooks'
|
||||
key_bindings = {
|
||||
disable_defaults = false, -- Disable the default key bindings
|
||||
-- The `view` bindings are active in the diff buffers, only when the current
|
||||
-- tabpage is a Diffview.
|
||||
view = {
|
||||
["<tab>"] = cb("select_next_entry"), -- Open the diff for the next file
|
||||
["<s-tab>"] = cb("select_prev_entry"), -- Open the diff for the previous file
|
||||
["gf"] = cb("goto_file"), -- Open the file in a new split in previous tabpage
|
||||
["<C-w><C-f>"] = cb("goto_file_split"), -- Open the file in a new split
|
||||
["<C-w>gf"] = cb("goto_file_tab"), -- Open the file in a new tabpage
|
||||
["<leader>e"] = cb("focus_files"), -- Bring focus to the files panel
|
||||
["<leader>b"] = cb("toggle_files"), -- Toggle the files panel.
|
||||
},
|
||||
file_panel = {
|
||||
["j"] = cb("next_entry"), -- Bring the cursor to the next file entry
|
||||
["<down>"] = cb("next_entry"),
|
||||
["k"] = cb("prev_entry"), -- Bring the cursor to the previous file entry.
|
||||
["<up>"] = cb("prev_entry"),
|
||||
["<cr>"] = cb("select_entry"), -- Open the diff for the selected entry.
|
||||
["o"] = cb("select_entry"),
|
||||
["<2-LeftMouse>"] = cb("select_entry"),
|
||||
["-"] = cb("toggle_stage_entry"), -- Stage / unstage the selected entry.
|
||||
["S"] = cb("stage_all"), -- Stage all entries.
|
||||
["U"] = cb("unstage_all"), -- Unstage all entries.
|
||||
["X"] = cb("restore_entry"), -- Restore entry to the state on the left side.
|
||||
["R"] = cb("refresh_files"), -- Update stats and entries in the file list.
|
||||
["<tab>"] = cb("select_next_entry"),
|
||||
["<s-tab>"] = cb("select_prev_entry"),
|
||||
["gf"] = cb("goto_file"),
|
||||
["<C-w><C-f>"] = cb("goto_file_split"),
|
||||
["<C-w>gf"] = cb("goto_file_tab"),
|
||||
["i"] = cb("listing_style"), -- Toggle between 'list' and 'tree' views
|
||||
["f"] = cb("toggle_flatten_dirs"), -- Flatten empty subdirectories in tree listing style.
|
||||
["<leader>e"] = cb("focus_files"),
|
||||
["<leader>b"] = cb("toggle_files"),
|
||||
},
|
||||
file_history_panel = {
|
||||
["g!"] = cb("options"), -- Open the option panel
|
||||
["<C-A-d>"] = cb("open_in_diffview"), -- Open the entry under the cursor in a diffview
|
||||
["y"] = cb("copy_hash"), -- Copy the commit hash of the entry under the cursor
|
||||
["zR"] = cb("open_all_folds"),
|
||||
["zM"] = cb("close_all_folds"),
|
||||
["j"] = cb("next_entry"),
|
||||
["<down>"] = cb("next_entry"),
|
||||
["k"] = cb("prev_entry"),
|
||||
["<up>"] = cb("prev_entry"),
|
||||
["<cr>"] = cb("select_entry"),
|
||||
["o"] = cb("select_entry"),
|
||||
["<2-LeftMouse>"] = cb("select_entry"),
|
||||
["<tab>"] = cb("select_next_entry"),
|
||||
["<s-tab>"] = cb("select_prev_entry"),
|
||||
["gf"] = cb("goto_file"),
|
||||
["<C-w><C-f>"] = cb("goto_file_split"),
|
||||
["<C-w>gf"] = cb("goto_file_tab"),
|
||||
["<leader>e"] = cb("focus_files"),
|
||||
["<leader>b"] = cb("toggle_files"),
|
||||
},
|
||||
option_panel = {
|
||||
["<tab>"] = cb("select"),
|
||||
["q"] = cb("close"),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
vim.g.edge_style = 'default'
|
||||
vim.g.edge_disable_italic_comment = 0
|
||||
vim.g.edge_enable_italic = 0
|
||||
vim.g.edge_cursor = 'auto'
|
||||
vim.g.edge_transparent_background = 0
|
||||
vim.g.edge_menu_selection_background = 'blue'
|
||||
vim.g.edge_spell_foreground = 'none'
|
||||
vim.g.edge_show_eob = 1
|
||||
vim.g.edge_diagnostic_text_highlight = 0
|
||||
vim.g.edge_diagnostic_line_highlight = 1
|
||||
vim.g.edge_diagnostic_virtual_text = 'grey'
|
||||
vim.g.edge_current_word = 'grey background'
|
||||
vim.g.edge_disable_terminal_colors = 0
|
||||
vim.g.edge_lightline_disable_bold = 0
|
||||
vim.g.edge_better_performance = 1
|
||||
|
||||
vim.fn.execute('colorscheme edge')
|
||||
@@ -0,0 +1,17 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
vim.keymap.set('n', "<leader>gl", ":Flog<CR>", { remap = false, silent = true })
|
||||
@@ -0,0 +1,24 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
local function git_status_tab()
|
||||
vim.fn.execute("tabnew")
|
||||
vim.fn.execute("leftabove vertical G | vertical resize 60 | set wfw")
|
||||
end
|
||||
|
||||
vim.keymap.set('n', '<leader>gd', ':Gdiffsplit<CR>', { remap = false })
|
||||
vim.keymap.set('n', '<leader>gg', git_status_tab, { silent = true, remap = false })
|
||||
vim.keymap.set('n', '<leader>gc', ':G commit<CR>', { remap = false })
|
||||
@@ -0,0 +1,19 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
local gl = require('galaxyline')
|
||||
|
||||
-- maybe some other day
|
||||
@@ -0,0 +1,61 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
require('github-theme').setup(
|
||||
{
|
||||
theme_style = 'dimmed',
|
||||
transparent = false,
|
||||
hide_end_of_buffer = false,
|
||||
hide_inactive_statusline = false,
|
||||
dark_float = true,
|
||||
dev = false,
|
||||
|
||||
-- styles
|
||||
comment_style = 'italic',
|
||||
function_style = 'NONE',
|
||||
keyword_style = 'NONE',
|
||||
msg_area_style = 'NONE',
|
||||
variable_style = 'NONE',
|
||||
|
||||
-- sidebars
|
||||
sidebars = {
|
||||
'qf',
|
||||
'vista_kind',
|
||||
'terminal',
|
||||
'packer',
|
||||
'aerial',
|
||||
'NvimTree'
|
||||
},
|
||||
|
||||
-- Change the "hint" color to the "orange" color, and make the "error" color bright red
|
||||
-- colors = { hint = 'orange', error = '#ff0000' },
|
||||
|
||||
-- Overwrite the highlight groups
|
||||
-- overrides = function(c)
|
||||
-- return {
|
||||
-- htmlTag = {
|
||||
-- fg = c.red,
|
||||
-- bg = '#282c34',
|
||||
-- sp = c.hint,
|
||||
-- style = 'underline'
|
||||
-- },
|
||||
-- DiagnosticHint = { link = 'LspDiagnosticsDefaultHint' },
|
||||
-- -- this will remove the highlight groups
|
||||
-- TSField = {}
|
||||
-- }
|
||||
-- end
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,61 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
require('gitsigns').setup(
|
||||
{
|
||||
on_attach = function(bufnr)
|
||||
local gs = package.loaded.gitsigns
|
||||
local function map(mode, l, r, opts)
|
||||
opts = opts or {}
|
||||
opts.buffer = bufnr
|
||||
vim.keymap.set(mode, l, r, opts)
|
||||
end
|
||||
|
||||
-- map('n', ']c',
|
||||
-- function()
|
||||
-- gs.next_hunk{
|
||||
-- wrap=false,
|
||||
-- navigation_message=true,
|
||||
-- foldopen=true
|
||||
-- }
|
||||
-- end
|
||||
-- )
|
||||
-- map('n', '[c',
|
||||
-- function()
|
||||
-- gs.prev_hunk{
|
||||
-- wrap=false,
|
||||
-- navigation_message=true,
|
||||
-- foldopen=true
|
||||
-- }
|
||||
-- end
|
||||
-- )
|
||||
map('n', '<leader>gv', gs.select_hunk)
|
||||
-- map('n', '<C-j>', "&diff ? '<C-j>' : '<cmd>Gitsigns next_hunk<CR>'", {expr=true})
|
||||
-- map('n', '<C-k>', "&diff ? '<C-k>' : '<cmd>Gitsigns prev_hunk<CR>'", {expr=true})
|
||||
map({ 'n', 'v' }, '<leader>gr', ':Gitsigns reset_hunk<CR>') -- gs.reset_hunk() doesn't work with selected lines
|
||||
map('n', '<leader>g?', gs.preview_hunk)
|
||||
map('n', '<leader>gb', function()
|
||||
gs.blame_line { full = true }
|
||||
end)
|
||||
-- map('n', '<leader>gd', gs.diffthis)
|
||||
end,
|
||||
signs = {
|
||||
-- default
|
||||
-- untracked = { text = '┆' }
|
||||
untracked = { text = '│' }
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,19 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
vim.opt.termguicolors = true
|
||||
vim.o.background = "dark" -- or "light" for light mode
|
||||
vim.fn.execute("colorscheme gruvbox")
|
||||
@@ -0,0 +1,24 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
require("indent_blankline").setup({
|
||||
show_current_context = true,
|
||||
show_current_context_start = false,
|
||||
use_treesitter = true,
|
||||
show_first_indent_level = true,
|
||||
char = '│',
|
||||
-- context_char = '┃',
|
||||
})
|
||||
@@ -0,0 +1,22 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
-- more options at https://www.jetbrains.com/lp/mono/
|
||||
vim.g.indentLine_char = '▏'
|
||||
-- Disable conceal for some syntax plugins
|
||||
vim.g.vim_json_conceal = 0
|
||||
vim.g.markdown_syntax_conceal = 0
|
||||
vim.g.indentLine_fileTypeExclude = { 'NvimTree' }
|
||||
@@ -0,0 +1,34 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
require('kanagawa').setup({
|
||||
undercurl = true, -- enable undercurls
|
||||
commentStyle = { italic = true },
|
||||
functionStyle = {},
|
||||
keywordStyle = {},
|
||||
statementStyle = { bold = true },
|
||||
typeStyle = {},
|
||||
variablebuiltinStyle = {},
|
||||
specialReturn = true, -- special highlight for the return keyword
|
||||
specialException = true, -- special highlight for exception handling keywords
|
||||
transparent = false, -- do not set background color
|
||||
dimInactive = true, -- dim inactive window `:h hl-NormalNC`
|
||||
globalStatus = true, -- adjust window separators highlight for laststatus=3
|
||||
colors = {},
|
||||
overrides = {},
|
||||
})
|
||||
|
||||
vim.cmd("colorscheme kanagawa")
|
||||
@@ -0,0 +1,21 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
vim.g.lazygit_floating_window_winblend = 0 -- transparency of floating window
|
||||
vim.g.lazygit_floating_window_scaling_factor = 0.9 -- scaling factor for floating window
|
||||
vim.g.lazygit_floating_window_corner_chars = { '╭', '╮', '╰', '╯' } -- customize lazygit popup window corner characters
|
||||
vim.g.lazygit_floating_window_use_plenary = 0 -- use plenary.nvim to manage floating window if available
|
||||
vim.g.lazygit_use_neovim_remote = 1 -- fallback to 0 if neovim-remote is not installed
|
||||
@@ -0,0 +1,17 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
require("lsp_signature").setup()
|
||||
@@ -0,0 +1,113 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
--- @param trunc_width number trunctates component when screen width is less then trunc_width
|
||||
--- @param trunc_len number truncates component to trunc_len number of chars
|
||||
--- @param hide_width number hides component when window width is smaller then hide_width
|
||||
--- @param no_ellipsis boolean whether to disable adding '...' at end after truncation
|
||||
--- return function that can format the component accordingly
|
||||
local function trunc(trunc_width, trunc_len, hide_width, no_ellipsis)
|
||||
return function(str)
|
||||
local win_width = vim.fn.winwidth(0)
|
||||
if hide_width and win_width < hide_width then return ''
|
||||
elseif trunc_width and trunc_len and win_width < trunc_width and #str > trunc_len then
|
||||
return str:sub(1, trunc_len) .. (no_ellipsis and '' or '...')
|
||||
end
|
||||
return str
|
||||
end
|
||||
end
|
||||
|
||||
--- @param trunc_len number truncates component to trunc_len number of chars
|
||||
--- @param no_ellipsis boolean whether to disable adding '...' at start before truncation
|
||||
--- return function that can format the component accordingly
|
||||
local function l_trunc(trunc_len, no_ellipsis)
|
||||
return function(str)
|
||||
if #str > trunc_len then
|
||||
return (no_ellipsis and '' or '...') .. str:sub(-trunc_len, -1)
|
||||
end
|
||||
return str
|
||||
end
|
||||
end
|
||||
|
||||
--- @param trunc_len number truncates component to trunc_len number of chars
|
||||
--- @param no_ellipsis boolean whether to disable adding '...' at start before truncation
|
||||
--- return function that can format the component accordingly
|
||||
local function r_trunc(trunc_len, no_ellipsis)
|
||||
return function(str)
|
||||
if #str > trunc_len then
|
||||
return str:sub(1, trunc_len) .. (no_ellipsis and '' or '...')
|
||||
end
|
||||
return str
|
||||
end
|
||||
end
|
||||
|
||||
local function short_path(len)
|
||||
return function(str)
|
||||
if #str > len then
|
||||
return vim.fn.pathshorten(str, 1)
|
||||
end
|
||||
return str
|
||||
end
|
||||
end
|
||||
|
||||
local function header()
|
||||
local text = short_path(40)(vim.fn.getcwd())
|
||||
local branch = r_trunc(15, false)(vim.fn.FugitiveHead())
|
||||
if branch ~= '' then
|
||||
text = text .. ' ' .. branch
|
||||
end
|
||||
return text
|
||||
end
|
||||
|
||||
require('lualine').setup ({
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
-- theme = require('config.nightfox_lualine_custom'),
|
||||
theme = 'auto',
|
||||
-- theme = "catppuccin",
|
||||
component_separators = { left = '', right = '' },
|
||||
section_separators = { left = '', right = '' },
|
||||
disabled_filetypes = { 'NvimTree', 'fugitive' },
|
||||
always_divide_middle = true,
|
||||
globalstatus = true
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { },
|
||||
lualine_b = { 'mode' },
|
||||
lualine_c = { { 'filename', path = 1 }, 'diff', {'diagnostics', sources = {'nvim_lsp'}}},
|
||||
lualine_x = { 'filetype', 'encoding', 'fileformat', 'progress' },
|
||||
lualine_y = { 'location' },
|
||||
lualine_z = { }
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = { },
|
||||
lualine_b = { },
|
||||
lualine_c = { 'filename' },
|
||||
lualine_x = { 'location' },
|
||||
lualine_y = { },
|
||||
lualine_z = { }
|
||||
},
|
||||
-- tabline = {
|
||||
-- lualine_a = { { header } },
|
||||
-- lualine_b = { {'tabs', mode = 0 } },
|
||||
-- lualine_c = { { 'buffers', show_filename_only = true, filetype_names = { TelescopePrompt = 'Telescope', fugitive = 'Fugitive' } } },
|
||||
-- lualine_x = {},
|
||||
-- lualine_y = {},
|
||||
-- lualine_z = {}
|
||||
-- },
|
||||
extensions = { }
|
||||
})
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
-- local ls = require"luasnip"
|
||||
-- local s = ls.snippet
|
||||
-- local sn = ls.snippet_node
|
||||
-- local isn = ls.indent_snippet_node
|
||||
-- local t = ls.text_node
|
||||
-- local i = ls.insert_node
|
||||
-- local f = ls.function_node
|
||||
-- local c = ls.choice_node
|
||||
-- local d = ls.dynamic_node
|
||||
-- local r = ls.restore_node
|
||||
-- local events = require("luasnip.util.events")
|
||||
-- local ai = require("luasnip.nodes.absolute_indexer")
|
||||
|
||||
-- For rafamadriz/friendly-snippets
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
@@ -0,0 +1,32 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
require("mason-lspconfig").setup({
|
||||
-- A list of servers to automatically install if they're not already installed. Example: { "rust_analyzer@nightly", "lua_ls" }
|
||||
-- This setting has no relation with the `automatic_installation` setting.
|
||||
---@type string[]
|
||||
ensure_installed = require('lsp'):language_servers(),
|
||||
|
||||
-- Whether servers that are set up (via lspconfig) should be automatically installed if they're not already installed.
|
||||
-- This setting has no relation with the `ensure_installed` setting.
|
||||
-- Can either be:
|
||||
-- - false: Servers are not automatically installed.
|
||||
-- - true: All servers set up via lspconfig are automatically installed.
|
||||
-- - { exclude: string[] }: All servers set up via lspconfig, except the ones provided in the list, are automatically installed.
|
||||
-- Example: automatic_installation = { exclude = { "rust_analyzer", "solargraph" } }
|
||||
---@type boolean
|
||||
-- automatic_installation = true
|
||||
})
|
||||
@@ -0,0 +1,17 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
require("mason").setup()
|
||||
@@ -0,0 +1,54 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
require('material').setup({
|
||||
contrast = {
|
||||
sidebars = false, -- Enable contrast for sidebar-like windows ( for example Nvim-Tree )
|
||||
floating_windows = false, -- Enable contrast for floating windows
|
||||
line_numbers = false, -- Enable contrast background for line numbers
|
||||
sign_column = false, -- Enable contrast background for the sign column
|
||||
cursor_line = false, -- Enable darker background for the cursor line
|
||||
non_current_windows = false, -- Enable darker background for non-current windows
|
||||
popup_menu = false, -- Enable lighter background for the popup menu
|
||||
},
|
||||
italics = {
|
||||
comments = false, -- Enable italic comments
|
||||
keywords = false, -- Enable italic keywords
|
||||
functions = false, -- Enable italic functions
|
||||
strings = false, -- Enable italic strings
|
||||
variables = false -- Enable italic variables
|
||||
},
|
||||
contrast_filetypes = { -- Specify which filetypes get the contrasted (darker) background
|
||||
"terminal", -- Darker terminal background
|
||||
"packer", -- Darker packer background
|
||||
"qf" -- Darker qf list background
|
||||
},
|
||||
high_visibility = {
|
||||
lighter = false, -- Enable higher contrast text for lighter style
|
||||
darker = false -- Enable higher contrast text for darker style
|
||||
},
|
||||
disable = {
|
||||
borders = false, -- Disable borders between verticaly split windows
|
||||
background = false, -- Prevent the theme from setting the background (NeoVim then uses your teminal background)
|
||||
term_colors = false, -- Prevent the theme from setting terminal colors
|
||||
eob_lines = false -- Hide the end-of-buffer lines
|
||||
},
|
||||
lualine_style = "default", -- Lualine style ( can be 'stealth' or 'default' )
|
||||
async_loading = true, -- Load parts of the theme asyncronously for faster startup (turned on by default)
|
||||
custom_highlights = {} -- Overwrite highlights with your own
|
||||
})
|
||||
vim.g.material_style = "deep ocean"
|
||||
vim.fn.execute("colorscheme material")
|
||||
@@ -0,0 +1,67 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
require('nightfox').setup({
|
||||
options = {
|
||||
-- Compiled file's destination location
|
||||
compile_path = vim.fn.stdpath("cache") .. "/nightfox",
|
||||
compile_file_suffix = "_compiled", -- Compiled file suffix
|
||||
transparent = false, -- Disable setting background
|
||||
terminal_colors = true, -- Set terminal colors (vim.g.terminal_color_*) used in `:terminal`
|
||||
dim_inactive = false, -- Non focused panes set to alternative background
|
||||
styles = { -- Style to be applied to different syntax groups
|
||||
comments = "NONE", -- Value is any valid attr-list value `:help attr-list`
|
||||
functions = "NONE",
|
||||
keywords = "NONE",
|
||||
numbers = "NONE",
|
||||
strings = "NONE",
|
||||
types = "NONE",
|
||||
variables = "NONE",
|
||||
},
|
||||
inverse = { -- Inverse highlight for different types
|
||||
match_paren = false,
|
||||
visual = false,
|
||||
search = false,
|
||||
},
|
||||
modules = { -- List of various plugins and additional options
|
||||
cmp = true,
|
||||
diagnostic = {
|
||||
enable = true,
|
||||
background = true
|
||||
},
|
||||
gitsigns = true,
|
||||
native_lsp = true,
|
||||
nvimtree = true,
|
||||
telescope = true,
|
||||
treesitter = true,
|
||||
},
|
||||
},
|
||||
groups = {
|
||||
all = {
|
||||
-- By default nightfox links some groups together. `CursorColumn` is one of these groups. When overriding
|
||||
-- Make sure `link` is cleared to `""` so that the link will be removed.
|
||||
-- see https://github.com/EdenEast/nightfox.nvim/blob/main/lua/nightfox/group/editor.lua
|
||||
Normal = { bg = "palette.bg0", link = "" },
|
||||
NormalNC = { bg = "palette.bg0", link = "" },
|
||||
NormalFloat = { bg = "palette.bg1", link = "" },
|
||||
CursorLine = { bg = "palette.bg1", link = "" },
|
||||
StatusLine = { bg = "palette.bg1", link = "" },
|
||||
StatusLineNC = { bg = "palette.bg1", link = "" }
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
vim.cmd("colorscheme nightfox")
|
||||
@@ -0,0 +1,47 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
local Color = require("nightfox.lib.color")
|
||||
local spec = require("nightfox.spec").load("nightfox")
|
||||
|
||||
local pal = spec.pallet
|
||||
local bg = Color.from_hex(spec.bg1)
|
||||
local fg = spec.fg2
|
||||
|
||||
local function generate_mode(color, amount)
|
||||
amount = amount or 0.3
|
||||
local fade = bg:blend(Color.from_hex(color), amount):to_css()
|
||||
local b = bg:to_css()
|
||||
local f = fg
|
||||
|
||||
return {
|
||||
a = { bg = color, fg = b },
|
||||
b = { bg = fade, fg = f },
|
||||
c = { bg = b, fg = f },
|
||||
}
|
||||
end
|
||||
|
||||
-- stylua: ignore
|
||||
local nightfox = {
|
||||
normal = generate_mode(pal.blue.base),
|
||||
insert = generate_mode(pal.green.base),
|
||||
command = generate_mode(pal.yellow.base),
|
||||
visual = generate_mode(pal.magenta.base),
|
||||
replace = generate_mode(pal.red.base),
|
||||
inactive = generate_mode(spec.fg3),
|
||||
}
|
||||
|
||||
return nightfox
|
||||
@@ -0,0 +1,22 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
vim.g.nord_contrast = true
|
||||
vim.g.nord_borders = false
|
||||
vim.g.nord_disable_background = false
|
||||
vim.g.nord_italic = false
|
||||
|
||||
require('nord').set()
|
||||
@@ -0,0 +1,35 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
require('nvim-autopairs').setup({
|
||||
disable_filetype = { "TelescopePrompt" },
|
||||
disable_in_macro = false, -- disable when recording or executing a macro
|
||||
disable_in_visualblock = false, -- disable when insert after visual block mode
|
||||
ignored_next_char = [=[[%w%%%'%[%"%.]]=],
|
||||
enable_moveright = true,
|
||||
enable_afterquote = true, -- add bracket pairs after quote
|
||||
enable_check_bracket_line = true, --- check bracket in same line
|
||||
enable_bracket_in_quote = true, --
|
||||
enable_abbr = false, -- trigger abbreviation
|
||||
break_undo = true, -- switch for basic rule break undo sequence
|
||||
check_ts = false,
|
||||
map_cr = true,
|
||||
map_bs = true, -- map the <BS> key
|
||||
map_c_h = false, -- Map the <C-h> key to delete a pair
|
||||
map_c_w = false, -- map <c-w> to delete a pair if possible
|
||||
})
|
||||
-- cmp_autopairs.lisp[#cmp_autopairs.lisp+1] = "racket"
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
local has_words_before = function()
|
||||
unpack = unpack or table.unpack
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
local cmp = require('cmp')
|
||||
local luasnip = require('luasnip')
|
||||
local lspkind = require('lspkind')
|
||||
|
||||
cmp.setup({
|
||||
enabled = function()
|
||||
-- disable completion in comments
|
||||
local context = require 'cmp.config.context'
|
||||
-- keep command mode completion enabled when cursor is in a comment
|
||||
if vim.api.nvim_get_mode().mode == 'c' then
|
||||
return true
|
||||
else
|
||||
return not context.in_treesitter_capture('comment') and
|
||||
not context.in_syntax_group('Comment')
|
||||
end
|
||||
end,
|
||||
completion = { keyword_length = 3 },
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
-- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||
luasnip.lsp_expand(args.body) -- For `luasnip` users.
|
||||
-- require('snippy').expand_snippet(args.body) -- For `snippy` users.
|
||||
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
|
||||
end
|
||||
},
|
||||
formatting = {
|
||||
format = function(entry, vim_item)
|
||||
vim_item = lspkind.cmp_format({
|
||||
mode = 'text', -- show only symbol annotations
|
||||
maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
|
||||
ellipsis_char =
|
||||
'...' -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first)
|
||||
|
||||
-- The function below will be called before any actual modifications from lspkind
|
||||
-- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30))
|
||||
--[[ before = function(entry, vim_item)
|
||||
...
|
||||
return vim_item
|
||||
end ]]
|
||||
})(entry, vim_item)
|
||||
|
||||
vim_item.dup = 0
|
||||
|
||||
return vim_item
|
||||
end
|
||||
},
|
||||
experimental = { ghost_text = true },
|
||||
mapping = {
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.close(),
|
||||
['<CR>'] = cmp.mapping(
|
||||
function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.confirm(
|
||||
{
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true
|
||||
}
|
||||
)
|
||||
-- vim.api.nvim_feedkeys('(', 'i', true)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }
|
||||
),
|
||||
-- ['<Down>'] = cmp.mapping(
|
||||
-- function(fallback)
|
||||
-- if cmp.visible() then
|
||||
-- cmp.select_next_item()
|
||||
-- elseif luasnip.expand_or_jumpable() then
|
||||
-- luasnip.expand_or_jump()
|
||||
-- else
|
||||
-- fallback()
|
||||
-- end
|
||||
-- end, { 'i', 's' }
|
||||
-- ),
|
||||
|
||||
-- ['<Up>'] = cmp.mapping(
|
||||
-- function(fallback)
|
||||
-- if cmp.visible() then
|
||||
-- cmp.select_prev_item()
|
||||
-- elseif luasnip.jumpable(-1) then
|
||||
-- luasnip.jump(-1)
|
||||
-- else
|
||||
-- fallback()
|
||||
-- end
|
||||
-- end, { 'i', 's' }
|
||||
-- ),
|
||||
['<Tab>'] = cmp.mapping(
|
||||
function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
-- You could replace the expand_or_jumpable() calls within expand_or_locally_jumpable()
|
||||
-- they way you will only jump inside the snippet region
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }
|
||||
),
|
||||
|
||||
['<S-Tab>'] = cmp.mapping(
|
||||
function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }
|
||||
)
|
||||
},
|
||||
sources = {
|
||||
-- { name = 'buffer' },
|
||||
{ name = 'path' },
|
||||
{ name = 'nvim_lsp' },
|
||||
-- { name = 'nvim_lsp_signature_help' },
|
||||
-- { name = 'nvim_lua' },
|
||||
-- { name = 'vsnip' }, -- For vsnip users.
|
||||
{ name = 'luasnip' } -- For luasnip users.
|
||||
-- { name = 'ultisnips' }, -- For ultisnips users.
|
||||
-- { name = 'snippy' }, -- For snippy users.
|
||||
}
|
||||
})
|
||||
-- see https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance#how-to-add-visual-studio-code-dark-theme-colors-to-the-menu
|
||||
-- -- gray
|
||||
-- vim.fn.execute("highlight! CmpItemAbbrDeprecated guibg=NONE gui=strikethrough guifg=#808080")
|
||||
-- -- blue
|
||||
-- vim.fn.execute("highlight! CmpItemAbbrMatch guibg=NONE guifg=#569CD6")
|
||||
-- vim.fn.execute("highlight! CmpItemAbbrMatchFuzzy guibg=NONE guifg=#569CD6")
|
||||
-- -- light blue
|
||||
-- vim.fn.execute("highlight! CmpItemKindVariable guibg=NONE guifg=#9CDCFE")
|
||||
-- vim.fn.execute("highlight! CmpItemKindInterface guibg=NONE guifg=#9CDCFE")
|
||||
-- vim.fn.execute("highlight! CmpItemKindText guibg=NONE guifg=#9CDCFE")
|
||||
-- -- pink
|
||||
-- vim.fn.execute("highlight! CmpItemKindFunction guibg=NONE guifg=#C586C0")
|
||||
-- vim.fn.execute("highlight! CmpItemKindMethod guibg=NONE guifg=#C586C0")
|
||||
-- -- front
|
||||
-- vim.fn.execute("highlight! CmpItemKindKeyword guibg=NONE guifg=#D4D4D4")
|
||||
-- vim.fn.execute("highlight! CmpItemKindProperty guibg=NONE guifg=#D4D4D4")
|
||||
-- vim.fn.execute("highlight! CmpItemKindUnit guibg=NONE guifg=#D4D4D4")
|
||||
|
||||
cmp.setup.cmdline(
|
||||
'/',
|
||||
{
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = { { name = 'buffer' } }
|
||||
}
|
||||
)
|
||||
|
||||
cmp.setup.cmdline(
|
||||
':',
|
||||
{
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources(
|
||||
{ { name = 'path' } },
|
||||
{ { name = 'cmdline', option = { ignore_cmds = { 'Man', '!' } } } }
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
|
||||
cmp.event:on(
|
||||
'confirm_done',
|
||||
cmp_autopairs.on_confirm_done()
|
||||
)
|
||||
@@ -0,0 +1,33 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
require('nvim_comment').setup({
|
||||
-- Linters prefer comment and line to have a space in between markers
|
||||
marker_padding = true,
|
||||
-- should comment out empty or whitespace only lines
|
||||
comment_empty = true,
|
||||
-- Should key mappings be created
|
||||
create_mappings = true,
|
||||
-- Normal mode mapping left hand side
|
||||
-- line_mapping = "<leader>cc",
|
||||
-- Visual/Operator mapping left hand side
|
||||
-- operator_mapping = "<leader>c",
|
||||
-- Hook function to call before commenting takes place
|
||||
hook = nil
|
||||
})
|
||||
vim.keymap.set('n', '<leader>c', ':CommentToggle<CR>')
|
||||
vim.keymap.set('v', '<leader>c', ":'<, '>CommentToggle<CR>")
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
require("dapui").setup({
|
||||
icons = { expanded = "▾", collapsed = "▸" },
|
||||
mappings = {
|
||||
-- Use a table to apply multiple mappings
|
||||
expand = { "<CR>", "<2-LeftMouse>" },
|
||||
open = "o",
|
||||
remove = "d",
|
||||
edit = "e",
|
||||
repl = "r",
|
||||
toggle = "t",
|
||||
},
|
||||
layouts = {
|
||||
{
|
||||
elements = {
|
||||
'scopes',
|
||||
'breakpoints',
|
||||
'stacks',
|
||||
'watches',
|
||||
},
|
||||
size = 40,
|
||||
position = 'left',
|
||||
},
|
||||
{
|
||||
elements = {
|
||||
'repl',
|
||||
'console',
|
||||
},
|
||||
size = 10,
|
||||
position = 'bottom',
|
||||
},
|
||||
},
|
||||
floating = {
|
||||
max_height = nil, -- These can be integers or a float between 0 and 1.
|
||||
max_width = nil, -- Floats will be treated as percentage of your screen.
|
||||
border = "single", -- Border style. Can be "single", "double" or "rounded"
|
||||
mappings = {
|
||||
close = { "q", "<Esc>" },
|
||||
},
|
||||
},
|
||||
windows = { indent = 1 },
|
||||
})
|
||||
@@ -0,0 +1,102 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
vim.fn.execute("nnoremap <silent> <F5> :lua require'dap'.continue()<CR>")
|
||||
vim.fn.execute("nnoremap <silent> <F10> :lua require'dap'.step_over()<CR>")
|
||||
vim.fn.execute("nnoremap <silent> <F11> :lua require'dap'.step_into()<CR>")
|
||||
vim.fn.execute("nnoremap <silent> <F12> :lua require'dap'.step_out()<CR>")
|
||||
vim.fn.execute("nnoremap <leader>dt :lua require'config.nvim-dap'.pytest({'-k', ''})<left><left><left>")
|
||||
vim.fn.execute("nnoremap <leader>dl :lua require'config.nvim-dap'.launch({''})<left><left><left>")
|
||||
vim.fn.execute("nnoremap <silent> <leader>db :lua require'dap'.toggle_breakpoint()<CR>")
|
||||
-- vim.fn.execute("nnoremap <silent> <leader>B :lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>")
|
||||
-- vim.fn.execute("nnoremap <silent> <leader>lp :lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))<CR>")
|
||||
vim.fn.execute("nnoremap <silent> <leader>dr :lua require'dap'.repl.open()<CR>")
|
||||
-- vim.fn.execute("nnoremap <silent> <leader>dl :lua require'dap'.run_last()<CR>")
|
||||
|
||||
local utils = require('utils')
|
||||
|
||||
M = {}
|
||||
|
||||
local env_ok = false
|
||||
local dap = nil
|
||||
|
||||
local function check_env()
|
||||
local debugpy = utils.exec('python -m debugpy --version')
|
||||
assert(debugpy.rc == 0, 'Python module debugpy is required')
|
||||
env_ok = true
|
||||
end
|
||||
|
||||
local function load_dap()
|
||||
local ok, p = pcall(require, 'dap')
|
||||
assert(ok, 'nvim-dap is required')
|
||||
return p
|
||||
end
|
||||
|
||||
local function start(config)
|
||||
if not env_ok then
|
||||
check_env()
|
||||
end
|
||||
if not dap then
|
||||
dap = load_dap()
|
||||
dap.adapters.python = {
|
||||
type = 'executable';
|
||||
command = 'python';
|
||||
args = { '-m', 'debugpy.adapter' };
|
||||
cwd = vim.fn.getcwd();
|
||||
}
|
||||
end
|
||||
dap.run(config)
|
||||
-- List of events described at https://microsoft.github.io/debug-adapter-protocol/specification#Events
|
||||
-- Also see :h dap-extensions
|
||||
dap.listeners.after['event_initialized']['nvim-dap.lua'] = function()
|
||||
dap.set_exception_breakpoints({ 'userUnhandled' })
|
||||
end
|
||||
end
|
||||
|
||||
function M.launch(args)
|
||||
assert(type(args) == 'table', 'Args not specified or of wrong type')
|
||||
local config = {
|
||||
name = 'Launch file',
|
||||
type = 'python',
|
||||
request = 'launch',
|
||||
program = "${file}";
|
||||
-- python = 'python';
|
||||
-- program = vim.fn.getcwd() .. '/.venv/bin/pytest';
|
||||
console = "integratedTerminal",
|
||||
args = args
|
||||
}
|
||||
start(config)
|
||||
end
|
||||
|
||||
function M.pytest(args)
|
||||
assert(type(args) == 'table', 'Args not specified or of wrong type')
|
||||
local config = {
|
||||
name = 'pytest ' .. table.concat(args, ' '),
|
||||
type = 'python',
|
||||
request = 'launch',
|
||||
|
||||
-- pythonPath = vim.fn.getcwd() .. '/.venv/bin/python',
|
||||
module = 'pytest',
|
||||
-- python = 'python';
|
||||
-- program = vim.fn.getcwd() .. '/.venv/bin/pytest';
|
||||
args = args,
|
||||
console = "integratedTerminal",
|
||||
-- program = "${file}";
|
||||
}
|
||||
start(config)
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -0,0 +1,230 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
local nvim_tree = require('nvim-tree')
|
||||
|
||||
nvim_tree.setup({
|
||||
auto_reload_on_write = true,
|
||||
create_in_closed_folder = false,
|
||||
disable_netrw = false,
|
||||
hijack_cursor = true,
|
||||
hijack_netrw = false,
|
||||
hijack_unnamed_buffer_when_opening = false,
|
||||
-- ignore_buffer_on_setup = false,
|
||||
-- open_on_setup = false,
|
||||
-- open_on_setup_file = false,
|
||||
open_on_tab = false,
|
||||
ignore_buf_on_tab_change = {},
|
||||
sort_by = "name",
|
||||
root_dirs = {},
|
||||
prefer_startup_root = false,
|
||||
sync_root_with_cwd = true,
|
||||
reload_on_bufenter = false,
|
||||
respect_buf_cwd = false,
|
||||
on_attach = "disable",
|
||||
remove_keymaps = false,
|
||||
select_prompts = false,
|
||||
view = {
|
||||
adaptive_size = false,
|
||||
centralize_selection = false,
|
||||
width = 40,
|
||||
hide_root_folder = false,
|
||||
side = "left",
|
||||
preserve_window_proportions = true,
|
||||
number = false,
|
||||
relativenumber = false,
|
||||
signcolumn = "yes",
|
||||
mappings = {
|
||||
custom_only = false,
|
||||
-- list = {
|
||||
-- { key = "q", action = ""},
|
||||
-- },
|
||||
},
|
||||
float = {
|
||||
enable = false,
|
||||
quit_on_focus_loss = true,
|
||||
open_win_config = {
|
||||
relative = "editor",
|
||||
border = "rounded",
|
||||
width = 30,
|
||||
height = 30,
|
||||
row = 1,
|
||||
col = 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
renderer = {
|
||||
add_trailing = true,
|
||||
group_empty = true,
|
||||
highlight_git = true,
|
||||
full_name = false,
|
||||
highlight_opened_files = "name",
|
||||
root_folder_modifier = ":~",
|
||||
indent_width = 2,
|
||||
indent_markers = {
|
||||
enable = false,
|
||||
inline_arrows = true,
|
||||
icons = {
|
||||
corner = "└",
|
||||
edge = "│",
|
||||
item = "│",
|
||||
bottom = "─",
|
||||
none = " ",
|
||||
},
|
||||
},
|
||||
icons = {
|
||||
webdev_colors = true,
|
||||
git_placement = "after",
|
||||
padding = " ",
|
||||
symlink_arrow = " ➛ ",
|
||||
show = {
|
||||
file = true,
|
||||
folder = true,
|
||||
folder_arrow = false,
|
||||
git = true,
|
||||
},
|
||||
glyphs = {
|
||||
default = "",
|
||||
symlink = "",
|
||||
bookmark = "",
|
||||
folder = {
|
||||
arrow_closed = "",
|
||||
arrow_open = "",
|
||||
default = "",
|
||||
open = "",
|
||||
empty = "",
|
||||
empty_open = "",
|
||||
symlink = "",
|
||||
symlink_open = "",
|
||||
},
|
||||
git = {
|
||||
unstaged = "✗",
|
||||
staged = "✓",
|
||||
unmerged = "",
|
||||
renamed = "➜",
|
||||
untracked = "★",
|
||||
deleted = "",
|
||||
ignored = "◌",
|
||||
},
|
||||
},
|
||||
},
|
||||
special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" },
|
||||
symlink_destination = true,
|
||||
},
|
||||
hijack_directories = {
|
||||
enable = true,
|
||||
auto_open = true,
|
||||
},
|
||||
update_focused_file = {
|
||||
enable = true,
|
||||
update_root = true,
|
||||
ignore_list = {
|
||||
'help'
|
||||
},
|
||||
},
|
||||
-- ignore_ft_on_setup = {},
|
||||
system_open = {
|
||||
cmd = "",
|
||||
args = {},
|
||||
},
|
||||
diagnostics = {
|
||||
enable = true,
|
||||
show_on_dirs = false,
|
||||
debounce_delay = 50,
|
||||
icons = {
|
||||
hint = "",
|
||||
info = "",
|
||||
warning = "",
|
||||
error = "",
|
||||
},
|
||||
},
|
||||
filters = {
|
||||
dotfiles = false,
|
||||
custom = {},
|
||||
exclude = {},
|
||||
},
|
||||
filesystem_watchers = {
|
||||
enable = true,
|
||||
debounce_delay = 50,
|
||||
},
|
||||
git = {
|
||||
enable = true,
|
||||
ignore = true,
|
||||
show_on_dirs = true,
|
||||
timeout = 400,
|
||||
},
|
||||
actions = {
|
||||
use_system_clipboard = true,
|
||||
change_dir = {
|
||||
enable = false,
|
||||
global = false,
|
||||
restrict_above_cwd = false,
|
||||
},
|
||||
expand_all = {
|
||||
max_folder_discovery = 300,
|
||||
exclude = {},
|
||||
},
|
||||
file_popup = {
|
||||
open_win_config = {
|
||||
col = 1,
|
||||
row = 1,
|
||||
relative = "cursor",
|
||||
border = "shadow",
|
||||
style = "minimal",
|
||||
},
|
||||
},
|
||||
open_file = {
|
||||
quit_on_open = false,
|
||||
resize_window = false,
|
||||
window_picker = {
|
||||
enable = true,
|
||||
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
|
||||
exclude = {
|
||||
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" },
|
||||
buftype = { "nofile", "terminal", "help" },
|
||||
},
|
||||
},
|
||||
},
|
||||
remove_file = {
|
||||
close_window = true,
|
||||
},
|
||||
},
|
||||
trash = {
|
||||
cmd = "trash",
|
||||
require_confirm = true,
|
||||
},
|
||||
live_filter = {
|
||||
prefix = "[FILTER]: ",
|
||||
always_show_folders = true,
|
||||
},
|
||||
log = {
|
||||
enable = false,
|
||||
truncate = false,
|
||||
types = {
|
||||
all = false,
|
||||
config = false,
|
||||
copy_paste = false,
|
||||
dev = false,
|
||||
diagnostics = false,
|
||||
git = false,
|
||||
profile = false,
|
||||
watcher = false,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
local opts = { remap = false, silent = true }
|
||||
vim.keymap.set('n', "<leader>tt", function() nvim_tree.toggle(false, true) end, opts)
|
||||
@@ -0,0 +1,67 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
require('nvim-treesitter.configs').setup({
|
||||
-- One of "all", "maintained" (parsers with maintainers), or a list of languages
|
||||
ensure_installed = {
|
||||
"bash",
|
||||
"c",
|
||||
"cpp",
|
||||
"cmake",
|
||||
"css",
|
||||
"dockerfile",
|
||||
"go",
|
||||
"html",
|
||||
"java",
|
||||
"javascript",
|
||||
"json",
|
||||
"lua",
|
||||
"make",
|
||||
"ninja",
|
||||
"python",
|
||||
"rust",
|
||||
"toml",
|
||||
"vim",
|
||||
"yaml",
|
||||
"yang",
|
||||
},
|
||||
|
||||
indent = {
|
||||
enable = true
|
||||
},
|
||||
|
||||
-- Install languages synchronously (only applied to `ensure_installed`)
|
||||
sync_install = false,
|
||||
|
||||
-- List of parsers to ignore installing
|
||||
ignore_install = { },
|
||||
|
||||
highlight = {
|
||||
-- `false` will disable the whole extension
|
||||
enable = true,
|
||||
|
||||
-- list of language that will be disabled
|
||||
disable = { },
|
||||
|
||||
-- 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,
|
||||
},
|
||||
})
|
||||
-- vim.opt.foldmethod = "expr"
|
||||
-- vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
|
||||
@@ -0,0 +1,49 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
require('onedark').setup {
|
||||
-- Main options --
|
||||
style = 'darker', -- Default theme style. Choose between 'dark', 'darker', 'cool', 'deep', 'warm', 'warmer' and 'light'
|
||||
transparent = false, -- Show/hide background
|
||||
term_colors = true, -- Change terminal color as per the selected theme style
|
||||
ending_tildes = true, -- Show the end-of-buffer tildes. By default they are hidden
|
||||
-- toggle theme style ---
|
||||
toggle_style_key = '<leader>ts', -- Default keybinding to toggle
|
||||
toggle_style_list = {'dark', 'darker', 'cool', 'deep', 'warm', 'warmer', 'light'}, -- List of styles to toggle between
|
||||
|
||||
-- Change code style ---
|
||||
-- Options are italic, bold, underline, none
|
||||
-- You can configure multiple style with comma seperated, For e.g., keywords = 'italic,bold'
|
||||
code_style = {
|
||||
comments = 'italic',
|
||||
keywords = 'none',
|
||||
functions = 'none',
|
||||
strings = 'none',
|
||||
variables = 'none'
|
||||
},
|
||||
|
||||
-- Custom Highlights --
|
||||
colors = {}, -- Override default colors
|
||||
highlights = {}, -- Override highlight groups
|
||||
|
||||
-- Plugins Config --
|
||||
diagnostics = {
|
||||
darker = true, -- darker colors for diagnostic
|
||||
undercurl = true, -- use undercurl instead of underline for diagnostics
|
||||
background = true, -- use background color for virtual text
|
||||
},
|
||||
}
|
||||
require('onedark').load()
|
||||
@@ -0,0 +1,20 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
vim.g.sonokai_style = "atlantis"
|
||||
vim.g.sonokai_enable_italic = 1
|
||||
vim.g.sonokai_disable_italic_comment = 1
|
||||
vim.fn.execute("colorscheme sonokai")
|
||||
@@ -0,0 +1,17 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
vim.g.SuperTabDefaultCompletionType = "<c-n>"
|
||||
@@ -0,0 +1,69 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
vim.g.symbols_outline = {
|
||||
highlight_hovered_item = true,
|
||||
show_guides = true,
|
||||
auto_preview = true,
|
||||
position = 'left',
|
||||
relative_width = true,
|
||||
width = 25,
|
||||
auto_close = false,
|
||||
show_numbers = true,
|
||||
show_relative_numbers = true,
|
||||
show_symbol_details = true,
|
||||
preview_bg_highlight = 'Pmenu',
|
||||
keymaps = { -- These keymaps can be a string or a table for multiple keys
|
||||
close = {"<Esc>", "q"},
|
||||
goto_location = "<Cr>",
|
||||
focus_location = "o",
|
||||
hover_symbol = "<C-space>",
|
||||
toggle_preview = "K",
|
||||
rename_symbol = "r",
|
||||
code_actions = "a",
|
||||
},
|
||||
lsp_blacklist = {},
|
||||
symbol_blacklist = {},
|
||||
symbols = {
|
||||
File = {icon = "", hl = "TSURI"},
|
||||
Module = {icon = "", hl = "TSNamespace"},
|
||||
Namespace = {icon = "", hl = "TSNamespace"},
|
||||
Package = {icon = "", hl = "TSNamespace"},
|
||||
Class = {icon = "𝓒", hl = "TSType"},
|
||||
Method = {icon = "ƒ", hl = "TSMethod"},
|
||||
Property = {icon = "", hl = "TSMethod"},
|
||||
Field = {icon = "", hl = "TSField"},
|
||||
Constructor = {icon = "", hl = "TSConstructor"},
|
||||
Enum = {icon = "ℰ", hl = "TSType"},
|
||||
Interface = {icon = "ﰮ", hl = "TSType"},
|
||||
Function = {icon = "", hl = "TSFunction"},
|
||||
Variable = {icon = "", hl = "TSConstant"},
|
||||
Constant = {icon = "", hl = "TSConstant"},
|
||||
String = {icon = "𝓐", hl = "TSString"},
|
||||
Number = {icon = "#", hl = "TSNumber"},
|
||||
Boolean = {icon = "⊨", hl = "TSBoolean"},
|
||||
Array = {icon = "", hl = "TSConstant"},
|
||||
Object = {icon = "⦿", hl = "TSType"},
|
||||
Key = {icon = "🔐", hl = "TSType"},
|
||||
Null = {icon = "NULL", hl = "TSType"},
|
||||
EnumMember = {icon = "", hl = "TSField"},
|
||||
Struct = {icon = "𝓢", hl = "TSType"},
|
||||
Event = {icon = "🗲", hl = "TSType"},
|
||||
Operator = {icon = "+", hl = "TSOperator"},
|
||||
TypeParameter = {icon = "𝙏", hl = "TSParameter"}
|
||||
}
|
||||
}
|
||||
vim.api.nvim_set_keymap('n', '<leader>o', ':SymbolsOutlineOpen<CR>', { noremap = true, silent = true })
|
||||
@@ -0,0 +1,126 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
local builtin = require('telescope.builtin')
|
||||
|
||||
vim.keymap.set(
|
||||
'n', '<leader>ff', function() builtin.find_files({ hidden = true }) end,
|
||||
{ remap = false }
|
||||
)
|
||||
vim.keymap.set(
|
||||
'n', '<leader>fr', function() builtin.oldfiles({ hidden = true }) end,
|
||||
{ remap = false }
|
||||
)
|
||||
vim.keymap.set(
|
||||
'n', '<leader>fg', function()
|
||||
builtin.live_grep(
|
||||
{ additional_args = function(_) return { '--hidden' } end }
|
||||
)
|
||||
end, { remap = false }
|
||||
)
|
||||
vim.keymap.set(
|
||||
'n', '<leader>fb', function() builtin.buffers() end, { remap = false }
|
||||
)
|
||||
|
||||
--[[ local telescope = require('telescope')
|
||||
|
||||
telescope.setup {
|
||||
extensions = {
|
||||
command_palette = {
|
||||
{
|
||||
'File',
|
||||
{ 'entire selection (C-a)', ':call feedkeys("GVgg")' },
|
||||
{ 'save current file (C-s)', ':w' },
|
||||
{ 'save all files (C-A-s)', ':wa' },
|
||||
{ 'quit (C-q)', ':qa' },
|
||||
{
|
||||
'file browser (C-i)',
|
||||
':lua require\'telescope\'.extensions.file_browser.file_browser()',
|
||||
1
|
||||
},
|
||||
{
|
||||
'search word (A-w)',
|
||||
':lua require(\'telescope.builtin\').live_grep()',
|
||||
1
|
||||
},
|
||||
{
|
||||
'git files (A-f)',
|
||||
':lua require(\'telescope.builtin\').git_files()',
|
||||
1
|
||||
},
|
||||
{
|
||||
'files (C-f)',
|
||||
':lua require(\'telescope.builtin\').find_files()',
|
||||
1
|
||||
}
|
||||
},
|
||||
{
|
||||
'Help',
|
||||
{ 'tips', ':help tips' },
|
||||
{ 'cheatsheet', ':help index' },
|
||||
{ 'tutorial', ':help tutor' },
|
||||
{ 'summary', ':help summary' },
|
||||
{ 'quick reference', ':help quickref' },
|
||||
{
|
||||
'search help(F1)',
|
||||
':lua require(\'telescope.builtin\').help_tags()',
|
||||
1
|
||||
}
|
||||
},
|
||||
{
|
||||
'Vim',
|
||||
{ 'reload vimrc', ':source $MYVIMRC' },
|
||||
{ 'check health', ':checkhealth' },
|
||||
{
|
||||
'jumps (Alt-j)',
|
||||
':lua require(\'telescope.builtin\').jumplist()'
|
||||
},
|
||||
{ 'commands', ':lua require(\'telescope.builtin\').commands()' },
|
||||
{
|
||||
'command history',
|
||||
':lua require(\'telescope.builtin\').command_history()'
|
||||
},
|
||||
{
|
||||
'registers (A-e)',
|
||||
':lua require(\'telescope.builtin\').registers()'
|
||||
},
|
||||
{
|
||||
'colorshceme',
|
||||
':lua require(\'telescope.builtin\').colorscheme()',
|
||||
1
|
||||
},
|
||||
{
|
||||
'vim options',
|
||||
':lua require(\'telescope.builtin\').vim_options()'
|
||||
},
|
||||
{ 'keymaps', ':lua require(\'telescope.builtin\').keymaps()' },
|
||||
{ 'buffers', ':Telescope buffers' },
|
||||
{
|
||||
'search history (C-h)',
|
||||
':lua require(\'telescope.builtin\').search_history()'
|
||||
},
|
||||
{ 'paste mode', ':set paste!' },
|
||||
{ 'cursor line', ':set cursorline!' },
|
||||
{ 'cursor column', ':set cursorcolumn!' },
|
||||
{ 'spell checker', ':set spell!' },
|
||||
{ 'relative number', ':set relativenumber!' },
|
||||
{ 'search highlighting (F12)', ':set hlsearch!' }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
require('telescope').load_extension('command_palette') ]]
|
||||
@@ -0,0 +1,26 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
vim.g.tokyonight_style = "night"
|
||||
vim.g.tokyonight_terminal_colors = true
|
||||
vim.g.tokyonight_italic_comments = true
|
||||
vim.g.tokyonight_italic_keywords = true
|
||||
vim.g.tokyonight_sidebars = {'packer', 'terminal'}
|
||||
vim.g.tokyonight_dark_sidebar = true
|
||||
vim.g.tokyonight_dark_float = true
|
||||
vim.g.tokyonight_lualine_bold = true
|
||||
|
||||
vim.fn.execute("colorscheme tokyonight")
|
||||
@@ -0,0 +1,27 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
-- Trigger configuration. You need to change this to something other than <tab> if you use one of the following:
|
||||
-- - https://github.com/Valloric/YouCompleteMe
|
||||
-- - https://github.com/nvim-lua/completion-nvim
|
||||
-- vim.g.UltiSnipsExpandTrigger="<Tab>"
|
||||
-- vim.g.UltiSnipsJumpForwardTrigger="<C-l>"
|
||||
-- vim.g.UltiSnipsJumpBackwardTrigger="<C-h>"
|
||||
vim.g.UltiSnipsExpandTrigger = '<Plug>(ultisnips_expand)'
|
||||
vim.g.UltiSnipsJumpForwardTrigger = '<Plug>(ultisnips_jump_forward)'
|
||||
vim.g.UltiSnipsJumpBackwardTrigger = '<Plug>(ultisnips_jump_backward)'
|
||||
vim.g.UltiSnipsListSnippets = '<c-x><c-s>'
|
||||
vim.g.UltiSnipsRemoveSelectModeMappings = 0
|
||||
@@ -0,0 +1,17 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
vim.cmd("colorscheme codedark")
|
||||
@@ -0,0 +1,21 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
vim.g.vista_sidebar_position = 'vertical topleft'
|
||||
|
||||
vim.g.vista_icon_indent = { "╰─▸ ", "├─▸ " }
|
||||
vim.g.vista_default_executive = 'nvim_lsp'
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
-- Conservative style of the standard Visual Studio
|
||||
-- with reduced number of colors
|
||||
-- vim.g.codedark_conservative = 1
|
||||
-- vim.g.vscode_style = "dark"
|
||||
-- vim.g.vscode_transparency = 0
|
||||
-- vim.g.vscode_italic_comment = 1
|
||||
-- vim.g.vscode_disable_nvimtree_bg = true
|
||||
-- vim.fn.execute("colorscheme vscode")
|
||||
|
||||
-- local c = require('vscode.colors')
|
||||
require('vscode').setup({
|
||||
style = 'dark',
|
||||
|
||||
-- Enable transparent background
|
||||
transparent = false,
|
||||
|
||||
-- Enable italic comment
|
||||
italic_comments = false,
|
||||
|
||||
-- Disable nvim-tree background color
|
||||
disable_nvimtree_bg = false,
|
||||
|
||||
-- Override colors (see ./lua/vscode/colors.lua)
|
||||
-- color_overrides = {
|
||||
-- vscLineNumber = '#FFFFFF',
|
||||
-- },
|
||||
|
||||
-- Override highlight groups (see ./lua/vscode/theme.lua)
|
||||
group_overrides = {
|
||||
-- this supports the same val table as vim.api.nvim_set_hl
|
||||
-- use colors from this colorscheme by requiring vscode.colors!
|
||||
-- Cursor = { fg=c.vscDarkBlue, bg=c.vscLightGreen, bold=true },
|
||||
}
|
||||
})
|
||||
|
||||
require('vscode').load()
|
||||
@@ -0,0 +1,22 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
vim.g.winresizer_vert_resize = "5"
|
||||
vim.g.winresizer_horiz_resize = "5"
|
||||
vim.g.winresizer_start_key = ""
|
||||
|
||||
local opts = { remap = false, silent = true }
|
||||
vim.keymap.set('n', "<C-W>r", ":WinResizerStartResize<CR>", opts)
|
||||
@@ -0,0 +1,17 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
vim.keymap.set('n', '<C-W>m', ':WinShift<CR>', { remap = false })
|
||||
@@ -0,0 +1,65 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
local function term_close()
|
||||
-- Split previous buffer, switching to it
|
||||
vim.fn.execute("split " .. vim.fn.expand("#"))
|
||||
-- Close previous window (terminal)
|
||||
vim.fn.execute(vim.fn.winnr("#") .. "wincmd q")
|
||||
end
|
||||
vim.api.nvim_create_autocmd("TermClose", {
|
||||
pattern = "term://*",
|
||||
callback = term_close
|
||||
})
|
||||
|
||||
local function my_hl()
|
||||
-- example (default visual)
|
||||
-- highlight Visual guifg=NONE guibg=#264F78 gui=none
|
||||
-- highlight DiffDelete guifg=#414141 guibg=#1E1E1E gui=none
|
||||
-- highlight GitSignsChange guifg=#0C7D9D
|
||||
-- highlight IndentBlanklineContextChar guifg=#999999
|
||||
-- semshi (python highlights)
|
||||
-- highlight semshiLocal ctermfg=209 guifg=#ff875f
|
||||
-- highlight semshiGlobal guifg=#dcdcaa
|
||||
-- highlight semshiImported guifg=#4ec9b0
|
||||
-- highlight semshiParameter guifg=#9cdcfe
|
||||
-- highlight semshiParameterUnused guifg=#72a1bb
|
||||
-- highlight semshiFree ctermfg=218 guifg=#ffafd7
|
||||
-- highlight semshiBuiltin ctermfg=207 guifg=#dcdcaa
|
||||
-- highlight semshiAttribute ctermfg=49 guifg=#00ffaf
|
||||
-- highlight semshiSelf ctermfg=249 guifg=#dcdcaa
|
||||
-- highlight semshiUnresolved ctermfg=226 guifg=#ffff00 cterm=underline gui=underline
|
||||
-- highlight semshiSelected ctermfg=231 guifg=#ffffff ctermbg=161 guibg=#d7005f
|
||||
-- highlight semshiErrorSign ctermfg=231 guifg=#ffffff ctermbg=160 guibg=#d70000
|
||||
-- highlight semshiErrorChar ctermfg=231 guifg=#ffffff ctermbg=160 guibg=#d70000
|
||||
-- sign define semshiError text=E> texthl=semshiErrorSign
|
||||
end
|
||||
vim.api.nvim_create_augroup("my_colors", { clear = true })
|
||||
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
pattern = "*",
|
||||
callback = my_hl,
|
||||
group = "my_colors"
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "go",
|
||||
callback = function()
|
||||
vim.opt_local.tabstop = 4
|
||||
vim.opt_local.expandtab = false
|
||||
vim.opt_local.listchars = 'tab:▏ '
|
||||
vim.opt_local.list = true
|
||||
end
|
||||
})
|
||||
@@ -0,0 +1,33 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
vim.g.is_win = vim.fn.has('win32') == 1 or vim.fn.has('win64') == 1
|
||||
vim.g.is_linux = vim.fn.has('unix') == 1 and vim.fn.has('win64') ~= 1
|
||||
vim.g.is_mac = vim.fn.has('macunix') == 1
|
||||
|
||||
if vim.fn.executable('python3') then
|
||||
if vim.g.is_win then
|
||||
vim.g.python3_host_prog=string.gsub(vim.fn.exepath('python3'), '.exe$', '')
|
||||
elseif vim.g.is_linux or vim.g.is_mac then
|
||||
vim.g.python3_host_prog=vim.fn.exepath('python3')
|
||||
end
|
||||
else
|
||||
error("Python 3 executable not found! You must install Python 3 and set its PATH correctly!")
|
||||
end
|
||||
|
||||
vim.g.mapleader = " "
|
||||
vim.g.vimsyn_embed = "1"
|
||||
vim.fn.execute("language en_US.utf-8")
|
||||
@@ -0,0 +1,80 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
local opts = { remap = false, silent = true }
|
||||
local opts_expr = { remap = false, silent = true, expr = true }
|
||||
|
||||
--- Tab mappings ---
|
||||
-- vim.keymap.set('n', "tn", ":tabnew <BAR> NvimTreeOpen<CR>", opts)
|
||||
vim.keymap.set('n', "tn", ":tabnew<CR>", opts)
|
||||
vim.keymap.set('n', "tq", ":tabclose<CR>", opts)
|
||||
-- switch tabs with Ctrl+PgUp/Ctrl+PgDwn (default vim mapping)
|
||||
|
||||
--- Window mappings ---
|
||||
vim.keymap.set('n', "<A-h>", ":wincmd h<CR>", opts)
|
||||
vim.keymap.set('n', "<A-j>", ":wincmd j<CR>", opts)
|
||||
vim.keymap.set('n', "<A-k>", ":wincmd k<CR>", opts)
|
||||
vim.keymap.set('n', "<A-l>", ":wincmd l<CR>", opts)
|
||||
-- Open new window in horizontal split
|
||||
vim.keymap.set('n', "<C-w>h", ":new<CR>", opts)
|
||||
-- Open new window in vertical split
|
||||
vim.keymap.set('n', "<C-w>v", ":vnew<CR>", opts)
|
||||
-- Open new window in horizontal split at bottom
|
||||
vim.keymap.set('n', "<C-w><leader>", ":bo new<CR>", opts)
|
||||
-- Close buffer and window
|
||||
vim.keymap.set('n', "<C-w>q", ":bd<CR>", opts)
|
||||
|
||||
--- Buffer mappings ---
|
||||
-- Navigate up/down half a screen
|
||||
vim.keymap.set({'n', 'v'}, "<C-j>", "<C-d>", opts)
|
||||
vim.keymap.set({'n', 'v'}, "<C-k>", "<C-u>", opts)
|
||||
-- Center cursorline
|
||||
vim.keymap.set('n', "<C-Space>", "zz", opts)
|
||||
-- Save buffer
|
||||
vim.keymap.set('n', "<C-s>", ":w<CR>", opts)
|
||||
-- Cycle buffers
|
||||
vim.keymap.set('n', "<C-End>", ":BufferLineCycleNext<CR>", opts)
|
||||
vim.keymap.set('n', "<C-Home>", ":BufferLineCyclePrev<CR>", opts)
|
||||
-- Close buffer without closing window
|
||||
vim.keymap.set('n', "<leader>q", ":bp<bar>sp<bar>bn<bar>bd<CR>", opts)
|
||||
|
||||
--- General mappings ---
|
||||
-- Remap some swedish keys for easier use
|
||||
vim.keymap.set('n', "ö", "}", { remap = true })
|
||||
vim.keymap.set('v', "ö", "}", { remap = true })
|
||||
vim.keymap.set('n', "ä", "{", { remap = true })
|
||||
vim.keymap.set('v', "ä", "{", { remap = true })
|
||||
vim.keymap.set('n', ",", "]", { remap = true })
|
||||
vim.keymap.set('n', ".", "[", { remap = true })
|
||||
-- yank/put using named register
|
||||
vim.keymap.set('n', '<leader>y', '"0y', opts)
|
||||
vim.keymap.set('v', '<leader>y', '"0y', opts)
|
||||
vim.keymap.set('n', '<leader>p', '"0p', opts)
|
||||
vim.keymap.set('v', '<leader>p', '"0p', opts)
|
||||
-- Allow exiting insert mode in terminal by hitting <ESC>
|
||||
vim.keymap.set('t', "<Esc>", "<C-\\><C-n>", opts)
|
||||
-- Navigate forward/backwards
|
||||
vim.keymap.set('n', "<C-l>", "<C-i>", opts)
|
||||
vim.keymap.set('n', "<C-h>", "<C-o>", opts)
|
||||
-- Use :diffput/get instead of normal one to allow staging visual selection
|
||||
vim.keymap.set('n', "<leader>dp", "&diff ? ':diffput<CR>' : '<leader>dp'", opts_expr)
|
||||
vim.keymap.set('v', "<leader>dp", "&diff ? ':diffput<CR>' : '<leader>dp'", opts_expr)
|
||||
vim.keymap.set('n', "<leader>do", "&diff ? ':diffget<CR>' : '<leader>do'", opts_expr)
|
||||
vim.keymap.set('v', "<leader>do", "&diff ? ':diffget<CR>' : '<leader>do'", opts_expr)
|
||||
|
||||
-- Remove default mappings
|
||||
vim.keymap.set('', "<C-LeftMouse>", "")
|
||||
vim.keymap.set('', "q", "")
|
||||
@@ -0,0 +1,89 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
vim.opt.cursorline = true
|
||||
vim.opt.number = true
|
||||
vim.opt.relativenumber = true
|
||||
vim.opt.mouse = "a"
|
||||
vim.opt.mousemodel = "extend"
|
||||
vim.opt.fillchars:append("diff: ")
|
||||
vim.opt.splitbelow = true
|
||||
vim.opt.splitright = true
|
||||
-- set tabline=%!MyTabLine()
|
||||
vim.opt.tabstop = 8
|
||||
vim.opt.softtabstop = 4
|
||||
vim.opt.expandtab = true
|
||||
vim.opt.shiftwidth = 4
|
||||
vim.opt.smarttab = false
|
||||
-- Folds are configured in nvim-treesitter, but this needs to be set before
|
||||
-- loading the first buffer which is not possible in nvim-treesitter.lua due to
|
||||
-- lazy loading (I think)
|
||||
vim.opt.foldlevelstart = 99
|
||||
vim.opt.foldmethod = "indent"
|
||||
vim.opt.foldignore = ""
|
||||
vim.opt.guifont = "JetBrains Mono:11"
|
||||
vim.opt.completeopt:append({ "menu", "menuone", "preview", "noinsert" })
|
||||
-- Max number of items
|
||||
vim.opt.pumheight = 20
|
||||
-- pseudo transparency for completion menu
|
||||
vim.opt.pumblend = 10
|
||||
-- pseudo transparency for floating window
|
||||
vim.opt.winblend = 5
|
||||
-- set nowrap
|
||||
vim.opt.clipboard:append("unnamedplus")
|
||||
vim.opt.matchpairs:append({ "<:>", "':'", "\":\"" })
|
||||
vim.opt.fileencoding = "utf-8"
|
||||
-- Only relevant with wrap enabled (default)
|
||||
vim.opt.linebreak = true
|
||||
vim.opt.breakindent = true
|
||||
vim.opt.showbreak = "↪"
|
||||
-- Minimum amount of lines to show offset +/- to cursorline
|
||||
vim.opt.scrolloff = 3
|
||||
vim.opt.visualbell = true
|
||||
vim.opt.errorbells = false
|
||||
-- Persistent undo even after you close a file and re-open it
|
||||
vim.opt.undofile = true
|
||||
-- Insert mode key word completion setting, see :h 'compelete'
|
||||
-- and https://medium.com/usevim/set-complete-e76b9f196f0f#:~:text=When%20in%20Insert%20mode%2C%20you,%2D%2D%20CTRL%2DN%20goes%20backwards.
|
||||
-- kspell is only relevant if ':set spell' is toggled on, e.g. when editing
|
||||
-- documents
|
||||
vim.opt.complete:append("kspell")
|
||||
vim.opt.complete:remove({ "w", "b", "u", "t" })
|
||||
vim.opt.spelllang = "en"
|
||||
-- Align indent to next multiple value of shiftwidth.
|
||||
-- E.g., only insert as many spaces necessary for reaching the next shiftwidth
|
||||
vim.opt.shiftround = true
|
||||
-- Allow virtualedit (editing on empty spaces) in visual block mode (Ctrl+V)
|
||||
vim.opt.virtualedit = "block"
|
||||
-- True color support. Avoid if terminal does not support it.
|
||||
vim.opt.termguicolors = true
|
||||
vim.opt.signcolumn = "auto"
|
||||
-- Diff options
|
||||
vim.opt.diffopt = {}
|
||||
-- Use vertical split by default
|
||||
vim.opt.diffopt:append("vertical")
|
||||
-- Insert filler lines
|
||||
vim.opt.diffopt:append("filler")
|
||||
-- Execute :diffoff when only one diff window remain
|
||||
vim.opt.diffopt:append("closeoff")
|
||||
-- Use internal diff library
|
||||
vim.opt.diffopt:append("internal")
|
||||
-- These make diffs easier to read, please see the following:
|
||||
-- https://vimways.org/2018/the-power-of-diff/
|
||||
vim.opt.diffopt:append({ "indent-heuristic", "algorithm:histogram" })
|
||||
vim.fn.execute("filetype plugin on")
|
||||
vim.opt.hlsearch = false
|
||||
vim.opt.laststatus = 3
|
||||
@@ -0,0 +1,23 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
-- requires shellcheck also (for linting)
|
||||
|
||||
return {
|
||||
cmd = { 'bash-language-server', 'start' },
|
||||
cmd_env = { GLOB_PATTERN = '*@(.sh|.inc|.bash|.command)' },
|
||||
single_file_support = true
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
return {
|
||||
cmd = {
|
||||
'clangd',
|
||||
'--clang-tidy',
|
||||
'--enable-config',
|
||||
'--log=verbose'
|
||||
},
|
||||
single_file_support = true,
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
return {
|
||||
cmd = { 'cmake-language-server' },
|
||||
single_file_support = true,
|
||||
init_options = {
|
||||
buildDirectory = "build"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
return {
|
||||
cmd = { 'diagnostic-languageserver', '--stdio' },
|
||||
single_file_support = true,
|
||||
-- For more info see https://github.com/iamcco/diagnostic-languageserver
|
||||
init_options = {
|
||||
filetypes = { python = 'flake8', lua = 'luaFormatter' },
|
||||
linters = {
|
||||
-- some help from this:
|
||||
-- https://github.com/creativenull/diagnosticls-configs-nvim/blob/main/lua/diagnosticls-configs/linters/flake8.lua
|
||||
flake8 = {
|
||||
command = 'flake8',
|
||||
args = {
|
||||
'--config',
|
||||
'tox.ini',
|
||||
'--format',
|
||||
'%(row)d,%(col)d,%(code).1s,%(code)s: %(text)s',
|
||||
'-'
|
||||
},
|
||||
rootPatterns = { 'Pipfile', '.git', 'tox.ini' },
|
||||
isStdout = true,
|
||||
isStderr = false,
|
||||
debounce = 100,
|
||||
offsetLine = 0,
|
||||
offsetColumn = 0,
|
||||
sourceName = 'flake8',
|
||||
formatLines = 1,
|
||||
formatPattern = {
|
||||
[[(\d+),(\d+),([A-Z]),(.*)(\r|\n)*$]],
|
||||
{ line = 1, column = 2, security = 3, message = { 4 } }
|
||||
},
|
||||
securities = {
|
||||
-- Available securities are { 'error', 'warning', 'hint', 'info' }
|
||||
E = 'error',
|
||||
W = 'warning',
|
||||
B = 'hint',
|
||||
F = 'error',
|
||||
D = 'info'
|
||||
}
|
||||
}
|
||||
},
|
||||
formatFiletypes = {
|
||||
python = { 'black', 'isort' },
|
||||
lua = { 'luaFormatter' },
|
||||
sh = { 'shfmt' }
|
||||
},
|
||||
formatters = {
|
||||
black = {
|
||||
sourceName = 'black',
|
||||
command = 'black',
|
||||
args = {
|
||||
'--stdin-filename',
|
||||
'%filename',
|
||||
'-t',
|
||||
'py39',
|
||||
'--quiet',
|
||||
'-'
|
||||
},
|
||||
rootPatterns = { 'Pipfile', '.git', 'tox.ini' },
|
||||
isStdout = true,
|
||||
isStderr = false,
|
||||
ignoreExitCode = false
|
||||
},
|
||||
isort = {
|
||||
sourceName = 'isort',
|
||||
command = 'isort',
|
||||
args = { '--quiet', '-' },
|
||||
rootPatterns = { 'Pipfile', '.git', 'tox.ini' },
|
||||
isStdout = true,
|
||||
isStderr = false,
|
||||
ignoreExitCode = false
|
||||
},
|
||||
luaFormatter = {
|
||||
sourceName = 'luaFormatter',
|
||||
command = 'lua-format',
|
||||
isStdout = true,
|
||||
isStderr = false,
|
||||
ignoreExitCode = false,
|
||||
args = {
|
||||
'--column-limit',
|
||||
'80', -- Column limit of one line
|
||||
'--indent-width',
|
||||
'4', -- Number of spaces used for indentation
|
||||
-- '--use-tab', -- Use tab for indentation
|
||||
'--no-use-tab', -- Do not use tab for indentation
|
||||
'--tab-width',
|
||||
'4', -- Number of spaces used per tab
|
||||
'--continuation-indent-width',
|
||||
'4', -- Indent width for continuations line
|
||||
'--spaces-before-call',
|
||||
'1', -- Space on function calls
|
||||
'--keep-simple-control-block-one-line', -- Keep block in one line
|
||||
-- '--no-keep-simple-control-block-one-line', -- Do not keep block in one line
|
||||
'--keep-simple-function-one-line', -- Keep function in one line
|
||||
-- '--no-keep-simple-function-one-line', -- Do not keep function in one line
|
||||
'--align-args', -- Align the arguments
|
||||
-- '--no-align-args', -- Do not align the arguments
|
||||
'--break-after-functioncall-lp', -- Break after '(' of function call
|
||||
-- '--no-break-after-functioncall-lp', -- Do not break after '(' of function call
|
||||
'--break-before-functioncall-rp', -- Break before ')' of function call
|
||||
-- '--no-break-before-functioncall-rp', -- Do not break before ')' of function call
|
||||
-- '--spaces-inside-functioncall-parens', -- Put spaces on the inside of parens in function calls
|
||||
'--no-spaces-inside-functioncall-parens', -- Do not put spaces on the inside of parens in function calls
|
||||
-- '--spaces-inside-functiondef-parens', -- Put spaces on the inside of parens in function headers
|
||||
'--no-spaces-inside-functiondef-parens', -- Do not put spaces on the inside of parens in function headers
|
||||
'--align-parameter', -- Align the parameters
|
||||
-- '--no-align-parameter', -- Do not align the parameters
|
||||
'--chop-down-parameter', -- Chop down all parameters
|
||||
-- '--no-chop-down-parameter', -- Do not chop down all parameters
|
||||
'--break-after-functiondef-lp', -- Break after '(' of function def
|
||||
-- '--no-break-after-functiondef-lp', -- Do not break after '(' of function def
|
||||
'--break-before-functiondef-rp', -- Break before ')' of function def
|
||||
-- '--no-break-before-functiondef-rp', -- Do not break before ')' of function def
|
||||
'--align-table-field', -- Align fields of table
|
||||
-- '--no-align-table-field', -- Do not align fields of table
|
||||
'--break-after-table-lb', -- Break after '{' of table
|
||||
-- '--no-break-after-table-lb', -- Do not break after '{' of table
|
||||
'--break-before-table-rb', -- Break before '}' of table
|
||||
-- '--no-break-before-table-rb', -- Do not break before '}' of table
|
||||
'--chop-down-table', -- Chop down any table
|
||||
-- '--no-chop-down-table', -- Do not chop down any table
|
||||
'--chop-down-kv-table', -- Chop down table if table contains key
|
||||
-- '--no-chop-down-kv-table', -- Do not chop down table if table contains key
|
||||
'--table-sep',
|
||||
',', -- Character to separate table fields
|
||||
'--column-table-limit',
|
||||
'80', -- Column limit of each line of a table
|
||||
-- '--extra-sep-at-table-end', -- Add a extra field separator
|
||||
'--no-extra-sep-at-table-end', -- Do not add a extra field separator
|
||||
'--spaces-inside-table-braces', -- Put spaces on the inside of braces in table constructors
|
||||
-- '--no-spaces-inside-table-braces', -- Do not put spaces on the inside of braces in table constructors
|
||||
'--break-after-operator', -- Put break after operators
|
||||
-- '--no-break-after-operator', -- Do not put break after operators
|
||||
'--double-quote-to-single-quote', -- Transform string literals to use single quote
|
||||
-- '--no-double-quote-to-single-quote', -- Do not transform string literals to use single quote
|
||||
-- '--single-quote-to-double-quote', -- Transform string literals to use double
|
||||
'--no-single-quote-to-double-quote', -- Do not transform string literals to use double
|
||||
'--spaces-around-equals-in-field', -- Put spaces around the equal sign in key/value fields
|
||||
-- '--no-spaces-around-equals-in-field', -- Do not put spaces around the equal sign in key/value fields
|
||||
'--line-breaks-after-function-body',
|
||||
'1', -- Line brakes after function body
|
||||
'--line-separator',
|
||||
'input' -- input(determined by the input content),
|
||||
-- os(Use line ending of the current Operating system),
|
||||
-- lf(Unix style "\n"),
|
||||
-- crlf(Windows style "\r\n"),
|
||||
-- cr(classic Max style "\r")
|
||||
}
|
||||
},
|
||||
shfmt = {
|
||||
sourceName = 'shfmt',
|
||||
command = 'shfmt',
|
||||
args = { '-s', '-i', '4', '-ci' },
|
||||
rootPatterns = { 'Pipfile', '.git', 'tox.ini' },
|
||||
isStdout = true,
|
||||
isStderr = false,
|
||||
ignoreExitCode = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
return {
|
||||
cmd = { "golangci-lint-langserver" },
|
||||
init_options = {
|
||||
command = { "golangci-lint", "run", "--out-format", "json" }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
return {
|
||||
cmd = { "gopls", "serve" },
|
||||
-- https://github.com/golang/tools/blob/master/gopls/doc/settings.md
|
||||
settings = {
|
||||
gopls = {
|
||||
gofumpt = true,
|
||||
codelenses = {
|
||||
gc_details = true,
|
||||
generate = true,
|
||||
regenerate_cgo = true,
|
||||
run_vulncheck_exp = true,
|
||||
tidy = true,
|
||||
upgrade_dependency = true,
|
||||
vendor = true
|
||||
},
|
||||
usePlaceholders = true,
|
||||
analyses = {
|
||||
asmdecl = true,
|
||||
assign = true,
|
||||
atomic = true,
|
||||
atomicalign = true,
|
||||
bools = true,
|
||||
buildtag = true,
|
||||
cgocall = true,
|
||||
composites = true,
|
||||
copylocks = true,
|
||||
deepequalerrors = true,
|
||||
embed = true,
|
||||
errorsas = true,
|
||||
fieldalignment = true,
|
||||
httpresponse = true,
|
||||
ifaceassert = true,
|
||||
infertypeargs = true,
|
||||
loopclosure = true,
|
||||
lostcancel = true,
|
||||
nilfunc = true,
|
||||
nilness = true,
|
||||
printf = true,
|
||||
shadow = true,
|
||||
shift = true,
|
||||
simplifycompositelit = true,
|
||||
simplifyrange = true,
|
||||
simplifyslice = true,
|
||||
sortslice = true,
|
||||
stdmethods = true,
|
||||
stringintconv = true,
|
||||
structtag = true,
|
||||
testinggoroutine = true,
|
||||
tests = true,
|
||||
timeformat = true,
|
||||
unmarshal = true,
|
||||
unreachable = true,
|
||||
unsafeptr = true,
|
||||
unusedparams = true,
|
||||
unusedresult = true,
|
||||
unusedwrite = true,
|
||||
useany = true,
|
||||
fillreturns = true,
|
||||
nonewvars = true,
|
||||
noresultvalues = true,
|
||||
undeclaredname = true,
|
||||
unusedvariable = true,
|
||||
fillstruct = true,
|
||||
stubmethods = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
return {
|
||||
cmd = {
|
||||
'java', '-jar',
|
||||
'/usr/share/java/groovy-language-server/groovy-language-server-all.jar'
|
||||
},
|
||||
single_file_support = true
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
return {
|
||||
cmd = { 'jedi-language-server' },
|
||||
single_file_support = true,
|
||||
-- For more info see https://github.com/pappasam/jedi-language-server#configurationSources
|
||||
-- and https://github.com/pappasam/coc-jedi#configuration (good descriptions)
|
||||
init_options = {
|
||||
completion = {
|
||||
-- If your language client supports CompletionItem snippets but you don't like them,
|
||||
-- disable them by setting this option to true.
|
||||
-- type: boolean
|
||||
-- default: false
|
||||
disableSnippets = false,
|
||||
-- Return all completion results in initial completion request.
|
||||
-- Set to true if your language client does not support completionItem/resolve.
|
||||
-- type: boolean
|
||||
-- default: false
|
||||
resolveEagerly = false,
|
||||
-- A list of regular expressions.
|
||||
-- If any regular expression in ignorePatterns matches a completion's name,
|
||||
-- that completion item is not returned to the client.
|
||||
-- type: string[]
|
||||
-- default: []
|
||||
-- In general, you should prefer the default value for this option.
|
||||
-- Jedi is very good at filtering values for end users.
|
||||
-- That said, there are situations where IDE developers,
|
||||
-- or some programmers in some code bases, may want to filter some completions by name.
|
||||
-- This flexible interface is provided to accommodate these advanced use cases.
|
||||
ignorePatterns = {}
|
||||
},
|
||||
-- Built-in diagnostics seem to be very basic,
|
||||
-- to the point where you are wondering if it's even active.
|
||||
-- Will use iamcco/diagnostic-languageserver instead.
|
||||
diagnostics = {
|
||||
-- Enables (or disables) diagnostics provided by Jedi
|
||||
-- type: boolean
|
||||
-- default: true
|
||||
enable = false,
|
||||
-- When diagnostics are enabled, run on document open
|
||||
-- type: boolean
|
||||
-- default: true
|
||||
didOpen = true,
|
||||
-- When diagnostics are enabled, run on in-memory document change
|
||||
-- (eg, while you're editing, without needing to save to disk)
|
||||
-- type: boolean
|
||||
-- default: true
|
||||
didChange = true,
|
||||
-- When diagnostics are enabled, run on document save (to disk)
|
||||
-- type: boolean
|
||||
-- default: true
|
||||
didSave = true
|
||||
},
|
||||
hover = {
|
||||
-- Enable (or disable) all hover text.
|
||||
-- If set to false, will cause the hover method not to be registered to the language server.
|
||||
-- type: boolean
|
||||
-- default: true
|
||||
enable = true,
|
||||
-- disable.[jedi-type].all
|
||||
-- Disable all hover text of jedi-type specified.
|
||||
-- type: boolean
|
||||
-- default: false
|
||||
-- disable.[jedi-type].names
|
||||
-- Disable hover text identified by name in list of jedi-type specified.
|
||||
-- type: string[]
|
||||
-- default: []
|
||||
-- disable.[jedi-type].fullNames
|
||||
-- Disable hover text identified by the fully qualified name in list of jedi-type specified.
|
||||
-- If no fully qualified name can be found, jedi-language-server will default to
|
||||
-- the name to prevent any unexpected behavior for users
|
||||
-- (relevant for jedi types like keywords that don't have full names).
|
||||
-- type: string[]
|
||||
-- default: []
|
||||
disable = {
|
||||
class = { all = false, names = {}, fullNames = {} },
|
||||
-- Need to escape lua keyword
|
||||
['function'] = { all = false, names = {}, fullNames = {} },
|
||||
instance = { all = false, names = {}, fullNames = {} },
|
||||
keyword = { all = false, names = {}, fullNames = {} },
|
||||
module = { all = false, names = {}, fullNames = {} },
|
||||
param = { all = false, names = {}, fullNames = {} },
|
||||
path = { all = false, names = {}, fullNames = {} },
|
||||
property = { all = false, names = {}, fullNames = {} },
|
||||
statement = { all = false, names = {}, fullNames = {} }
|
||||
}
|
||||
},
|
||||
jediSettings = {
|
||||
-- Modules that jedi will directly import without analyzing.
|
||||
-- Improves autocompletion but loses goto definition.
|
||||
-- type: string[]
|
||||
-- default: []
|
||||
-- If you're noticing that modules like numpy and pandas are taking a super long time to load
|
||||
-- and you value completions / signatures over goto definition,
|
||||
-- I recommend using this option like this:
|
||||
-- autoImportModules = { "numpy", "pandas" },
|
||||
autoImportModules = {},
|
||||
-- Completions are by default case insensitive.
|
||||
-- Set to false to make completions case sensitive.
|
||||
-- type: boolean
|
||||
-- default: true
|
||||
caseInsensitiveCompletion = true,
|
||||
-- Print jedi debugging messages to stderr.
|
||||
-- type: boolean
|
||||
-- default: false
|
||||
debug = false
|
||||
},
|
||||
-- The preferred MarkupKind for all jedi-language-server messages that take MarkupContent.
|
||||
-- type: string
|
||||
-- accepted values: "markdown", "plaintext"
|
||||
-- If omitted, jedi-language-server defaults to the client-preferred configuration.
|
||||
-- If there is no client-preferred configuration, jedi language server users "plaintext".
|
||||
-- markupKindPreferred = "markdown",
|
||||
workspace = {
|
||||
-- Add additional paths for Jedi's analysis.
|
||||
-- Useful with vendor directories, packages in a non-standard location, etc.
|
||||
-- You probably won't need to use this, but you'll be happy it's here when you need it!
|
||||
-- type: string[]
|
||||
-- default: []
|
||||
-- Non-absolute paths are relative to your project root.
|
||||
-- For example, let's say your Python project is structured like this:
|
||||
-- ├── funky
|
||||
-- │ └── haha.py
|
||||
-- ├── poetry.lock
|
||||
-- ├── pyproject.toml
|
||||
-- └── test.py
|
||||
-- Assume that funky/haha.py contains 1 line, x = 12,
|
||||
-- and your build system does some wizardry that makes haha importable just like os or pathlib.
|
||||
-- In this example, if you want to have this same non-standard behavior with jedi-language-server,
|
||||
-- put the following:
|
||||
-- extraPaths = { "funky" }
|
||||
-- When editing test.py, you'll get completions, goto definition,
|
||||
-- and all other lsp features for the line `from haha import ....`
|
||||
-- Again, you probably don't need this.
|
||||
extraPaths = {},
|
||||
symbols = {
|
||||
-- Performance optimization that sets names of folders that are ignored for workspace/symbols.
|
||||
-- type: string[]
|
||||
-- default: { ".nox", ".tox", ".venv", "__pycache__", "venv" }
|
||||
-- If you manually set this option, it overrides the default.
|
||||
-- Setting it to an empty array will result in no ignored folders.
|
||||
ignoreFolders = {
|
||||
'.nox', '.tox', '.venv', '__pycache__', 'venv',
|
||||
'artifacts', 'config', '.vscode', '.pytest_cache',
|
||||
'build', 'scripts', 'incoax_tests.egg-info',
|
||||
'node_modules'
|
||||
},
|
||||
-- Maximum number of symbols returned by a call to workspace/symbols.
|
||||
-- type: number
|
||||
-- default: 20
|
||||
-- A value less than or equal to zero removes the maximum
|
||||
-- and allows jedi-language-server to return all workplace symbols found by jedi.
|
||||
maxSymbols = 20
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
return {
|
||||
cmd = { 'lemminx' },
|
||||
single_file_support = true,
|
||||
init_options = {
|
||||
settings = {
|
||||
xml = {
|
||||
trace = { server = 'verbose' },
|
||||
catalogs = {},
|
||||
logs = {
|
||||
client = false,
|
||||
file = '/home/oscar/lsp4xml.log'
|
||||
},
|
||||
format = {
|
||||
splitAttributes = true,
|
||||
joinCDATALines = false,
|
||||
joinContentLines = true,
|
||||
joinCommentLines = false,
|
||||
spaceBeforeEmptyCloseLine = false,
|
||||
enabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
local runtime_path = vim.split(package.path, ';')
|
||||
table.insert(runtime_path, 'lua/?.lua')
|
||||
table.insert(runtime_path, 'lua/?/init.lua')
|
||||
|
||||
-- spec: https://luals.github.io/wiki/settings/
|
||||
|
||||
return {
|
||||
cmd = { 'lua-language-server' },
|
||||
single_file_support = true,
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
||||
version = 'LuaJIT',
|
||||
-- Setup your lua path
|
||||
path = runtime_path
|
||||
},
|
||||
diagnostics = {
|
||||
-- Get the language server to recognize the `vim` global
|
||||
globals = { 'vim' }
|
||||
},
|
||||
workspace = {
|
||||
-- Make the server aware of Neovim runtime files
|
||||
library = vim.api.nvim_get_runtime_file('', true),
|
||||
checkThirdParty = false
|
||||
},
|
||||
-- Do not send telemetry data containing a randomized but unique identifier
|
||||
telemetry = { enable = false }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
return {
|
||||
cmd = { 'pylsp' },
|
||||
single_file_support = true,
|
||||
-- Reference: https://github.com/python-lsp/python-lsp-server/blob/develop/CONFIGURATION.md
|
||||
settings = {
|
||||
pylsp = {
|
||||
-- configurationSources = { "flake8", "jedi_completion", "jedi_definition", "jedi_hover", "jedi_references", "jedi_signature_help", "jedi_symbols" },
|
||||
plugins = {
|
||||
flake8 = {
|
||||
config = 'tox.ini',
|
||||
enabled = true
|
||||
-- executable = "flake8"
|
||||
},
|
||||
pyls_isort = { enabled = true },
|
||||
jedi_completion = {
|
||||
enabled = true,
|
||||
include_params = false,
|
||||
include_class_objects = true,
|
||||
fuzzy = true,
|
||||
eager = true,
|
||||
resolve_at_most = 25,
|
||||
cache_for = {
|
||||
'pandas',
|
||||
'numpy',
|
||||
'tensorflow',
|
||||
'matplotlib'
|
||||
}
|
||||
},
|
||||
jedi_definition = {
|
||||
enabled = true,
|
||||
follow_imports = true,
|
||||
follow_builtin_imports = true
|
||||
},
|
||||
jedi_hover = { enabled = true },
|
||||
jedi_references = { enabled = true },
|
||||
jedi_signature_help = { enabled = true },
|
||||
jedi_symbols = {
|
||||
enabled = true,
|
||||
all_scopes = true,
|
||||
include_import_symbols = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
return {
|
||||
cmd = { 'pyright-langserver', '--stdio' },
|
||||
single_file_support = true,
|
||||
-- see https://github.com/microsoft/pyright/blob/main/docs/configuration.md
|
||||
-- and https://github.com/fannheyward/coc-pyright
|
||||
settings = {
|
||||
python = {
|
||||
disableCompletion = false,
|
||||
disableDiagnostics = false,
|
||||
analysis = {
|
||||
autoImportCompletions = true,
|
||||
autoSearchPaths = true,
|
||||
diagnosticMode = 'workspace',
|
||||
stubPath = 'typings',
|
||||
typeschedPaths = {},
|
||||
diagnosticSeverityOverrides = {},
|
||||
typeCheckingMode = 'off',
|
||||
useLibraryCodeForTypes = true
|
||||
},
|
||||
completion = { importSupport = true, snippetSupport = true }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
return {
|
||||
cmd = { 'rust-analyzer' },
|
||||
settings = {
|
||||
-- https://github.com/rust-lang/rust-analyzer/blob/master/docs/user/generated_config.adoc
|
||||
['rust-analyzer'] = {
|
||||
cargo = {
|
||||
-- Extra environment variables that will be set when running cargo, rustc
|
||||
-- or other commands within the workspace. Useful for setting RUSTFLAGS.
|
||||
extraEnv = {
|
||||
OPENSSL_INCLUDE_DIR = '/usr/include/openssl-1.0/',
|
||||
OPENSSL_LIB_DIR = '/usr/lib/openssl-1.0/'
|
||||
}
|
||||
}
|
||||
--[[ inlayHints = {
|
||||
closingBraceHints = {
|
||||
-- Whether to show inlay hints after a closing `}` to indicate what item it belongs to.
|
||||
enable = false
|
||||
},
|
||||
} ]]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,287 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
local P = {}
|
||||
|
||||
P._filetypes = nil
|
||||
P._language_servers = nil
|
||||
|
||||
P.capabilities = {}
|
||||
|
||||
P.spec = require('lsp.spec')
|
||||
|
||||
function P._setup_diagnostic()
|
||||
vim.diagnostic.config({
|
||||
underline = true,
|
||||
signs = true,
|
||||
virtual_text = false,
|
||||
-- virtual_text = {
|
||||
-- format = function(diagnostic)
|
||||
-- return string.format("%s: %s", diagnostic.user_data.lsp.code, diagnostic.message)
|
||||
-- end
|
||||
-- },
|
||||
float = {
|
||||
show_header = false,
|
||||
source = 'if_many',
|
||||
border = 'rounded',
|
||||
focusable = false,
|
||||
format = function(diagnostic)
|
||||
return string.format('%s', diagnostic.message)
|
||||
end
|
||||
|
||||
},
|
||||
update_in_insert = false, -- default to false
|
||||
severity_sort = true -- default to false
|
||||
})
|
||||
-- Change diagnostic icons
|
||||
vim.fn.sign_define('DiagnosticSignError', {
|
||||
text = 'E',
|
||||
texthl = 'DiagnosticSignError',
|
||||
-- culhl = 'DiagnosticSignError',
|
||||
numhl = 'DiagnosticSignError'
|
||||
-- linehl = 'LspDiagnosticsUnderlineError'
|
||||
})
|
||||
vim.fn.sign_define('DiagnosticSignWarn', {
|
||||
text = 'W',
|
||||
texthl = 'DiagnosticSignWarn',
|
||||
-- culhl = 'DiagnosticSignWarn',
|
||||
numhl = 'DiagnosticSignWarn'
|
||||
-- linehl = 'LspDiagnosticsUnderlineWarning'
|
||||
})
|
||||
vim.fn.sign_define('DiagnosticSignHint', {
|
||||
text = 'H',
|
||||
texthl = 'DiagnosticSignHint',
|
||||
-- culhl = 'DiagnosticSignHint',
|
||||
numhl = 'DiagnosticSignHint'
|
||||
-- linehl = 'LspDiagnosticsUnderlineHint'
|
||||
})
|
||||
vim.fn.sign_define('DiagnosticSignInfo', {
|
||||
text = 'i',
|
||||
texthl = 'DiagnosticSignInfo',
|
||||
-- culhl = 'DiagnosticSignInfo',
|
||||
numhl = 'DiagnosticSignInfo'
|
||||
-- linehl = 'LspDiagnosticsUnderlineInfo'
|
||||
})
|
||||
|
||||
-- Change some highlights
|
||||
-- vim.cmd('highlight DiagnosticUnderlineError guifg=' .. utils.get_hl('DiagnosticError').foreground)
|
||||
-- vim.cmd('highlight DiagnosticUnderlineWarn guifg=' .. utils.get_hl('DiagnosticWarn').foreground)
|
||||
end
|
||||
|
||||
function P.on_attach(client, bufnr)
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
-- Disabled in favor of nvim-cmp
|
||||
-- vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
require('lsp_signature').on_attach({
|
||||
debug = false, -- set to true to enable debug logging
|
||||
log_path = vim.fn.stdpath('cache') .. '/lsp_signature.log', -- log dir when debug is on
|
||||
-- default is ~/.cache/nvim/lsp_signature.log
|
||||
verbose = false, -- show debug line number
|
||||
|
||||
bind = true, -- This is mandatory, otherwise border config won't get registered.
|
||||
-- If you want to hook lspsaga or other signature handler, pls set to false
|
||||
doc_lines = 20, -- will show two lines of comment/doc(if there are more than two lines in doc, will be truncated);
|
||||
-- set to 0 if you DO NOT want any API comments be shown
|
||||
-- This setting only take effect in insert mode, it does not affect signature help in normal
|
||||
-- mode, 10 by default
|
||||
|
||||
max_height = 12, -- max height of signature floating_window
|
||||
max_width = 80, -- max_width of signature floating_window
|
||||
noice = false, -- set to true if you using noice to render markdown
|
||||
wrap = true, -- allow doc/signature text wrap inside floating_window, useful if your lsp return doc/sig is too long
|
||||
|
||||
floating_window = true, -- show hint in a floating window, set to false for virtual text only mode
|
||||
|
||||
floating_window_above_cur_line = true, -- try to place the floating above the current line when possible Note:
|
||||
-- will set to true when fully tested, set to false will use whichever side has more space
|
||||
-- this setting will be helpful if you do not want the PUM and floating win overlap
|
||||
|
||||
floating_window_off_x = 1, -- adjust float windows x position.
|
||||
floating_window_off_y = 0, -- adjust float windows y position. e.g -2 move window up 2 lines; 2 move down 2 lines
|
||||
|
||||
close_timeout = nil, -- close floating window after ms when laster parameter is entered
|
||||
fix_pos = false, -- set to true, the floating window will not auto-close until finish all parameters
|
||||
hint_enable = false, -- virtual hint enable
|
||||
hint_prefix = '🐼 ', -- Panda for parameter, NOTE: for the terminal not support emoji, might crash
|
||||
hint_scheme = 'String',
|
||||
hi_parameter = 'IncSearch', -- default 'LspSignatureActiveParameter', -- how your parameter will be highlight
|
||||
handler_opts = {
|
||||
border = 'none' -- double, rounded, single, shadow, none
|
||||
},
|
||||
|
||||
always_trigger = true, -- sometime show signature on new line or in middle of parameter can be confusing, set it to false for #58
|
||||
|
||||
auto_close_after = nil, -- autoclose signature float win after x sec, disabled if nil.
|
||||
extra_trigger_chars = {}, -- Array of extra characters that will trigger signature completion, e.g., {"(", ","}
|
||||
zindex = 200, -- by default it will be on top of all floating windows, set to <= 50 send it to bottom
|
||||
|
||||
padding = '', -- character to pad on left and right of signature can be ' ', or '|' etc
|
||||
|
||||
transparency = nil, -- disabled by default, allow floating win transparent value 1~100
|
||||
shadow_blend = 36, -- if you using shadow as border use this set the opacity
|
||||
shadow_guibg = 'Black', -- if you using shadow as border use this set the color e.g. 'Green' or '#121315'
|
||||
timer_interval = 200, -- default timer check interval set to lower value if you want to reduce latency
|
||||
toggle_key = '<C-e>', -- toggle signature on and off in insert mode, e.g. toggle_key = '<M-x>'
|
||||
|
||||
select_signature_key = nil, -- cycle to next signature, e.g. '<M-n>' function overloading
|
||||
move_cursor_key = '<C-s>' -- imap, use nvim_set_current_win to move cursor between current win and floating
|
||||
}, bufnr)
|
||||
-- Mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local opts = { noremap = true, silent = true }
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'L',
|
||||
'<cmd>lua vim.diagnostic.open_float()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '[d',
|
||||
'<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', ']d',
|
||||
'<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ll',
|
||||
'<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD',
|
||||
'<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd',
|
||||
'<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K',
|
||||
'<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi',
|
||||
'<cmd>lua vim.lsp.buf.implementation()<CR>',
|
||||
opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>s',
|
||||
'<cmd>lua vim.lsp.buf.signature_help()<CR>',
|
||||
opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wa',
|
||||
'<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>',
|
||||
opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wr',
|
||||
'<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>',
|
||||
opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wl',
|
||||
'<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>',
|
||||
opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gt',
|
||||
'<cmd>lua vim.lsp.buf.type_definition()<CR>',
|
||||
opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>rn',
|
||||
'<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ca',
|
||||
'<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr',
|
||||
'<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>lf',
|
||||
'<cmd>lua vim.lsp.buf.format({async = true})<CR>',
|
||||
opts)
|
||||
-- if client.server_capabilities.document_range_formatting then
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'v', '<leader>lf',
|
||||
'<cmd>lua vim.lsp.buf.format({async = true})<CR>',
|
||||
opts)
|
||||
-- end
|
||||
|
||||
-- The below command will highlight the current variable and its usages in the buffer.
|
||||
if client.server_capabilities.document_highlight then
|
||||
vim.fn.execute('hi! link LspReferenceRead Visual')
|
||||
vim.fn.execute('hi! link LspReferenceText Visual')
|
||||
vim.fn.execute('hi! link LspReferenceWrite Visual')
|
||||
vim.api.nvim_create_augroup('lsp_document_highlight', { clear = true })
|
||||
vim.api.nvim_create_autocmd('CursorHold', {
|
||||
buffer = bufnr,
|
||||
callback = vim.lsp.buf.document_highlight
|
||||
})
|
||||
vim.api.nvim_create_autocmd('CursorMoved', {
|
||||
buffer = bufnr,
|
||||
callback = vim.lsp.buf.clear_references
|
||||
})
|
||||
end
|
||||
-- Auto show current line diagnostics after 300 ms
|
||||
-- vim.cmd('autocmd CursorHold <buffer> lua vim.diagnostic.open_float({ scope = "line" })')
|
||||
-- vim.api.nvim_create_autocmd("CursorHold", {
|
||||
-- buffer = bufnr,
|
||||
-- callback = function()
|
||||
-- vim.diagnostic.open_float({ scope = "line" })
|
||||
-- end
|
||||
-- })
|
||||
vim.opt.updatetime = 100
|
||||
end
|
||||
|
||||
function P.reload_server_buf(self, name)
|
||||
local server_spec = self.spec[name]
|
||||
local ft_map = {}
|
||||
for _, ft in ipairs(server_spec.filetypes) do
|
||||
ft_map[ft] = true
|
||||
end
|
||||
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
|
||||
if vim.api.nvim_buf_is_loaded(bufnr) then
|
||||
local buf_ft = vim.api.nvim_get_option_value('filetype', { buf = bufnr })
|
||||
if ft_map[buf_ft] then
|
||||
vim.api.nvim_buf_call(
|
||||
bufnr,
|
||||
function() vim.cmd('e') end
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function P.filetypes(self)
|
||||
if not self._filetypes then
|
||||
self._filetypes = {}
|
||||
local unique = {}
|
||||
for _, server_spec in pairs(self.spec) do
|
||||
for _, ft in ipairs(server_spec.filetypes) do
|
||||
if not unique[ft] then
|
||||
table.insert(self._filetypes, ft)
|
||||
unique[ft] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return self._filetypes
|
||||
end
|
||||
|
||||
function P.language_servers(self)
|
||||
if not self._language_servers then
|
||||
self._language_servers = {}
|
||||
for server, _ in pairs(self.spec) do
|
||||
table.insert(self._language_servers, server)
|
||||
end
|
||||
end
|
||||
|
||||
return self._language_servers
|
||||
end
|
||||
|
||||
function P.setup_server(self, server)
|
||||
local lspconfig = require('lspconfig')
|
||||
local server_spec = self.spec[server]
|
||||
local cfg = require('lsp.config.' .. server)
|
||||
cfg.filetypes = server_spec.filetypes
|
||||
cfg.root_dir = lspconfig.util.find_git_ancestor
|
||||
cfg.capabilities = self.capabilities
|
||||
cfg.on_attach = self.on_attach
|
||||
lspconfig[server].setup(cfg)
|
||||
end
|
||||
|
||||
function P.setup(self)
|
||||
self._setup_diagnostic()
|
||||
P.capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
require("mason-lspconfig").setup_handlers({
|
||||
function(name)
|
||||
self:setup_server(name)
|
||||
self:reload_server_buf(name)
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
return P
|
||||
@@ -0,0 +1,88 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
return {
|
||||
clangd = {
|
||||
filetypes = {
|
||||
'c',
|
||||
'cpp',
|
||||
'objc',
|
||||
'objcpp',
|
||||
'cuda',
|
||||
'proto',
|
||||
}
|
||||
},
|
||||
cmake = {
|
||||
filetypes = {
|
||||
'cmake'
|
||||
}
|
||||
},
|
||||
diagnosticls = {
|
||||
filetypes = {
|
||||
'python',
|
||||
'lua',
|
||||
'sh',
|
||||
}
|
||||
},
|
||||
lua_ls = {
|
||||
filetypes = {
|
||||
'lua'
|
||||
}
|
||||
},
|
||||
lemminx = {
|
||||
filetypes = {
|
||||
'xml',
|
||||
'xsd',
|
||||
'xsl',
|
||||
'xslt',
|
||||
'svg',
|
||||
}
|
||||
},
|
||||
bashls = {
|
||||
filetypes = {
|
||||
'sh'
|
||||
}
|
||||
},
|
||||
groovyls = {
|
||||
filetypes = {
|
||||
'groovy'
|
||||
}
|
||||
},
|
||||
rust_analyzer = {
|
||||
filetypes = {
|
||||
'rust'
|
||||
}
|
||||
},
|
||||
gopls = {
|
||||
filetypes = {
|
||||
"go",
|
||||
"gomod"
|
||||
}
|
||||
},
|
||||
golangci_lint_ls = {
|
||||
filetypes = {
|
||||
"go",
|
||||
"gomod"
|
||||
}
|
||||
},
|
||||
jedi_language_server = {
|
||||
filetypes = {
|
||||
'python'
|
||||
}
|
||||
},
|
||||
-- pyright = { 'python' },
|
||||
-- pylsp = { 'python' },
|
||||
}
|
||||
+213
@@ -0,0 +1,213 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
vim.loader.enable()
|
||||
|
||||
local plugins = {
|
||||
{
|
||||
'Mofiqul/vscode.nvim',
|
||||
priority = 1000,
|
||||
lazy = false,
|
||||
config = function() require('config.vscode') end
|
||||
},
|
||||
{
|
||||
'rafamadriz/friendly-snippets',
|
||||
},
|
||||
{
|
||||
'L3MON4D3/LuaSnip',
|
||||
config = function() require('config.luasnip') end,
|
||||
-- dependencies = { 'rafamadriz/friendly-snippets' },
|
||||
-- comment out on windows and install jsregexp manually
|
||||
build = "make install_jsregexp",
|
||||
version = "2.*",
|
||||
},
|
||||
{
|
||||
'windwp/nvim-autopairs',
|
||||
config = function() require('config.nvim-autopairs') end
|
||||
},
|
||||
{
|
||||
'saadparwaiz1/cmp_luasnip',
|
||||
},
|
||||
{
|
||||
'hrsh7th/cmp-buffer',
|
||||
},
|
||||
{
|
||||
'hrsh7th/cmp-path',
|
||||
},
|
||||
{
|
||||
'hrsh7th/cmp-cmdline',
|
||||
},
|
||||
{
|
||||
'onsails/lspkind-nvim',
|
||||
},
|
||||
{
|
||||
'hrsh7th/nvim-cmp',
|
||||
-- dependencies = {
|
||||
-- 'L3MON4D3/LuaSnip',
|
||||
-- 'windwp/nvim-autopairs',
|
||||
-- 'saadparwaiz1/cmp_luasnip',
|
||||
-- 'hrsh7th/cmp-buffer',
|
||||
-- 'hrsh7th/cmp-path',
|
||||
-- 'hrsh7th/cmp-cmdline',
|
||||
-- 'onsails/lspkind-nvim',
|
||||
-- },
|
||||
config = function() require('config.nvim-cmp') end
|
||||
},
|
||||
{
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
-- dependencies = {
|
||||
-- 'hrsh7th/nvim-cmp'
|
||||
-- },
|
||||
},
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
config = function() require('config.mason') end
|
||||
},
|
||||
{
|
||||
'williamboman/mason-lspconfig.nvim',
|
||||
config = function() require('config.mason-lspconfig') end,
|
||||
-- dependencies = { 'williamboman/mason.nvim' },
|
||||
},
|
||||
{
|
||||
'ray-x/lsp_signature.nvim',
|
||||
event = "VeryLazy",
|
||||
config = function() require('config.lsp_signature') end
|
||||
},
|
||||
{
|
||||
'neovim/nvim-lspconfig',
|
||||
config = function() require('lsp'):setup() end,
|
||||
lazy = true,
|
||||
ft = require('lsp'):filetypes(),
|
||||
-- dependencies = {
|
||||
-- 'williamboman/mason-lspconfig.nvim',
|
||||
-- 'ray-x/lsp_signature.nvim',
|
||||
-- 'hrsh7th/cmp-nvim-lsp'
|
||||
-- },
|
||||
},
|
||||
{
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
config = function() require('config.nvim-treesitter') end,
|
||||
lazy = true,
|
||||
event = 'VimEnter',
|
||||
build = ':TSUpdate'
|
||||
},
|
||||
{
|
||||
'mfussenegger/nvim-dap',
|
||||
config = function() require('config.nvim-dap') end,
|
||||
lazy = true,
|
||||
ft = require('lsp'):filetypes(),
|
||||
},
|
||||
{
|
||||
'rcarriga/nvim-dap-ui',
|
||||
-- dependencies = { 'mfussenegger/nvim-dap' },
|
||||
config = function() require('config.nvim-dap-ui') end
|
||||
},
|
||||
{
|
||||
'kyazdani42/nvim-web-devicons'
|
||||
},
|
||||
{
|
||||
'tpope/vim-fugitive',
|
||||
config = function() require('config.fugitive') end,
|
||||
lazy = true,
|
||||
event = 'VimEnter'
|
||||
},
|
||||
{
|
||||
'rbong/vim-flog',
|
||||
-- dependencies = { 'tpope/vim-fugitive' },
|
||||
config = function() require('config.flog') end
|
||||
},
|
||||
{
|
||||
'nvim-lualine/lualine.nvim',
|
||||
-- dependencies = { 'kyazdani42/nvim-web-devicons', 'vim-fugitive' },
|
||||
config = function() require('config.lualine') end,
|
||||
lazy = true,
|
||||
event = 'VimEnter'
|
||||
},
|
||||
{
|
||||
'akinsho/bufferline.nvim',
|
||||
-- dependencies = { 'kyazdani42/nvim-web-devicons' },
|
||||
config = function() require('config.bufferline') end,
|
||||
lazy = true,
|
||||
event = 'VimEnter'
|
||||
},
|
||||
{
|
||||
'nvim-lua/plenary.nvim'
|
||||
},
|
||||
{
|
||||
'lewis6991/gitsigns.nvim',
|
||||
-- dependencies = { 'nvim-lua/plenary.nvim' },
|
||||
config = function() require('config.gitsigns') end,
|
||||
lazy = true,
|
||||
event = 'VimEnter'
|
||||
},
|
||||
{
|
||||
'nvim-telescope/telescope.nvim',
|
||||
-- dependencies = { 'nvim-lua/plenary.nvim' },
|
||||
config = function() require('config.telescope') end,
|
||||
lazy = true,
|
||||
event = 'VimEnter'
|
||||
},
|
||||
{
|
||||
'numToStr/Comment.nvim',
|
||||
config = function() require('config.comment') end,
|
||||
lazy = true,
|
||||
event = 'VimEnter'
|
||||
},
|
||||
{
|
||||
'Yggdroot/indentLine',
|
||||
config = function() require('config.indentLine') end,
|
||||
lazy = true,
|
||||
event = 'VimEnter'
|
||||
},
|
||||
{
|
||||
'simeji/winresizer',
|
||||
config = function() require('config.winresizer') end,
|
||||
lazy = true,
|
||||
keys = { '<C-W>r' }
|
||||
},
|
||||
{
|
||||
'sindrets/winshift.nvim',
|
||||
config = function() require('config.winshift') end,
|
||||
lazy = true,
|
||||
keys = { '<C-W>m' }
|
||||
},
|
||||
{
|
||||
'martinda/Jenkinsfile-vim-syntax',
|
||||
lazy = true,
|
||||
ft = { 'jenkinsfile', 'Jenkinsfile' }
|
||||
},
|
||||
{
|
||||
'kyazdani42/nvim-tree.lua',
|
||||
config = function() require('config.nvim-tree') end
|
||||
},
|
||||
{
|
||||
'dstein64/vim-startuptime',
|
||||
lazy = true,
|
||||
event = 'VimEnter'
|
||||
},
|
||||
{
|
||||
'stevearc/aerial.nvim',
|
||||
config = function() require('config.aerial') end
|
||||
}
|
||||
}
|
||||
|
||||
local opts = {
|
||||
-- defaults = {
|
||||
-- lazy = true
|
||||
-- }
|
||||
}
|
||||
|
||||
require('lazy').setup(plugins, opts)
|
||||
@@ -0,0 +1,74 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
local utils = require('utils')
|
||||
|
||||
M = {}
|
||||
|
||||
local env_ok = false
|
||||
local dap = nil
|
||||
|
||||
local function check_env()
|
||||
local debugpy = utils.exec('python -m debugpy --version')
|
||||
assert(debugpy.rc == 0, 'Python module debugpy is required')
|
||||
local pytest = utils.exec('python -m pytest --version')
|
||||
assert(pytest.rc == 0, 'Python module pytest is required')
|
||||
env_ok = true
|
||||
end
|
||||
|
||||
local function load_dap()
|
||||
local ok, dap = pcall(require, 'dap')
|
||||
assert(ok, 'nvim-dap is required')
|
||||
return dap
|
||||
end
|
||||
|
||||
function M.run(args)
|
||||
assert(type(args) == 'table', 'Args not specified or of wrong type')
|
||||
if not env_ok then
|
||||
check_env()
|
||||
end
|
||||
if not dap then
|
||||
dap = load_dap()
|
||||
dap.adapters.python = {
|
||||
type = 'executable';
|
||||
command = 'python';
|
||||
args = { '-m', 'debugpy.adapter' };
|
||||
cwd = vim.fn.getcwd();
|
||||
}
|
||||
end
|
||||
local config = {
|
||||
name = 'pytest ' .. table.concat(args, ' '),
|
||||
type = 'python',
|
||||
request = 'launch',
|
||||
|
||||
-- pythonPath = vim.fn.getcwd() .. '/.venv/bin/python',
|
||||
module = 'pytest',
|
||||
-- python = 'python';
|
||||
-- program = vim.fn.getcwd() .. '/.venv/bin/pytest';
|
||||
args = args,
|
||||
console = "integratedTerminal",
|
||||
-- program = "${file}";
|
||||
}
|
||||
-- session = dap.launch(adapter, config)
|
||||
dap.run(config)
|
||||
-- List of events described at https://microsoft.github.io/debug-adapter-protocol/specification#Events
|
||||
-- Also see :h dap-extensions
|
||||
dap.listeners.after['event_initialized']['pytest.lua'] = function(session, body)
|
||||
dap.set_exception_breakpoints({ 'userUnhandled' })
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -0,0 +1,86 @@
|
||||
--[[
|
||||
Copyright 2023 Oscar Wallberg
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
]]
|
||||
|
||||
M = {}
|
||||
|
||||
M.os_name = vim.loop.os_uname().sysname
|
||||
|
||||
function M.has_value(tab, val)
|
||||
for _, value in ipairs(tab) do if value == val then return true end end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
---@param cmd table: Array of executable + args
|
||||
function M.exec(cmd)
|
||||
local out = vim.fn.system(cmd)
|
||||
local rc = vim.v.shell_error
|
||||
|
||||
return { out = out, rc = rc }
|
||||
end
|
||||
|
||||
function M.get_color(group, attr)
|
||||
return vim.fn.synIDattr(vim.fn.synIDtrans(vim.fn.hlID(group)), attr)
|
||||
end
|
||||
|
||||
function M.get_hl(name)
|
||||
local ok, hl = pcall(vim.api.nvim_get_hl_by_name, name, true)
|
||||
if not ok then return end
|
||||
for _, key in pairs({ 'foreground', 'background', 'special' }) do
|
||||
if hl[key] then hl[key] = string.format('#%06x', hl[key]) end
|
||||
end
|
||||
return hl
|
||||
end
|
||||
|
||||
--- Check that an executable is available
|
||||
--- @param exe string: Array to look for
|
||||
--- @return boolean
|
||||
function M.is_available(exe)
|
||||
return vim.fn.executable(exe) == 1
|
||||
end
|
||||
|
||||
--- Check that at least one executable is available
|
||||
--- @param exes table: Array of exes
|
||||
--- @return boolean
|
||||
function M.any_available(exes)
|
||||
for _, e in ipairs(exes) do
|
||||
if M.is_available(e) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
--- Asserts that an executable is available
|
||||
--- Raises error if missing.
|
||||
--- @param exe string: Array to look for
|
||||
function M.assert_available(exe)
|
||||
if not M.is_available(exe) then
|
||||
error("Missing executable '" .. exe .. "'.")
|
||||
end
|
||||
end
|
||||
|
||||
--- Asserts that at least one executable is available
|
||||
--- Raises error if missing.
|
||||
--- @param exes table: Array of exes
|
||||
function M.assert_any_available(exes)
|
||||
if not M.any_available(exes) then
|
||||
error('At least one of the following is required:\n' .. table.concat(exes, ', '))
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
Reference in New Issue
Block a user