Migrate neovim config to lua

This commit is contained in:
2021-05-19 21:39:28 +02:00
parent 52bbd24071
commit 03fc8f45e6
22 changed files with 699 additions and 527 deletions

View File

@@ -0,0 +1,3 @@
vim.cmd('let g:nvcode_termcolors=256')
vim.cmd('colorscheme ' .. O.colorscheme)

View File

@@ -0,0 +1,70 @@
O = {
auto_close_tree = 0,
auto_complete = true,
background = dark,
ignorecase = smartcase,
clipboard = unnamedplus,
incsearch = true,
termguicolors = true,
colorscheme = 'moonlight',
hidden_files = true,
wrap_lines = false,
number = true,
relative_number = true,
shell = 'zsh',
timeoutlen = 100,
number = true,
scrolloff = 8,
noshowmode = true,
splitright = true,
splitbelow = true,
database = {save_location = '~/.config/nvcode_db', auto_execute = 1},
python = {
linter = 'flake8',
-- @usage can be 'yapf', 'black'
formatter = 'black',
autoformat = false,
isort = false,
diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true},
analysis = {type_checking = "basic", auto_search_paths = true, use_library_code_types = true}
},
lua = {
-- @usage can be 'lua-format'
formatter = '',
autoformat = false,
diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true}
},
sh = {
-- @usage can be 'shellcheck'
linter = '',
-- @usage can be 'shfmt'
formatter = '',
autoformat = false,
diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true}
},
tsserver = {
-- @usage can be 'eslint'
linter = '',
-- @usage can be 'prettier'
formatter = '',
autoformat = false,
diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true}
},
json = {
-- @usage can be 'prettier'
formatter = '',
autoformat = false,
diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true}
},
clang = {diagnostics = {virtual_text = {spacing = 0, prefix = ""}, signs = true, underline = true}},
ruby = {
diagnostics = {virtualtext = {spacing = 0, prefix = ""}, signs = true, underline = true},
filetypes = {'rb', 'erb', 'rakefile'}
},
-- css = {formatter = '', autoformat = false, virtual_text = true},
-- json = {formatter = '', autoformat = false, virtual_text = true}
}
DATA_PATH = vim.fn.stdpath('data')
CACHE_PATH = vim.fn.stdpath('cache')

View File

@@ -0,0 +1,155 @@
vim.g.mapleader = ' '
-- TODO find better place
vim.g.floaterm_open_command = 'vsplit'
-- better window movement
vim.api.nvim_set_keymap('n', '<C-h>', '<C-w>h', {silent = true})
vim.api.nvim_set_keymap('n', '<C-j>', '<C-w>j', {silent = true})
vim.api.nvim_set_keymap('n', '<C-k>', '<C-w>k', {silent = true})
vim.api.nvim_set_keymap('n', '<C-l>', '<C-w>l', {silent = true})
-- TODO fix this
-- Terminal window navigation
vim.cmd([[
tnoremap <C-h> <C-\><C-N><C-w>h
tnoremap <C-j> <C-\><C-N><C-w>j
tnoremap <C-k> <C-\><C-N><C-w>k
tnoremap <C-l> <C-\><C-N><C-w>l
inoremap <C-h> <C-\><C-N><C-w>h
inoremap <C-j> <C-\><C-N><C-w>j
inoremap <C-k> <C-\><C-N><C-w>k
inoremap <C-l> <C-\><C-N><C-w>l
tnoremap <Esc> <C-\><C-n>
]])
-- TODO fix this
-- resize with arrows
vim.cmd([[
nnoremap <silent> <C-Up> :resize -2<CR>
nnoremap <silent> <C-Down> :resize +2<CR>
nnoremap <silent> <C-Left> :vertical resize +2<CR>
nnoremap <silent> <C-Right> :vertical resize -2<CR>
]])
-- improved keyboard support for navigation (especially terminal)
vim.cmd([[
nnoremap <leader>h <C-w>h
nnoremap <leader>j <C-w>j
nnoremap <leader>k <C-w>k
nnoremap <leader>l <C-w>l
nnoremap <A-h> <C-w>h
nnoremap <A-j> <C-w>j
nnoremap <A-k> <C-w>k
nnoremap <A-l> <C-w>l
]])
-- Change 2 split windows from vert to horiz or horiz to vert
vim.cmd([[
map <leader>th <C-w>t<C-w>H
map <leader>tk <C-w>t<C-w>K
]])
-- Make adjusting split sizes a bit more friendly
vim.cmd([[
noremap <silent> <C-Left> :vertical resize +3<CR>
noremap <silent> <C-Right> :vertical resize -3<CR>
noremap <silent> <C-Up> :resize +3<CR>
noremap <silent> <C-Down> :resize -3<CR>
]])
-- FloatTerm
vim.cmd([[
nnoremap <silent> <F9> :FloatermNew --height=0.4 --width=0.98 --wintype=floating --position=bottom --autoclose=2 --title=
tnoremap <silent> <F9> <C-\><C-n>:FloatermNew --height=0.4 --width=0.98 --wintype=floating --position=bottom --autoclose=2 --title=
nnoremap <silent> <F8> :FloatermPrev<CR>
tnoremap <silent> <F8> <C-\><C-n>:FloatermPrev<CR>
nnoremap <silent> <F10> :FloatermNext<CR>
tnoremap <silent> <F10> <C-\><C-n>:FloatermNext<CR>
inoremap <silent> <F11> <C-c>:FloatermToggle<CR>
nnoremap <silent> <F11> :FloatermToggle<CR>
tnoremap <silent> <F11> <C-\><C-n>:FloatermToggle<CR>
tnoremap <silent> <M-o> <C-\><C-n><CR>
nnoremap <C-c><C-c> :FloatermSend<CR>
vnoremap <C-c><C-c> :FloatermSend<CR>
]])
-- Telescope
vim.cmd([[
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <C-b> <cmd>Telescope buffers<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
]])
-- better indenting
vim.api.nvim_set_keymap('v', '<', '<gv', {noremap = true, silent = true})
vim.api.nvim_set_keymap('v', '>', '>gv', {noremap = true, silent = true})
-- I hate escape
vim.api.nvim_set_keymap('i', 'jk', '<ESC>', {noremap = true, silent = true})
vim.api.nvim_set_keymap('i', 'kj', '<ESC>', {noremap = true, silent = true})
vim.api.nvim_set_keymap('i', 'jj', '<ESC>', {noremap = true, silent = true})
-- Tab switch buffer
vim.api.nvim_set_keymap('n', '<TAB>', ':bnext<CR>', {noremap = true, silent = true})
vim.api.nvim_set_keymap('n', '<S-TAB>', ':bprevious<CR>', {noremap = true, silent = true})
-- Move selected line / block of text in visual mode
vim.api.nvim_set_keymap('x', 'K', ':move \'<-2<CR>gv-gv', {noremap = true, silent = true})
vim.api.nvim_set_keymap('x', 'J', ':move \'>+1<CR>gv-gv', {noremap = true, silent = true})
vim.cmd([[
if !exists('g:vscode')
" Let quit work as expected if after entering :q the only window left open is NERD Tree itself
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" Toggle NERDTree
" Can't get <C-Space> by itself to work, so this works as Ctrl - space - space
" https://github.com/neovim/neovim/issues/3101
" http://stackoverflow.com/questions/7722177/how-do-i-map-ctrl-x-ctrl-o-to-ctrl-space-in-terminal-vim#answer-24550772
"nnoremap <C-Space> :NERDTreeToggle<CR>
"nmap <C-@> <C-Space>
"nnoremap <silent> <M-b> :NERDTreeToggle<CR>
" toggle tagbar
nnoremap <silent> <leader>tb :TagbarToggle<CR>
" toggle line wrap
nnoremap <silent> <leader>w :set wrap! wrap?<CR>
" toggle buffer (switch between current and last buffer)
nnoremap <silent> <leader>bb <C-^>
" close buffer
nnoremap <silent> <leader>bd :bd<CR>
" kill buffer
nnoremap <silent> <leader>bk :bd!<CR>
" list buffers
nnoremap <silent> <leader>bl :ls<CR>
" list and select buffer
nnoremap <silent> <leader>bg :ls<CR>:buffer<Space>
" Telescope project
nnoremap <silent> <leader>fp :Telescope project<CR>
" Automatic formatting for Julia files
autocmd FileType julia nnoremap <buffer> <c-f> :JuliaFormatterFormat<cr>
" Maps quit
noremap <leader>q :q<cr>
" Maps quit all
noremap <c-q> :qa<cr>
" Maps write
nnoremap <leader>w :w<cr>
end
]])

View File

@@ -0,0 +1,6 @@
-- npm install -g dockerfile-language-server-nodejs
require'lspconfig'.dockerls.setup {
cmd = {DATA_PATH .. "/lspinstall/dockerfile/node_modules/.bin/docker-langserver", "--stdio"},
on_attach = require'lsp'.common_on_attach,
root_dir = vim.loop.cwd
}

View File

@@ -0,0 +1,10 @@
require'lspconfig'.elixirls.setup{
cmd = { DATA_PATH .. "/lspinstall/elixir/elixir-ls/language_server.sh"};
}
-- needed for the LSP to recognize elixir files (alternativly just use elixir-editors/vim-elixir)
vim.cmd([[
au BufRead,BufNewFile *.ex,*.exs set filetype=elixir
au BufRead,BufNewFile *.eex,*.leex,*.sface set filetype=eelixir
au BufRead,BufNewFile mix.lock set filetype=elixir
]])

View File

@@ -0,0 +1,7 @@
require'lspconfig'.gopls.setup{
cmd = {DATA_PATH .. "/lspinstall/go/gopls"},
settings = {gopls = {analyses = {unusedparams = true}, staticcheck = true}},
root_dir = require'lspconfig'.util.root_pattern(".git","go.mod","."),
init_options = {usePlaceholders = true, completeUnimported = true},
on_attach = require'lsp'.common_on_attach
}

View File

@@ -0,0 +1,116 @@
-- TODO figure out why this don't work
vim.fn.sign_define(
"LspDiagnosticsSignError",
{texthl = "LspDiagnosticsSignError", text = "", numhl = "LspDiagnosticsSignError"}
)
vim.fn.sign_define(
"LspDiagnosticsSignWarning",
{texthl = "LspDiagnosticsSignWarning", text = "", numhl = "LspDiagnosticsSignWarning"}
)
vim.fn.sign_define(
"LspDiagnosticsSignHint",
{texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint"}
)
vim.fn.sign_define(
"LspDiagnosticsSignInformation",
{texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation"}
)
vim.cmd("nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>")
vim.cmd("nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>")
vim.cmd("nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>")
vim.cmd("nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>")
vim.cmd("nnoremap <silent> ca :Lspsaga code_action<CR>")
vim.cmd("nnoremap <silent> K :Lspsaga hover_doc<CR>")
-- vim.cmd('nnoremap <silent> <C-k> <cmd>lua vim.lsp.buf.signature_help()<CR>')
vim.cmd("nnoremap <silent> <C-p> :Lspsaga diagnostic_jump_prev<CR>")
vim.cmd("nnoremap <silent> <C-n> :Lspsaga diagnostic_jump_next<CR>")
-- -- scroll down hover doc or scroll in definition preview
-- vim.cmd("nnoremap <silent> <C-f> <cmd>lua require('lspsaga.action').smart_scroll_with_saga(1)<CR>")
-- -- scroll up hover doc
-- vim.cmd("nnoremap <silent> <C-b> <cmd>lua require('lspsaga.action').smart_scroll_with_saga(-1)<CR>")
-- vim.cmd('command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()')
-- Set Default Prefix.
-- Note: You can set a prefix per lsp server in the lv-globals.lua file
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics, {
virtual_text = {
prefix = "",
spacing = 0,
},
signs = true,
underline = true,
}
)
-- symbols for autocomplete
vim.lsp.protocol.CompletionItemKind = {
"  (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)"
}
--[[ " autoformat
autocmd BufWritePre *.js lua vim.lsp.buf.formatting_sync(nil, 100)
autocmd BufWritePre *.jsx lua vim.lsp.buf.formatting_sync(nil, 100)
autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 100) ]]
-- Java
-- autocmd FileType java nnoremap ca <Cmd>lua require('jdtls').code_action()<CR>
local function documentHighlight(client, bufnr)
-- Set autocommands conditional on server_capabilities
if client.resolved_capabilities.document_highlight then
vim.api.nvim_exec(
[[
hi LspReferenceRead cterm=bold ctermbg=red guibg=#464646
hi LspReferenceText cterm=bold ctermbg=red guibg=#464646
hi LspReferenceWrite cterm=bold ctermbg=red guibg=#464646
augroup lsp_document_highlight
autocmd! * <buffer>
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
augroup END
]],
false
)
end
end
local lsp_config = {}
function lsp_config.common_on_attach(client, bufnr)
documentHighlight(client, bufnr)
end
function lsp_config.tsserver_on_attach(client, bufnr)
lsp_config.common_on_attach(client, bufnr)
client.resolved_capabilities.document_formatting = false
end
-- Use a loop to conveniently both setup defined servers
-- and map buffer local keybindings when the language server attaches
-- local servers = {"pyright", "tsserver"}
-- for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup {on_attach = on_attach} end
return lsp_config

View File

@@ -0,0 +1,16 @@
-- npm install -g vscode-json-languageserver
require'lspconfig'.jsonls.setup {
cmd = {
"node", DATA_PATH .. "/lspinstall/json/vscode-json/json-language-features/server/dist/node/jsonServerMain.js",
"--stdio"
},
on_attach = require'lsp'.common_on_attach,
commands = {
Format = {
function()
vim.lsp.buf.range_formatting({}, {0, 0}, {vim.fn.line("$"), 0})
end
}
}
}

View File

@@ -0,0 +1 @@
require'lspconfig'.julials.setup{}

View File

@@ -0,0 +1,22 @@
-- npm i -g pyright
require'lspconfig'.pyright.setup {
cmd = {DATA_PATH .. "/lspinstall/python/node_modules/.bin/pyright-langserver", "--stdio"},
on_attach = require'lsp'.common_on_attach,
handlers = {
["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
virtual_text = O.python.diagnostics.virtual_text,
signs = O.python.diagnostics.signs,
underline = O.python.diagnostics.underline,
update_in_insert = true
})
},
settings = {
python = {
analysis = {
typeCheckingMode = O.python.analysis.type_checking,
autoSearchPaths = O.python.analysis.auto_search_paths,
useLibraryCodeForTypes = O.python.analysis.use_library_code_types
}
}
}
}

View File

@@ -0,0 +1,4 @@
require'lspconfig'.terraformls.setup{
cmd = {DATA_PATH .. "/lspinstall/terraform/terraform-ls", "serve"},
on_attach = require'lsp'.common_on_attach
}

View File

@@ -0,0 +1,46 @@
vim.o.completeopt = "menuone,noselect"
require'compe'.setup {
enabled = true;
autocomplete = true;
debug = false;
min_length = 1;
preselect = 'enable';
throttle_time = 80;
source_timeout = 200;
incomplete_delay = 400;
max_abbr_width = 100;
max_kind_width = 100;
max_menu_width = 100;
documentation = false;
source = {
path = true;
buffer = true;
calc = true;
vsnip = true;
nvim_lsp = true;
nvim_lua = true;
spell = true;
tags = true;
snippets_nvim = true;
treesitter = true;
};
}
local t = function(str)
return vim.api.nvim_replace_termcodes(str, true, true, true)
end
_G.s_tab_complete = function()
if vim.fn.pumvisible() == 1 then
return t "<C-p>"
elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then
return t "<Plug>(vsnip-jump-prev)"
else
return t "<S-Tab>"
end
end
vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true})
vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})

View File

@@ -0,0 +1,71 @@
local actions = require('telescope.actions')
-- Global remapping
------------------------------
-- '--color=never',
require('telescope').setup {
defaults = {
find_command = {'rg', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case'},
prompt_position = "bottom",
-- prompt_prefix = " ",
prompt_prefix = "",
selection_caret = "",
entry_prefix = " ",
initial_mode = "insert",
selection_strategy = "reset",
sorting_strategy = "descending",
layout_strategy = "horizontal",
layout_defaults = {horizontal = {mirror = false}, vertical = {mirror = false}},
file_sorter = require'telescope.sorters'.get_fuzzy_file,
file_ignore_patterns = {},
generic_sorter = require'telescope.sorters'.get_generic_fuzzy_sorter,
shorten_path = true,
winblend = 0,
width = 0.75,
preview_cutoff = 120,
results_height = 1,
results_width = 0.8,
border = {},
borderchars = {'', '', '', '', '', '', '', ''},
color_devicons = true,
use_less = true,
set_env = {['COLORTERM'] = 'truecolor'}, -- default = nil,
file_previewer = require'telescope.previewers'.vim_buffer_cat.new,
grep_previewer = require'telescope.previewers'.vim_buffer_vimgrep.new,
qflist_previewer = require'telescope.previewers'.vim_buffer_qflist.new,
-- Developer configurations: Not meant for general override
buffer_previewer_maker = require'telescope.previewers'.buffer_previewer_maker,
mappings = {
i = {
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
-- To disable a keymap, put [map] = false
-- So, to not map "<C-n>", just put
-- ["<c-x>"] = false,
["<esc>"] = actions.close,
-- Otherwise, just set the mapping to the function that you want it to be.
-- ["<C-i>"] = actions.select_horizontal,
-- Add up multiple actions
["<CR>"] = actions.select_default + actions.center
-- You can perform as many actions in a row as you like
-- ["<CR>"] = actions.select_default + actions.center + my_cool_custom_action,
},
n = {
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
-- ["<C-i>"] = my_cool_custom_action,
}
}
},
extensions = {
fzy_native = {
override_generic_sorter = false,
override_file_sorter = true,
}
}
}

View File

@@ -0,0 +1,115 @@
require("which-key").setup {
plugins = {
marks = true, -- shows a list of your marks on ' and `
registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
-- the presets plugin, adds help for a bunch of default keybindings in Neovim
-- No actual key bindings are created
presets = {
operators = true, -- adds help for operators like d, y, ...
motions = true, -- adds help for motions
text_objects = true, -- help for text objects triggered after entering an operator
windows = true, -- default bindings on <c-w>
nav = true, -- misc bindings to work with windows
z = true, -- bindings for folds, spelling and others prefixed with z
g = true -- bindings for prefixed with g
}
},
icons = {
breadcrumb = "»", -- symbol used in the command line area that shows your active key combo
separator = "", -- symbol used between a key and it's label
group = "+" -- symbol prepended to a group
},
window = {
border = "single", -- none, single, double, shadow
position = "bottom", -- bottom, top
margin = {1, 0, 1, 0}, -- extra window margin [top, right, bottom, left]
padding = {2, 2, 2, 2} -- extra window padding [top, right, bottom, left]
},
layout = {
height = {min = 4, max = 25}, -- min and max height of the columns
width = {min = 20, max = 50}, -- min and max width of the columns
spacing = 3 -- spacing between columns
},
hidden = {"<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ "}, -- hide mapping boilerplate
show_help = true -- show help message on the command line when the popup is visible
}
local opts = {
mode = "n", -- NORMAL mode
prefix = "<leader>",
buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings
silent = true, -- use `silent` when creating keymaps
noremap = true, -- use `noremap` when creating keymaps
nowait = false -- use `nowait` when creating keymaps
}
-- Set leader
vim.api.nvim_set_keymap('n', '<Space>', '<NOP>', {noremap = true, silent = true})
vim.g.mapleader = ' '
-- explorer
vim.api.nvim_set_keymap('n', '<Leader>e', ':NERDTreeToggle<CR>', {noremap = true, silent = true})
-- dashboard
vim.api.nvim_set_keymap('n', '<Leader>;', ':Dashboard<CR>', {noremap = true, silent = true})
-- TODO create entire treesitter section
local mappings = {
["/"] = "Comment",
["e"] = "Explorer",
f = {
f = {":Telescope find_files<CR>", "Find File"}
},
["f"] = "Find File",
g = {
name = "+Git",
j = {"<cmd>NextHunk<cr>", "Next Hunk"},
k = {"<cmd>PrevHunk<cr>", "Prev Hunk"},
p = {"<cmd>PreviewHunk<cr>", "Preview Hunk"},
r = {"<cmd>ResetHunk<cr>", "Reset Hunk"},
R = {"<cmd>ResetBuffer<cr>", "Reset Buffer"},
s = {"<cmd>StageHunk<cr>", "Stage Hunk"},
u = {"<cmd>UndoStageHunk<cr>", "Undo Stage Hunk"},
o = {"<cmd>Telescope git_status<cr>", "Open changed file"},
b = {"<cmd>Telescope git_branches<cr>", "Checkout branch"},
c = {"<cmd>Telescope git_commits<cr>", "Checkout commit"},
C = {"<cmd>Telescope git_bcommits<cr>", "Checkout commit(for current file)"},
},
l = {
name = "+LSP",
a = {"<cmd>Lspsaga code_action<cr>", "Code Action"},
A = {"<cmd>Lspsaga range_code_action<cr>", "Selected Action"},
d = {"<cmd>Telescope lsp_document_diagnostics<cr>", "Document Diagnostics"},
D = {"<cmd>Telescope lsp_workspace_diagnostics<cr>", "Workspace Diagnostics"},
f = {"<cmd>LspFormatting<cr>", "Format"},
i = {"<cmd>LspInfo<cr>", "Info"},
l = {"<cmd>Lspsaga lsp_finder<cr>", "LSP Finder"},
L = {"<cmd>Lspsaga show_line_diagnostics<cr>", "Line Diagnostics"},
p = {"<cmd>Lspsaga preview_definition<cr>", "Preview Definition"},
q = {"<cmd>Telescope quickfix<cr>", "Quickfix"},
r = {"<cmd>Lspsaga rename<cr>", "Rename"},
t = {"<cmd>LspTypeDefinition<cr>", "Type Definition"},
x = {"<cmd>cclose<cr>", "Close Quickfix"},
s = {"<cmd>Telescope lsp_document_symbols<cr>", "Document Symbols"},
S = {"<cmd>Telescope lsp_workspace_symbols<cr>", "Workspace Symbols"}
},
s = {
name = "+Search",
b = {"<cmd>Telescope git_branches<cr>", "Checkout branch"},
c = {"<cmd>Telescope colorscheme<cr>", "Colorscheme"},
d = {"<cmd>Telescope lsp_document_diagnostics<cr>", "Document Diagnostics"},
D = {"<cmd>Telescope lsp_workspace_diagnostics<cr>", "Workspace Diagnostics"},
f = {"<cmd>Telescope find_files<cr>", "Find File"},
m = {"<cmd>Telescope marks<cr>", "Marks"},
M = {"<cmd>Telescope man_pages<cr>", "Man Pages"},
r = {"<cmd>Telescope oldfiles<cr>", "Open Recent File"},
R = {"<cmd>Telescope registers<cr>", "Registers"},
t = {"<cmd>Telescope live_grep<cr>", "Text"}
},
S = {name = "+Session", s = {"<cmd>SessionSave<cr>", "Save Session"}, l = {"<cmd>SessionLoad<cr>", "Load Session"}}
}
local wk = require("which-key")
wk.register(mappings, opts)

View File

@@ -0,0 +1,36 @@
vim.cmd('set iskeyword+=-') -- treat dash separated words as a word text object"
vim.cmd('set shortmess+=c') -- Don't pass messages to |ins-completion-menu|.
vim.cmd('set inccommand=split') -- Make substitution work in realtime
vim.o.hidden = O.hidden_files -- Required to keep multiple buffers open multiple buffers
vim.o.title = true
TERMINAL = vim.fn.expand('$TERMINAL')
vim.cmd('let &titleold="'..TERMINAL..'"')
vim.o.titlestring="%<%F%=%l/%L - nvim"
vim.wo.wrap = O.wrap_lines -- Display long lines as just one line
vim.cmd('set whichwrap+=<,>,[,],h,l') -- move to next line with theses keys
vim.cmd('syntax on') -- syntax highlighting
vim.o.pumheight = 10 -- Makes popup menu smaller
vim.o.fileencoding = "utf-8" -- The encoding written to file
vim.o.cmdheight = 2 -- More space for displaying messages
vim.cmd('set colorcolumn=99999') -- fix indentline for now
vim.o.mouse = "a" -- Enable your mouse
vim.o.splitbelow = true -- Horizontal splits will automatically be below
vim.o.termguicolors = true -- set term gui colors most terminals support this
vim.o.splitright = true -- Vertical splits will automatically be to the right
vim.o.t_Co = "256" -- Support 256 colors
vim.o.conceallevel = 0 -- So that I can see `` in markdown files
vim.cmd('set ts=4') -- Insert 4 spaces for a tab
vim.cmd('set sw=4') -- Change the number of space characters inserted for indentation
vim.cmd('set expandtab') -- Converts tabs to spaces
vim.bo.smartindent = true -- Makes indenting smart
vim.wo.number = O.number -- set numbered lines
vim.wo.relativenumber = O.relative_number -- set relative number
vim.wo.cursorline = true -- Enable highlighting of the current line
vim.o.showtabline = 2 -- Always show tabs
vim.o.showmode = false -- We don't need to see things like -- INSERT -- anymore
vim.o.backup = false -- This is recommended by coc
vim.o.writebackup = false -- This is recommended by coc
vim.wo.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time
vim.o.updatetime = 300 -- Faster completion
vim.o.timeoutlen = O.timeoutlen -- By default timeoutlen is 1000 ms
vim.o.clipboard = "unnamedplus" -- Copy paste between vim and everything else