[neovim] Move configuration to lua, replacing COC and ALE with LSP and Treesitter

This commit is contained in:
Bruno Carlin 2022-02-22 10:18:48 +01:00
parent 0c6bb91f41
commit 9f17b691b1
46 changed files with 2448 additions and 34 deletions

View file

@ -0,0 +1,149 @@
local cmp = require'cmp'
local kind_icons = {
Text = "",
Method = "",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = ""
}
local has_words_before = function()
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 feedkey = function(key, mode)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
end
local snippy = require("snippy")
cmp.setup({
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
snippy.expand_snippet(args.body)
--vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping = {
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
-- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
['<CR>'] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif snippy.can_expand_or_advance() then
snippy.expand_or_advance()
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 snippy.can_jump(-1) then
snippy.previous()
else
fallback()
end
end, { "i", "s" }),
--[[
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif vim.fn["vsnip#available"](1) == 1 then
feedkey("<Plug>(vsnip-expand-or-jump)", "")
elseif has_words_before() then
cmp.complete()
else
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function()
if cmp.visible() then
cmp.select_prev_item()
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
feedkey("<Plug>(vsnip-jump-prev)", "")
end
end, { "i", "s" }),
]]--
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'snippy' },
--{ name = 'vsnip' },
}, {
{ name = 'buffer' },
}),
formatting = {
format = function(entry, vim_item)
-- Kind icons
vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
-- Source
vim_item.menu = ({
buffer = "[Buffer]",
nvim_lsp = "[LSP]",
snippy = "[Snip]",
vsnip = "[Snip]",
})[entry.source.name]
return vim_item
end
},
})
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', {
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
-- Setup lspconfig.
-- local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
-- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
-- require('lspconfig')['<YOUR_LSP_SERVER>'].setup {
-- capabilities = capabilities
-- }

View file

@ -0,0 +1,9 @@
vim.g.firenvim_config = {
globalSettings = {
alt = 'all',
},
localSettings = {
['https://share\\.waarp\\.org/'] = { takeover = 'never', priority = 1 },
}
}

View file

@ -0,0 +1,71 @@
-- This API requires nvim 0.7
--[[
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
-- Navigation
map('n', '<leader>gn', function() gs.next_hunk({wrap=true}) end, {expr=true})
map('n', '<leader>gp', function() gs.prev_hunk({wrap=true}) end, {expr=true})
-- Actions
map({'n', 'v'}, '<leader>gs', gs.stage_hunk)
map('n', '<leader>gS', gs.stage_buffer)
map('n', '<leader>gu', gs.undo_stage_hunk)
map({'n', 'v'}, '<leader>gr', gs.reset_hunk)
map('n', '<leader>gR', gs.reset_buffer)
map('n', '<leader>gP', gs.preview_hunk)
map('n', '<leader>gb', function() gs.blame_line{full=true} end)
map('n', '<leader>gB', gs.toggle_current_line_blame)
map('n', '<leader>gd', gs.diffthis)
map('n', '<leader>gdp', function() gs.diffthis('~') end)
map('n', '<leader>gD', gs.toggle_deleted)
-- Text object
map({'o', 'x'}, 'ih', ':<C-U>Gitsigns select_hunk<CR>')
end
}
]]--
require('gitsigns').setup {
on_attach = function(bufnr)
local function map(mode, lhs, rhs, opts)
opts = vim.tbl_extend('force', {noremap = true, silent = true}, opts or {})
vim.api.nvim_buf_set_keymap(bufnr, mode, lhs, rhs, opts)
end
-- Navigation
map('n', '<leader>gn', "&diff ? ']c' : '<cmd>Gitsigns next_hunk<CR>'", {expr=true})
map('n', '<leader>gp', "&diff ? '[c' : '<cmd>Gitsigns prev_hunk<CR>'", {expr=true})
-- Actions
map('n', '<leader>gs', '<cmd>Gitsigns stage_hunk<CR>')
map('v', '<leader>gs', '<cmd>Gitsigns stage_hunk<CR>')
map('n', '<leader>gr', '<cmd>Gitsigns reset_hunk<CR>')
map('v', '<leader>gr', '<cmd>Gitsigns reset_hunk<CR>')
map('n', '<leader>gS', '<cmd>Gitsigns stage_buffer<CR>')
map('n', '<leader>gu', '<cmd>Gitsigns undo_stage_hunk<CR>')
map('n', '<leader>gR', '<cmd>Gitsigns reset_buffer<CR>')
map('n', '<leader>gP', '<cmd>Gitsigns preview_hunk<CR>')
map('n', '<leader>gb', '<cmd>lua require"gitsigns".blame_line{full=true}<CR>')
map('n', '<leader>gB', '<cmd>Gitsigns toggle_current_line_blame<CR>')
map('n', '<leader>gd', '<cmd>Gitsigns diffthis<CR>')
map('n', '<leader>gdp', '<cmd>lua require"gitsigns".diffthis("~")<CR>')
map('n', '<leader>gD', '<cmd>Gitsigns toggle_deleted<CR>')
-- Text object
map('o', 'ih', ':<C-U>Gitsigns select_hunk<CR>')
map('x', 'ih', ':<C-U>Gitsigns select_hunk<CR>')
end
}
vim.cmd [[
highlight! link GitSignsAdd DiffAdd
]]

View file

@ -0,0 +1,6 @@
vim.g.indent_blankline_char=''
require("indent_blankline").setup {
show_current_context = true,
show_current_context_start = true,
}

View file

@ -0,0 +1,18 @@
require "plugins.main"
require "plugins.solarized"
require "plugins.cmp"
require "plugins.firenvim"
require "plugins.gitsigns"
require "plugins.indent"
require "plugins.lsp_signature"
require "plugins.lualine"
require "plugins.neogit"
require "plugins.neotree"
require "plugins.nvimgo"
require "plugins.nvimgoc"
require "plugins.nvimtree"
require "plugins.sidebar"
require "plugins.snippy"
require "plugins.telescope"
require "plugins.treesitter"
require "plugins.treesitter_textobject"

View file

@ -0,0 +1,6 @@
require('lsp_signature').setup {
bind = true,
handler_opts = {
border = "rounded"
},
}

View file

@ -0,0 +1,35 @@
require('lualine').setup {
options = {
icons_enabled = true,
theme = 'solarized',
component_separators = { left = '', right = ''},
section_separators = { left = '', right = ''},
disabled_filetypes = { NvimTree },
always_divide_middle = true,
},
sections = {
lualine_a = {'mode'},
lualine_b = {'branch', 'diff', 'diagnostics'},
lualine_c = {'filename'},
lualine_x = {'encoding', 'fileformat', 'filetype'},
lualine_y = {'progress'},
lualine_z = {'location'}
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {'filename'},
lualine_x = {'location'},
lualine_y = {},
lualine_z = {}
},
tabline = {
lualine_a = {'buffers'},
lualine_b = {},
lualine_c = {'filename'},
lualine_x = {},
lualine_y = {},
lualine_z = {'tabs'}
},
extensions = {}
}

View file

@ -0,0 +1,107 @@
local fn = vim.fn
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
packer_bootstrap = fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
end
return require('packer').startup(function(use)
use 'wbthomason/packer.nvim'
-- Appearance
--use 'shaunsingh/solarized.nvim'
--use 'ishan9299/nvim-solarized-lua'
use 'altercation/vim-colors-solarized'
use 'lukas-reineke/indent-blankline.nvim'
use 'sidebar-nvim/sidebar.nvim'
use {
'nvim-lualine/lualine.nvim',
requires = {
'kyazdani42/nvim-web-devicons'
},
}
use {
"nvim-neo-tree/neo-tree.nvim",
branch = "v1.x",
requires = {
"nvim-lua/plenary.nvim",
"kyazdani42/nvim-web-devicons", -- not strictly required, but recommended
"MunifTanjim/nui.nvim",
},
}
use {
'kyazdani42/nvim-tree.lua',
requires = {
'kyazdani42/nvim-web-devicons', -- optional, for file icon
},
}
use 'folke/twilight.nvim'
-- LSP integration
use 'neovim/nvim-lspconfig'
use 'ray-x/lsp_signature.nvim'
-- Auto-completion
use 'hrsh7th/nvim-cmp'
use 'hrsh7th/cmp-nvim-lsp'
use 'hrsh7th/cmp-buffer'
use 'hrsh7th/cmp-path'
use 'hrsh7th/cmp-cmdline'
-- Snippets
use 'dcampos/nvim-snippy'
use 'dcampos/cmp-snippy'
--use 'hrsh7th/cmp-vsnip'
--use 'hrsh7th/vim-vsnip'
-- Git integration
use {
'lewis6991/gitsigns.nvim',
requires = {
'nvim-lua/plenary.nvim'
},
-- tag = 'release' -- To use the latest release
}
use {
'TimUntersberger/neogit',
requires = {
'nvim-lua/plenary.nvim'
},
}
-- Language support
use {
'crispgm/nvim-go',
requires = {
'nvim-lua/plenary.nvim',
'nvim-lua/popup.nvim'
},
}
use 'rafaelsq/nvim-goc.lua'
use 'vimwiki/vimwiki'
use 'pearofducks/ansible-vim'
-- others
use 'folke/zen-mode.nvim'
use {
'nvim-telescope/telescope.nvim',
requires = {
'nvim-lua/plenary.nvim'
},
}
use {
'nvim-treesitter/nvim-treesitter',
run = ':TSUpdate'
}
use 'nvim-treesitter/nvim-treesitter-textobjects'
use {
'glacambre/firenvim',
run = function() vim.fn['firenvim#install'](0) end
}
-- Automatically set up your configuration after cloning packer.nvim
-- Put this at the end after all plugins
if packer_bootstrap then
require('packer').sync()
end
end)

View file

@ -0,0 +1,70 @@
require("neogit").setup {
disable_signs = false,
disable_hint = false,
disable_context_highlighting = false,
disable_commit_confirmation = false,
auto_refresh = true,
disable_builtin_notifications = false,
use_magit_keybindings = false,
commit_popup = {
kind = "split",
},
-- Change the default way of opening neogit
kind = "tab",
-- customize displayed signs
signs = {
-- { CLOSED, OPENED }
section = { ">", "v" },
item = { ">", "v" },
hunk = { "", "" },
},
integrations = {
-- Neogit only provides inline diffs. If you want a more traditional way to look at diffs, you can use `sindrets/diffview.nvim`.
-- The diffview integration enables the diff popup, which is a wrapper around `sindrets/diffview.nvim`.
--
-- Requires you to have `sindrets/diffview.nvim` installed.
-- use {
-- 'TimUntersberger/neogit',
-- requires = {
-- 'nvim-lua/plenary.nvim',
-- 'sindrets/diffview.nvim'
-- }
-- }
--
diffview = false
},
-- Setting any section to `false` will make the section not render at all
sections = {
untracked = {
folded = false
},
unstaged = {
folded = false
},
staged = {
folded = false
},
stashes = {
folded = true
},
unpulled = {
folded = true
},
unmerged = {
folded = false
},
recent = {
folded = true
},
},
-- override/add mappings
mappings = {
-- modify status buffer mappings
status = {
-- Adds a mapping with "B" as key that does the "BranchPopup" command
-- ["B"] = "BranchPopup",
-- Removes the default mapping of "s"
-- ["s"] = "",
}
}
}

View file

@ -0,0 +1,295 @@
-- See ":help neo-tree-highlights" for a list of available highlight groups
vim.cmd [[
highlight clear NeoTreeDirectoryName
highlight! link NeoTreeDirectoryName Directory
highlight! link NeoTreeDirectoryIcon NeoTreeDirectoryName
"highlight! NeoTreeIndentMarker ctermfg=11
highlight! NeoTreeDimText ctermfg=11
]]
local config = {
default_source = "filesystem",
close_if_last_window = true, -- Close Neo-tree if it is the last window left in the tab
-- popup_border_style is for input and confirmation dialogs.
-- Configurtaion of floating window is done in the individual source sections.
-- "NC" is a special style that works well with NormalNC set
popup_border_style = "NC", -- "double", "none", "rounded", "shadow", "single" or "solid"
use_popups_for_input = true, -- If false, inputs will use vim.ui.input() instead of custom floats.
close_floats_on_escape_key = true,
enable_git_status = true,
enable_diagnostics = true,
open_files_in_last_window = true, -- false = open files in top left window
log_level = "debug", -- "trace", "debug", "info", "warn", "error", "fatal"
log_to_file = true, -- true, false, "/path/to/file.log", use :NeoTreeLogs to show the file
--
--event_handlers = {
-- {
-- event = "before_render",
-- handler = function (state)
-- -- add something to the state that can be used by custom components
-- end
-- },
-- {
-- event = "file_opened",
-- handler = function(file_path)
-- --auto close
-- require("neo-tree").close_all()
-- end
-- },
-- {
-- event = "file_opened",
-- handler = function(file_path)
-- --clear search after opening a file
-- require("neo-tree.sources.filesystem").reset_search()
-- end
-- },
-- {
-- event = "file_renamed",
-- handler = function(args)
-- -- fix references to file
-- print(args.source, " renamed to ", args.destination)
-- end
-- },
-- {
-- event = "file_moved",
-- handler = function(args)
-- -- fix references to file
-- print(args.source, " moved to ", args.destination)
-- end
-- },
--},
default_component_configs = {
indent = {
indent_size = 2,
padding = 1,
with_markers = true,
indent_marker = "",
last_indent_marker = "",
highlight = "NeoTreeIndentMarker",
},
icon = {
folder_closed = "",
folder_open = "",
default = "*",
},
name = {
trailing_slash = true,
use_git_status_colors = true,
},
git_status = {
highlight = "NeoTreeDimText",
},
},
filesystem = {
hijack_netrw_behavior = "open_default", -- netrw disabled, opening a directory opens neo-tree
-- in whatever position is specified in window.position
-- "open_split", -- netrw disabled, opening a directory opens within the
-- window like netrw would, regardless of window.position
-- "disabled", -- netrw left alone, neo-tree does not handle opening dirs
follow_current_file = false, -- This will find and focus the file in the active buffer every time
-- the current file is changed while the tree is open.
use_libuv_file_watcher = false, -- This will use the OS level file watchers to detect changes
-- instead of relying on nvim autocmd events.
window = { -- see https://github.com/MunifTanjim/nui.nvim/tree/main/lua/nui/popup for
-- possible options. These can also be functions that return these options.
position = "left", -- left, right, float, split
width = 40, -- applies to left and right positions
popup = { -- settings that apply to float position only
size = {
height = "80%",
width = "50%",
},
position = "50%", -- 50% means center it
-- you can also specify border here, if you want a different setting from
-- the global popup_border_style.
},
-- Mappings for tree window. See `:h nep-tree-mappings` for a list of built-in commands.
-- You can also create your own commands by providing a function instead of a string.
mappings = {
["<2-LeftMouse>"] = "open",
["<cr>"] = "open",
["S"] = "open_split",
["s"] = "open_vsplit",
["C"] = "close_node",
["z"] = "close_all_nodes",
["<bs>"] = "navigate_up",
["."] = "set_root",
["H"] = "toggle_hidden",
["I"] = "toggle_gitignore",
["R"] = "refresh",
["/"] = "fuzzy_finder",
--["/"] = "filter_as_you_type", -- this was the default until v1.28
["f"] = "filter_on_submit",
["<C-x>"] = "clear_filter",
["a"] = "add",
["d"] = "delete",
["r"] = "rename",
["c"] = "copy_to_clipboard",
["x"] = "cut_to_clipboard",
["p"] = "paste_from_clipboard",
["y"] = "copy", -- takes text input for destination
["m"] = "move", -- takes text input for destination
["q"] = "close_window",
},
},
--find_command = "fd",
--find_args = { -- you can specify extra args to pass to the find command.
-- "--exclude", ".git",
-- "--exclude", "node_modules"
--},
---- or use a function instead of list of strings
--find_args = function(cmd, path, search_term, args)
-- if cmd ~= "fd" then
-- return args
-- end
-- --maybe you want to force the filter to always include hidden files:
-- table.insert(args, "--hidden")
-- -- but no one ever wants to see .git files
-- table.insert(args, "--exclude")
-- table.insert(args, ".git")
-- -- or node_modules
-- table.insert(args, "--exclude")
-- table.insert(args, "node_modules")
-- --here is where it pays to use the function, you can exclude more for
-- --short search terms, or vary based on the directory
-- if string.len(search_term) < 4 and path == "/home/cseickel" then
-- table.insert(args, "--exclude")
-- table.insert(args, "Library")
-- end
-- return args
--end,
search_limit = 50, -- max number of search results when using filters
filters = {
show_hidden = false,
respect_gitignore = false,
},
bind_to_cwd = false, -- true creates a 2-way binding between vim's cwd and neo-tree's root
-- The renderer section provides the renderers that will be used to render the tree.
-- The first level is the node type.
-- For each node type, you can specify a list of components to render.
-- Components are rendered in the order they are specified.
-- The first field in each component is the name of the function to call.
-- The rest of the fields are passed to the function as the "config" argument.
renderers = {
directory = {
{ "clipboard" },
{ "indent" },
{ "icon" },
{ "current_filter" },
{ "name" },
-- {
-- "symlink_target",
-- highlight = "NeoTreeSymbolicLinkTarget",
-- },
{ "diagnostics" },
{ "git_status" },
},
file = {
{ "clipboard" },
{ "indent" },
{ "icon" },
{
"name",
use_git_status_colors = true,
},
-- {
-- "symlink_target",
-- highlight = "NeoTreeSymbolicLinkTarget",
-- },
{ "diagnostics" },
{ "git_status" },
},
},
},
buffers = {
window = {
position = "left",
width = 40,
mappings = {
["<2-LeftMouse>"] = "open",
["<cr>"] = "open",
["S"] = "open_split",
["s"] = "open_vsplit",
["<bs>"] = "navigate_up",
["."] = "set_root",
["R"] = "refresh",
["a"] = "add",
["d"] = "delete",
["r"] = "rename",
["c"] = "copy_to_clipboard",
["x"] = "cut_to_clipboard",
["p"] = "paste_from_clipboard",
["bd"] = "buffer_delete",
},
},
bind_to_cwd = true,
renderers = {
directory = {
{ "indent" },
{ "icon" },
{ "name" },
{ "diagnostics", errors_only = true },
{ "clipboard" },
},
file = {
{ "indent" },
{ "icon" },
{ "name" },
{ "bufnr" },
{ "diagnostics" },
{ "git_status" },
{ "clipboard" },
},
},
},
git_status = {
window = {
position = "left",
width = 40,
mappings = {
["<2-LeftMouse>"] = "open",
["<cr>"] = "open",
["S"] = "open_split",
["s"] = "open_vsplit",
["C"] = "close_node",
["R"] = "refresh",
["d"] = "delete",
["r"] = "rename",
["c"] = "copy_to_clipboard",
["x"] = "cut_to_clipboard",
["p"] = "paste_from_clipboard",
["A"] = "git_add_all",
["gu"] = "git_unstage_file",
["ga"] = "git_add_file",
["gr"] = "git_revert_file",
["gc"] = "git_commit",
["gp"] = "git_push",
["gg"] = "git_commit_and_push",
},
},
renderers = {
directory = {
{ "indent" },
{ "icon" },
{ "name" },
{ "diagnostics", errors_only = true },
},
file = {
{ "indent" },
{ "icon" },
{ "name" },
{ "diagnostics" },
{ "git_status" },
},
},
},
}
require("neo-tree").setup(config)
vim.cmd [[
nnoremap <leader>n :NeoTreeFocus<cr>
nnoremap <C-n> :NeoTreeToggle<cr>
]]

View file

@ -0,0 +1,41 @@
require('go').setup({
-- auto commands
auto_format = false,
auto_lint = false,
-- linters: revive, errcheck, staticcheck, golangci-lint
linter = 'revive',
-- linter_flags: e.g., {revive = {'-config', '/path/to/config.yml'}}
linter_flags = {},
-- lint_prompt_style: qf (quickfix), vt (virtual text)
lint_prompt_style = 'qf',
-- formatter: goimports, gofmt, gofumpt
formatter = 'gofumpt',
-- test flags: -count=1 will disable cache
test_flags = {'-v'},
test_timeout = '30s',
test_env = {},
-- show test result with popup window
test_popup = true,
test_popup_width = 80,
test_popup_height = 10,
-- test open
test_open_cmd = 'edit',
-- struct tags
tags_name = 'json',
tags_options = {'json=omitempty'},
tags_transform = 'snakecase',
tags_flags = {'-skip-unexported'},
-- quick type
quick_type_flags = {'--just-types'},
})
vim.cmd [[
augroup nvimgo_keymaps
autocmd!
autocmd FileType go nnoremap <buffer><leader>t :GoTest<cr>
autocmd FileType go nnoremap <buffer><leader>tf :GoTestFunc<cr>
autocmd FileType go nnoremap <buffer><leader>tF :GoTestFile<cr>
autocmd FileType go nnoremap <buffer><leader>ta :GoTestAll<cr>
autocmd FileType go nnoremap <buffer><leader>a :GoToTest<cr>
augroup END
]]

View file

@ -0,0 +1,20 @@
-- if set, when we switch between buffers, it will not split more than once. It will switch to the existing buffer instead
vim.opt.switchbuf = 'useopen'
local goc = require('nvim-goc')
goc.setup({ verticalSplit = false })
vim.cmd [[
augroup nvimgoc_keymaps
autocmd!
autocmd FileType go nnoremap <buffer><leader>c :lua require('nvim-goc').Coverage<cr>
autocmd FileType go nnoremap <buffer><leader>cc :lua require('nvim-goc').CoverageClear
autocmd FileType go nnoremap <buffer><leader>cf :lua require('nvim-goc').CoverageFunc<cr>
augroup end
]]
-- default colors
-- vim.highlight.link('GocNormal', 'Comment')
-- vim.highlight.link('GocCovered', 'String')
-- vim.highlight.link('GocUncovered', 'Error')

View file

@ -0,0 +1,104 @@
vim.g.nvim_tree_indent_markers = 1 -- 0 by default, this option shows indent markers when folders are open
vim.g.nvim_tree_git_hl = 1 -- 0 by default, will enable file highlight for git attributes (can be used without the icons).
vim.g.nvim_tree_highlight_opened_files = 1 -- 0 by default, will enable folder and file icon highlight for opened files/directories.
vim.g.nvim_tree_root_folder_modifier = ':~' -- This is the default. See :help filename-modifiers for more options
vim.g.nvim_tree_add_trailing = 1 -- 0 by default, append a trailing slash to folder names
vim.g.nvim_tree_group_empty = 1 -- 0 by default, compact folders that only contain a single folder into one node in the file tree
vim.g.nvim_tree_disable_window_picker = 1 -- 0 by default, will disable the window picker.
vim.g.nvim_tree_icon_padding = ' ' -- one space by default, used for rendering the space between the icon and the filename. Use with caution, it could break rendering if you set an empty string depending on your font.
vim.g.nvim_tree_symlink_arrow = '->' -- defaults to ' ➛ '. used as a separator between symlinks' source and target.
vim.g.nvim_tree_respect_buf_cwd = 1 -- 0 by default, will change cwd of nvim-tree to that of new buffer's when opening nvim-tree.
vim.g.nvim_tree_create_in_closed_folder = 0 -- 1 by default, When creating files, sets the path of a file when cursor is on a closed folder to the parent folder when 0, and inside the folder when 1.
vim.g.nvim_tree_window_picker_exclude = {
filetype = { packer, },
buftype = { terminal },
}
-- Dictionary of buffer option names mapped to a list of option values that
-- indicates to the window picker that the buffer's window should not be
-- selectable.
vim.g.nvim_tree_special_files = { ['README.md'] = 1, Makefile = 1, MAKEFILE = 1 } -- List of filenames that gets highlighted with NvimTreeSpecialFile
vim.g.nvim_tree_show_icons = {
git = 1,
folders = 1,
files = 1,
folder_arrows = 0,
}
-- If 0, do not show the icons for one of 'git' 'folder' and 'files'
-- 1 by default, notice that if 'files' is 1, it will only display
-- if nvim-web-devicons is installed and on your runtimepath.
-- if folder is 1, you can also tell folder_arrows 1 to show small arrows next to the folder icons.
-- but this will not work when you set indent_markers (because of UI conflict)
-- default will show icon by default if no icon is provided
-- default shows no icon by default
vim.g.nvim_tree_icons = {
default = '',
symlink = '',
git = {
unstaged = '',
staged = '',
unmerged = '',
renamed = '',
untracked = '',
deleted = '',
ignored = ''
},
folder = {
arrow_open = '',
arrow_closed = '',
default = '',
open = '',
empty = '',
empty_open = '',
symlink = '',
symlink_open = '',
}
}
vim.cmd [[
nnoremap <C-n> :NvimTreeClose<CR>
nnoremap <leader>n :NvimTreeFocus<CR>
]]
-- NvimTreeOpen, NvimTreeClose, NvimTreeFocus, NvimTreeFindFileToggle, and NvimTreeResize are also available if you need them
vim.cmd [[
highlight! NvimTreeIndentMarker ctermfg=11
]]
-- each of these are documented in `:help nvim-tree.OPTION_NAME`
require('nvim-tree').setup {
hijack_netrw = true,
auto_close = true,
auto_reload_on_write = true,
open_on_tab = false,
hijack_cursor = false,
update_cwd = false,
hijack_unnamed_buffer_when_opening = true,
hijack_directories = {
enable = true,
auto_open = true,
},
diagnostics = {
enable = true,
icons = {
hint = "",
info = "",
warning = "",
error = "",
}
},
git = {
enable = true,
ignore = false,
},
filters = {
dotfiles = false,
custom = { '.git' }
},
view = {
width = 30,
height = 30,
hide_root_folder = false,
side = 'left',
},
}

View file

@ -0,0 +1,23 @@
require("sidebar-nvim").setup {
disable_default_keybindings = 0,
bindings = nil,
open = false,
side = 'right',
initial_width = 35,
hide_statusline = true,
update_interval = 1000,
sections = { "git", "diagnostics", "symbols", "todos" },
section_separator = {"", "-----", ""},
containers = {
attach_shell = "/bin/sh", show_all = true, interval = 5000,
},
datetime = { format = "%a %b %d, %H:%M", clocks = { { name = "local" } } },
todos = { ignored_paths = { "~" } },
disable_closing_prompt = false
}
local options = { noremap = true }
local map = vim.api.nvim_set_keymap
map('n', '<C-s>', "<cmd>lua require('sidebar-nvim').toggle()<cr>", options)
map('n', '<leader>s', "<cmd>lua require('sidebar-nvim').focus()<cr>", options)

View file

@ -0,0 +1,11 @@
require('snippy').setup({
mappings = {
is = {
['<Tab>'] = 'expand_or_advance',
['<S-Tab>'] = 'previous',
},
nx = {
['<leader>x'] = 'cut_text',
},
},
})

View file

@ -0,0 +1,7 @@
vim.g.solarized_termcolors = 16
--vim.g.solarized_termtrans = 1
vim.g.solarized_hitrail = 1
vim.cmd [[
colorscheme bsolarized2
]]

View file

@ -0,0 +1,47 @@
require('telescope').setup{
defaults = {
-- Default configuration for telescope goes here:
-- config_key = value,
mappings = {
i = {
-- map actions.which_key to <C-h> (default: <C-/>)
-- actions.which_key shows the mappings for your picker,
-- e.g. git_{create, delete, ...}_branch for the git_branches picker
["<C-h>"] = "which_key"
}
}
},
pickers = {
-- Default configuration for builtin pickers goes here:
-- picker_name = {
-- picker_config_key = value,
-- ...
-- }
-- Now the picker_config_key will be applied every time you call this
-- builtin picker
},
extensions = {
-- Your extension configuration goes here:
-- extension_name = {
-- extension_config_key = value,
-- }
-- please take a look at the readme of the extension you want to configure
}
}
local options = { noremap = true }
local map = vim.api.nvim_set_keymap
map('n', '<leader>ff', "<cmd>lua require('telescope.builtin').find_files()<cr>", options)
map('n', '<leader>fg', "<cmd>lua require('telescope.builtin').live_grep()<cr>", options)
map('n', '<leader>fb', "<cmd>lua require('telescope.builtin').buffers()<cr>", options)
map('n', '<leader>fc', "<cmd>lua require('telescope.builtin').quickfix()<cr>", options)
map('n', '<leader>fl', "<cmd>lua require('telescope.builtin').loclist()<cr>", options)
map('n', '<leader>fs', "<cmd>lua require('telescope.builtin').spell_suggest()<cr>", options)
map('n', '<leader>fr', "<cmd>lua require('telescope.builtin').lsp_references()<cr>", options)
map('n', '<leader>fo', "<cmd>lua require('telescope.builtin').lsp_document_symbols()<cr>", options)
map('n', '<leader>fa', "<cmd>lua require('telescope.builtin').lsp_code_actions()<cr>", options)
map('n', '<leader>fd', "<cmd>lua require('telescope.builtin').diagnostics({bufnr=0})<cr>", options)
map('n', '<leader>fgs', "<cmd>lua require('telescope.builtin').git_status()<cr>", options)
map('n', '<leader>fgc', "<cmd>lua require('telescope.builtin').git_bcommits()<cr>", options)
map('n', '<leader>fgb', "<cmd>lua require('telescope.builtin').git_branches()<cr>", options)

View file

@ -0,0 +1,38 @@
require('nvim-treesitter.configs').setup {
-- One of "all", "maintained" (parsers with maintainers), or a list of languages
ensure_installed = "maintained",
-- Install languages synchronously (only applied to `ensure_installed`)
sync_install = false,
-- List of parsers to ignore installing
--ignore_install = { "javascript" },
highlight = {
-- `false` will disable the whole extension
enable = true,
-- list of language that will be disabled
--disable = { "c", "rust" },
-- 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,
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "gnn",
node_incremental = "grn",
scope_incremental = "grc",
node_decremental = "grm",
},
},
indent = {
enable = true
},
}

View file

@ -0,0 +1,46 @@
require('nvim-treesitter.configs').setup {
textobjects = {
select = {
enable = true,
-- Automatically jump forward to textobj, similar to targets.vim
lookahead = true,
keymaps = {
-- You can use the capture groups defined in textobjects.scm
["af"] = "@function.outer",
["if"] = "@function.inner",
["acl"] = "@class.outer",
["icl"] = "@class.inner",
["ii"] = "@conditional.inner",
["ai"] = "@conditional.outer",
["il"] = "@loop.inner",
["al"] = "@loop.outer",
["ip"] = "@parameter.inner",
["ap"] = "@parameter.outer",
["as"] = "@statement.outer",
["ica"] = "@call.inner",
["aca"] = "@call.outer",
["aco"] = "@comment.outer",
},
},
swap = {
enable = true,
swap_next = {
["<leader>a"] = "@parameter.inner",
},
swap_previous = {
["<leader>A"] = "@parameter.inner",
},
},
lsp_interop = {
enable = true,
border = 'none',
peek_definition_code = {
["<leader>df"] = "@function.outer",
},
},
},
}

View file

@ -0,0 +1,21 @@
require("twilight").setup {
dimming = {
alpha = 0.25, -- amount of dimming
-- we try to get the foreground from the highlight groups or fallback color
color = { "Normal", "#ffffff" },
inactive = false, -- when true, other windows will be fully dimmed (unless they contain the same buffer)
},
context = 10, -- amount of lines we will try to show around the current line
treesitter = true, -- use treesitter when available for the filetype
-- treesitter is used to automatically expand the visible text,
-- but you can further control the types of nodes that should always be fully expanded
expand = { -- for treesitter, we we always try to expand to the top-most ancestor with these types
"function",
"method",
},
exclude = {}, -- exclude these filetypes
}
vim.cmd [[
highlight Twilight ctermfg=10
]]

View file

@ -0,0 +1,7 @@
vim.g.vimwiki_list = [{'path': '~/Notebook',
\ 'auto_toc': 1,
\ 'index': 'main',
\ 'ext': '.md',
\ 'syntax': 'markdown'}]
vim.g.vimwiki_ext2syntax = {'.md': 'markdown'}

View file

@ -0,0 +1,56 @@
require("zen-mode").setup {
--[[
window = {
--backdrop = 0.95, -- shade the backdrop of the Zen window. Set to 1 to keep the same as Normal
-- height and width can be:
-- * an absolute number of cells when > 1
-- * a percentage of the width / height of the editor when <= 1
-- * a function that returns the width or the height
--width = 120, -- width of the Zen window
--height = 1, -- height of the Zen window
-- by default, no options are changed for the Zen window
-- uncomment any of the options below, or add other vim.wo options you want to apply
options = {
-- signcolumn = "no", -- disable signcolumn
-- number = false, -- disable number column
-- relativenumber = false, -- disable relative numbers
-- cursorline = false, -- disable cursorline
-- cursorcolumn = false, -- disable cursor column
-- foldcolumn = "0", -- disable fold column
-- list = false, -- disable whitespace characters
},
},
]]--
plugins = {
-- disable some global vim options (vim.o...)
-- comment the lines to not apply the options
options = {
enabled = true,
ruler = false, -- disables the ruler text in the cmd line area
showcmd = false, -- disables the command in the last line of the screen
},
twilight = { enabled = true }, -- enable to start Twilight when zen mode opens
gitsigns = { enabled = false }, -- disables git signs
tmux = { enabled = false }, -- disables the tmux statusline
-- this will change the font size on kitty when in zen mode
-- to make this work, you need to set the following kitty options:
-- - allow_remote_control socket-only
-- - listen_on unix:/tmp/kitty
kitty = {
enabled = false,
font = "+4", -- font size increment
},
},
-- callback where you can add custom code when the Zen window opens
--on_open = function(win)
--end,
-- callback where you can add custom code when the Zen window closes
--on_close = function()
--end,
}