The Lua Journey Begins...

This commit is contained in:
Christian Chiarulli 2021-03-14 15:10:28 -04:00 committed by GitHub
parent d002b0419a
commit 0dc3c5030b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
102 changed files with 292 additions and 7863 deletions

3
lua/colorscheme.lua Normal file
View file

@ -0,0 +1,3 @@
vim.cmd('colorscheme nvcode')
vim.cmd('let g:nvcode_termcolors=256')
--vim.api.nvim_exec([[colorscheme nvcode]])

36
lua/keymappings.lua Normal file
View file

@ -0,0 +1,36 @@
vim.api.nvim_set_keymap('n', '<Space>', '<NOP>', { noremap = true, silent = true })
vim.g.mapleader = ' '
-- no hl
vim.api.nvim_set_keymap('n', '<Leader>h', ':set hlsearch!<CR>', { noremap = true, silent = true })
-- explorer
vim.api.nvim_set_keymap('n', '<Leader>e', ':NvimTreeToggle<CR>', { noremap = true, silent = true })
-- 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 })
-- 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 })
-- TAB Complete
--vim.api.nvim_set_keymap('i', '<expr><TAB>', 'pumvisible() ? \"\\<C-n>\" : \"\\<TAB>\"', { noremap = true, silent = true })

View file

@ -1,254 +0,0 @@
local lsp_wrapper = {}
-- buf
function lsp_wrapper.add_to_workspace_folder()
vim.lsp.buf.add_workspace_folder()
end
function lsp_wrapper.clear_references()
vim.lsp.buf.clear_references()
end
function lsp_wrapper.code_action()
vim.lsp.buf.code_action()
end
function lsp_wrapper.declaration()
vim.lsp.buf.declaration()
vim.lsp.buf.clear_references()
end
function lsp_wrapper.definition()
vim.lsp.buf.definition()
vim.lsp.buf.clear_references()
end
function lsp_wrapper.document_highlight()
vim.lsp.buf.document_highlight()
end
function lsp_wrapper.document_symbol()
vim.lsp.buf.document_symbol()
end
function lsp_wrapper.formatting()
vim.lsp.buf.formatting()
end
function lsp_wrapper.formatting_sync()
vim.lsp.buf.formatting_sync()
end
function lsp_wrapper.hover()
vim.lsp.buf.hover()
end
function lsp_wrapper.implementation()
vim.lsp.buf.implementation()
end
function lsp_wrapper.incoming_calls()
vim.lsp.buf.incoming_calls()
end
function lsp_wrapper.list_workspace_folders()
vim.lsp.buf.list_workspace_folders()
end
function lsp_wrapper.outgoing_calls()
vim.lsp.buf.outgoing_calls()
end
function lsp_wrapper.range_code_action()
vim.lsp.buf.range_code_action()
end
function lsp_wrapper.range_formatting()
vim.lsp.buf.range_formatting()
end
function lsp_wrapper.references()
vim.lsp.buf.references()
vim.lsp.buf.clear_references()
end
function lsp_wrapper.remove_workspace_folder()
vim.lsp.buf.remove_workspace_folder()
end
function lsp_wrapper.rename()
vim.lsp.buf.rename()
end
function lsp_wrapper.signature_help()
vim.lsp.buf.signature_help()
end
function lsp_wrapper.type_definition()
vim.lsp.buf.type_definition()
end
function lsp_wrapper.workspace_symbol()
vim.lsp.buf.workspace_symbol()
end
-- diagnostic
function lsp_wrapper.get_all()
vim.lsp.diagnostic.get_all()
end
function lsp_wrapper.get_next()
vim.lsp.diagnostic.get_next()
end
function lsp_wrapper.get_prev()
vim.lsp.diagnostic.get_prev()
end
function lsp_wrapper.goto_next()
vim.lsp.diagnostic.goto_next()
end
function lsp_wrapper.goto_prev()
vim.lsp.diagnostic.goto_prev()
end
function lsp_wrapper.show_line_diagnostics()
vim.lsp.diagnostic.show_line_diagnostics()
end
-- misc
-- :lua print(vim.inspect(vim.lsp.buf_get_clients()))
-- autoformat
-- autocmd BufWritePre *.rs lua vim.lsp.buf.formatting_sync(nil, 1000)
return lsp_wrapper
-- You can see more about the differences in types here:
-- https://microsoft.github.io/language-server-protocol/specification#textDocument_documentHighlight
-- *hl-LspReferenceText*
-- LspReferenceText used for highlighting "text" references
-- *hl-LspReferenceRead*
-- LspReferenceRead used for highlighting "read" references
-- *hl-LspReferenceWrite*
-- LspReferenceWrite used for highlighting "write" references
-- *lsp-highlight-diagnostics*
-- All highlights defined for diagnostics begin with `LspDiagnostics` followed by
-- the type of highlight (e.g., `Sign`, `Underline`, etc.) and then the Severity
-- of the highlight (e.g. `Error`, `Warning`, etc.)
-- Sign, underline and virtual text highlights (by default) are linked to their
-- corresponding LspDiagnosticsDefault highlight.
-- For example, the default highlighting for |hl-LspDiagnosticsSignError| is
-- linked to |hl-LspDiagnosticsDefaultError|. To change the default (and
-- therefore the linked highlights), use the |:highlight| command: >
-- highlight LspDiagnosticsDefaultError guifg="BrightRed"
-- <
-- *hl-LspDiagnosticsDefaultError*
-- LspDiagnosticsDefaultError
-- Used as the base highlight group.
-- Other LspDiagnostic highlights link to this by default (except Underline)
-- *hl-LspDiagnosticsDefaultWarning*
-- LspDiagnosticsDefaultWarning
-- Used as the base highlight group.
-- Other LspDiagnostic highlights link to this by default (except Underline)
-- *hl-LspDiagnosticsDefaultInformation*
-- LspDiagnosticsDefaultInformation
-- Used as the base highlight group.
-- Other LspDiagnostic highlights link to this by default (except Underline)
-- *hl-LspDiagnosticsDefaultHint*
-- LspDiagnosticsDefaultHint
-- Used as the base highlight group.
-- Other LspDiagnostic highlights link to this by default (except Underline)
-- *hl-LspDiagnosticsVirtualTextError*
-- LspDiagnosticsVirtualTextError
-- Used for "Error" diagnostic virtual text.
-- See |vim.lsp.diagnostic.set_virtual_text()|
-- *hl-LspDiagnosticsVirtualTextWarning*
-- LspDiagnosticsVirtualTextWarning
-- Used for "Warning" diagnostic virtual text.
-- See |vim.lsp.diagnostic.set_virtual_text()|
-- *hl-LspDiagnosticsVirtualTextInformation*
-- LspDiagnosticsVirtualTextInformation
-- Used for "Information" diagnostic virtual text.
-- See |vim.lsp.diagnostic.set_virtual_text()|
-- *hl-LspDiagnosticsVirtualTextHint*
-- LspDiagnosticsVirtualTextHint
-- Used for "Hint" diagnostic virtual text.
-- See |vim.lsp.diagnostic.set_virtual_text()|
-- *hl-LspDiagnosticsUnderlineError*
-- LspDiagnosticsUnderlineError
-- Used to underline "Error" diagnostics.
-- See |vim.lsp.diagnostic.set_underline()|
-- *hl-LspDiagnosticsUnderlineWarning*
-- LspDiagnosticsUnderlineWarning
-- Used to underline "Warning" diagnostics.
-- See |vim.lsp.diagnostic.set_underline()|
-- *hl-LspDiagnosticsUnderlineInformation*
-- LspDiagnosticsUnderlineInformation
-- Used to underline "Information" diagnostics.
-- See |vim.lsp.diagnostic.set_underline()|
-- *hl-LspDiagnosticsUnderlineHint*
-- LspDiagnosticsUnderlineHint
-- Used to underline "Hint" diagnostics.
-- See |vim.lsp.diagnostic.set_underline()|
-- *hl-LspDiagnosticsFloatingError*
-- LspDiagnosticsFloatingError
-- Used to color "Error" diagnostic messages in diagnostics float.
-- See |vim.lsp.diagnostic.show_line_diagnostics()|
-- *hl-LspDiagnosticsFloatingWarning*
-- LspDiagnosticsFloatingWarning
-- Used to color "Warning" diagnostic messages in diagnostics float.
-- See |vim.lsp.diagnostic.show_line_diagnostics()|
-- *hl-LspDiagnosticsFloatingInformation*
-- LspDiagnosticsFloatingInformation
-- Used to color "Information" diagnostic messages in diagnostics float.
-- See |vim.lsp.diagnostic.show_line_diagnostics()|
-- *hl-LspDiagnosticsFloatingHint*
-- LspDiagnosticsFloatingHint
-- Used to color "Hint" diagnostic messages in diagnostics float.
-- See |vim.lsp.diagnostic.show_line_diagnostics()|
-- *hl-LspDiagnosticsSignError*
-- LspDiagnosticsSignError
-- Used for "Error" signs in sign column.
-- See |vim.lsp.diagnostic.set_signs()|
-- *hl-LspDiagnosticsSignWarning*
-- LspDiagnosticsSignWarning
-- Used for "Warning" signs in sign column.
-- See |vim.lsp.diagnostic.set_signs()|
-- *hl-LspDiagnosticsSignInformation*
-- LspDiagnosticsSignInformation
-- Used for "Information" signs in sign column.
-- See |vim.lsp.diagnostic.set_signs()|
-- *hl-LspDiagnosticsSignHint*
-- LspDiagnosticsSignHint
-- Used for "Hint" signs in sign column.
-- See |vim.lsp.diagnostic.set_signs()|

View file

@ -1,37 +0,0 @@
command! LspCodeAction lua require 'lsp-wrapper'.code_action()
command! LspDeclaration lua require 'lsp-wrapper'.declaration()
command! LspDefinition lua require 'lsp-wrapper'.definition()
command! LspDocumentSymbol lua require 'lsp-wrapper'.document_symbol()
command! LspFormatting lua require 'lsp-wrapper'.formatting()
command! LspFormattingSync lua require 'lsp-wrapper'.formatting_sync()
command! LspHover lua require 'lsp-wrapper'.hover()
command! LspImplementation lua require 'lsp-wrapper'.implementation()
command! LspRangeCodeAction lua require 'lsp-wrapper'.range_code_action()
command! LspRangeFormatting lua require 'lsp-wrapper'.range_formatting()
command! LspReferences lua require 'lsp-wrapper'.references()
command! LspRename lua require 'lsp-wrapper'.rename()
command! LspTypeDefinition lua require 'lsp-wrapper'.type_definition()
command! LspWorkspaceSymbol lua require 'lsp-wrapper'.workspace_symbol()
command! LspGotoNext lua require 'lsp-wrapper'.goto_next()
command! LspGotoPrev lua require 'lsp-wrapper'.goto_prev()
command! LspShowLineDiagnostics lua require 'lsp-wrapper'.show_line_diagnostics()
" command! LspAddToWorkspaceFolder lua require 'lsp-wrapper'.add_to_workspace_folder()
" command! LspRemoveWorkspaceFolder lua require 'lsp-wrapper'.remove_workspace_folder()
" command! LspListWorkspaceFolders lua require 'lsp-wrapper'.list_workspace_folders()
" command! LspClearReferences lua require 'lsp-wrapper'.clear_references()
" command! LspGetNext lua require 'lsp-wrapper'.get_next()
" command! LspGetPrev lua require 'lsp-wrapper'.get_prev()
" command! LspGetAll lua require 'lsp-wrapper'.get_all()
" command! LspIncomingCalls lua require 'lsp-wrapper'.incoming_calls()
" command! LspOutGoingCalls lua require 'lsp-wrapper'.outgoing_calls()
" command! LspDocumentHighlight lua require 'lsp-wrapper'.document_highlight()
" Java
" command! FileType java LspCodeAction <Esc><Cmd>lua require('jdtls').code_action(true)<CR>
" command! FileType java LspCodeAction <Esc><Cmd>lua require('jdtls').code_action(false, 'refactor')<CR>
" nnoremap <A-o> <Cmd>lua require'jdtls'.organize_imports()<CR>
" nnoremap crv <Cmd>lua require('jdtls').extract_variable()<CR>
" vnoremap crv <Esc><Cmd>lua require('jdtls').extract_variable(true)<CR>
" vnoremap crm <Esc><Cmd>lua require('jdtls').extract_method(true)<CR>

View file

@ -1,3 +0,0 @@
-- npm i -g bash-language-server
require'lspconfig'.bashls.setup{}

View file

@ -1,3 +0,0 @@
-- npm install -g vscode-css-languageserver-bin
require'lspconfig'.cssls.setup{}

View file

@ -1,3 +0,0 @@
-- npm install -g dockerfile-language-server-nodejs
require'lspconfig'.dockerls.setup{}

View file

@ -1,15 +0,0 @@
require"lspconfig".efm.setup {
init_options = {documentFormatting = true},
filetypes = {"lua"},
settings = {
rootMarkers = {".git/"},
languages = {
lua = {
{
formatCommand = "lua-format -i --no-keep-simple-function-one-line --no-break-after-operator --column-limit=150 --break-after-table-lb",
formatStdin = true
}
}
}
}
}

View file

@ -1,3 +0,0 @@
-- npm install -g graphql-language-service-cli
require'lspconfig'.graphql.setup{}

View file

@ -1,11 +0,0 @@
-- npm install -g vscode-html-languageserver-bin
--Enable (broadcasting) snippet capability for completion
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
require'lspconfig'.html.setup {
capabilities = capabilities,
}
require'lspconfig'.html.setup{}

0
lua/lsp/init.lua Normal file
View file

View file

@ -1,8 +0,0 @@
-- In Vimscript
-- augroup lsp
-- au!
-- au FileType java lua require('jdtls').start_or_attach({cmd = {'java-linux-ls'}})
-- augroup end
-- find_root looks for parent directories relative to the current buffer containing one of the given arguments.
-- require'lspconfig'.jdtls.setup {cmd = {'java-linux-ls'}}
require('jdtls').start_or_attach({cmd = {'java-linux-ls'}, root_dir = require('jdtls.setup').find_root({'gradle.build', 'pom.xml'})})

View file

@ -1,3 +0,0 @@
-- npm install -g typescript typescript-language-server
require'lspconfig'.tsserver.setup{}

View file

@ -1,11 +0,0 @@
-- npm install -g vscode-json-languageserver
require'lspconfig'.jsonls.setup {
commands = {
Format = {
function()
vim.lsp.buf.range_formatting({},{0,0},{vim.fn.line("$"),0})
end
}
}
}

View file

@ -1,61 +0,0 @@
-- local nvim_lsp = require('lspconfig')
-- local on_attach = function(client, bufnr)
-- local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
-- local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
-- buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- -- Mappings.
-- local opts = { noremap=true, silent=true }
-- buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
-- -- buf_set_keymap('n', 'gd', ':lua vim.lsp.buf.definition()')
-- buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
-- buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
-- buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
-- buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
-- buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
-- buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
-- buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
-- buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
-- buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
-- -- buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
-- buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
-- buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
-- buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
-- buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
-- -- *vim.lsp.buf.code_action()
-- -- Set some keybinds conditional on server capabilities
-- if client.resolved_capabilities.document_formatting then
-- buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
-- elseif client.resolved_capabilities.document_range_formatting then
-- buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.range_formatting()<CR>", opts)
-- end
-- -- Set autocommands conditional on server_capabilities
-- -- if client.resolved_capabilities.document_highlight then
-- -- vim.api.nvim_exec([[
-- -- hi LspReferenceRead cterm=bold ctermbg=red guibg=Pink
-- -- hi LspReferenceText cterm=bold ctermbg=red guibg=Pink
-- -- hi LspReferenceWrite cterm=bold ctermbg=red guibg=Pink
-- -- 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
-- -- Use a loop to conveniently both setup defined servers
-- -- and map buffer local keybindings when the language server attaches
-- local servers = { "pyright", "rust_analyzer", "tsserver" }
-- for _, lsp in ipairs(servers) do
-- nvim_lsp[lsp].setup { on_attach = on_attach }
-- end
vim.fn.sign_define("LspDiagnosticsSignError", {text = "", numhl = "LspDiagnosticsDefaultError"})
vim.fn.sign_define("LspDiagnosticsSignWarning", {text = "", numhl = "LspDiagnosticsDefaultWarning"})
vim.fn.sign_define("LspDiagnosticsSignInformation", {text = "", numhl = "LspDiagnosticsDefaultInformation"})
vim.fn.sign_define("LspDiagnosticsSignHint", {text = "", numhl = "LspDiagnosticsDefaultHint"})

View file

@ -1,27 +0,0 @@
-- commented options are defaults
require('lspkind').init({
with_text = false,
symbol_map = {
Text = '',
Method = '',
Function = '',
Constructor = '',
Variable = '[]',
Class = '',
Interface = '',
Module = '',
Property = '',
Unit = '',
Value = '',
Enum = '',
Keyword = '',
Snippet = '',
Color = '',
File = '',
Folder = '',
EnumMember = '',
Constant = '',
Struct = ''
},
})

View file

@ -5,11 +5,11 @@ local sumneko_root_path = ""
local sumneko_binary = ""
if vim.fn.has("mac") == 1 then
sumneko_root_path = "/Users/" .. USER .. "/.config/nvim/lua-language-server"
sumneko_binary = "/Users/" .. USER .. "/.config/nvim/lua-language-server/bin/macOS/lua-language-server"
sumneko_root_path = "/Users/" .. USER .. "/.config/nvim/ls/lua-language-server"
sumneko_binary = "/Users/" .. USER .. "/.config/nvim/ls/lua-language-server/bin/macOS/lua-language-server"
elseif vim.fn.has("unix") == 1 then
sumneko_root_path = "/home/" .. USER .. "/.config/nvim/lua-language-server"
sumneko_binary = "/home/" .. USER .. "/.config/nvim/lua-language-server/bin/Linux/lua-language-server"
sumneko_root_path = "/home/" .. USER .. "/.config/nvim/ls/lua-language-server"
sumneko_binary = "/home/" .. USER .. "/.config/nvim/ls/lua-language-server/bin/Linux/lua-language-server"
else
print("Unsupported system for sumneko")
end

View file

@ -1,3 +0,0 @@
-- npm i -g pyright
require'lspconfig'.pyright.setup{}

View file

@ -1,3 +0,0 @@
-- npm install -g vim-language-server
require'lspconfig'.vimls.setup{}

View file

@ -1,3 +0,0 @@
-- npm install -g yaml-language-server
require'lspconfig'.yamlls.setup{}

View file

@ -0,0 +1,13 @@
require'bufferline'.setup{}
vim.api.nvim_set_keymap('n', '<TAB>', ':BufferLineCycleNext<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<S-TAB>', ':BufferLineCyclePrev<CR>', { noremap = true, silent = true })
--" These commands will move the current buffer backwards or forwards in the bufferline
--nnoremap <silent><mymap> :BufferLineMoveNext<CR>
--nnoremap <silent><mymap> :BufferLineMovePrev<CR>
--" These commands will sort buffers by directory, language, or a custom criteria
--nnoremap <silent>be :BufferLineSortByExtension<CR>
--nnoremap <silent>bd :BufferLineSortByDirectory<CR>
--nnoremap <silent><mymap> :lua require'bufferline'.sort_buffers_by(function (buf_a, buf_b) return buf_a.id < buf_b.id end)<CR>

View file

@ -1,6 +1,6 @@
require'colorizer'.setup(
{'*';},
{
{
RGB = true; -- #RGB hex codes
RRGGBB = true; -- #RRGGBB hex codes
-- names = true; -- "Name" codes like Blue
@ -10,6 +10,3 @@ require'colorizer'.setup(
css = true; -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
css_fn = true; -- Enable all CSS *functions*: rgb_fn, hsl_fn
})

View file

@ -1,9 +1,3 @@
-- TODO we need snippet support and to maybe get better docs idk
vim.cmd [[set shortmess+=c]]
vim.o.completeopt = "menuone,noselect"
require'compe'.setup {
enabled = true;
autocomplete = true;
@ -13,10 +7,9 @@ require'compe'.setup {
throttle_time = 80;
source_timeout = 200;
incomplete_delay = 400;
allow_prefix_unmatch = false;
max_abbr_width = 1000;
max_kind_width = 1000;
max_menu_width = 1000000;
max_abbr_width = 100;
max_kind_width = 100;
max_menu_width = 100;
documentation = true;
source = {
@ -33,9 +26,37 @@ require'compe'.setup {
};
}
local t = function(str)
return vim.api.nvim_replace_termcodes(str, true, true, true)
end
local check_back_space = function()
local col = vim.fn.col('.') - 1
if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
return true
else
return false
end
end
-- Use (s-)tab to:
--- move to prev/next item in completion menuone
--- jump to prev/next snippet's placeholder
_G.tab_complete = function()
if vim.fn.pumvisible() == 1 then
return t "<C-n>"
elseif vim.fn.call("vsnip#available", {1}) == 1 then
return t "<Plug>(vsnip-expand-or-jump)"
elseif check_back_space() then
return t "<Tab>"
else
return vim.fn['compe#complete']()
end
end
_G.s_tab_complete = function()
if vim.fn.pumvisible() == 1 then
return t "<C-p>"
@ -46,6 +67,7 @@ _G.s_tab_complete = function()
end
end
vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
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

@ -247,25 +247,3 @@ gls.short_line_left[1] = {
highlight = {colors.purple,colors.bg}
}
}
-- gls.short_line_right[1] = {
-- BufferIcon = {
-- provider= 'BufferIcon',
-- separator = ' ',
-- separator_highlight = {colors.purple,colors.bg},
-- highlight = {colors.grey,colors.purple}
-- }
-- }
-- function! s:my_bookmark_color() abort
-- let s:scl_guibg = matchstr(execute('hi SignColumn'), 'guibg=\zs\S*')
-- if empty(s:scl_guibg)
-- let s:scl_guibg = 'NONE'
-- endif
-- exe 'hi MyBookmarkSign guifg=' . s:scl_guibg
-- endfunction
-- call s:my_bookmark_color() " don't remove this line!
-- augroup UserGitSignColumnColor
-- autocmd!
-- autocmd ColorScheme * call s:my_bookmark_color()
-- augroup END

37
lua/nv-gitsigns/init.lua Normal file
View file

@ -0,0 +1,37 @@
require('gitsigns').setup {
signs = {
-- TODO add hl to colorscheme
add = {hl = 'GitSignsAdd' , text = '', numhl='GitSignsAddNr' , linehl='GitSignsAddLn'},
change = {hl = 'GitSignsChange', text = '', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'},
delete = {hl = 'GitSignsDelete', text = '', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'},
topdelete = {hl = 'GitSignsDelete', text = '', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'},
changedelete = {hl = 'GitSignsChange', text = '', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'},
},
numhl = false,
linehl = false,
keymaps = {
-- Default keymap options
noremap = true,
buffer = true,
['n ]c'] = { expr = true, "&diff ? ']c' : '<cmd>lua require\"gitsigns\".next_hunk()<CR>'"},
['n [c'] = { expr = true, "&diff ? '[c' : '<cmd>lua require\"gitsigns\".prev_hunk()<CR>'"},
['n <leader>hs'] = '<cmd>lua require"gitsigns".stage_hunk()<CR>',
['n <leader>hu'] = '<cmd>lua require"gitsigns".undo_stage_hunk()<CR>',
['n <leader>hr'] = '<cmd>lua require"gitsigns".reset_hunk()<CR>',
['n <leader>hp'] = '<cmd>lua require"gitsigns".preview_hunk()<CR>',
['n <leader>hb'] = '<cmd>lua require"gitsigns".blame_line()<CR>',
-- Text objects
['o ih'] = ':<C-U>lua require"gitsigns".text_object()<CR>',
['x ih'] = ':<C-U>lua require"gitsigns".text_object()<CR>'
},
watch_index = {
interval = 1000
},
sign_priority = 6,
update_debounce = 200,
status_formatter = nil, -- Use default
use_decoration_api = false
}

View file

@ -0,0 +1,40 @@
require('nvim-autopairs').setup()
local pairs_map = {
["'"] = "'",
['"'] = '"',
['('] = ')',
['['] = ']',
['{'] = '}',
['`'] = '`',
}
local disable_filetype = { "TelescopePrompt" }
local break_line_filetype = nil -- mean all file type
local html_break_line_filetype = {'html' , 'vue' , 'typescriptreact' , 'svelte' , 'javascriptreact'}
local ignored_next_char = "%w"
local remap = vim.api.nvim_set_keymap
local npairs = require('nvim-autopairs')
-- skip it, if you use another global object
_G.MUtils= {}
vim.g.completion_confirm_key = ""
MUtils.completion_confirm=function()
if vim.fn.pumvisible() ~= 0 then
if vim.fn.complete_info()["selected"] ~= -1 then
vim.fn["compe#confirm"]()
return npairs.esc("<c-y>")
else
vim.defer_fn(function()
vim.fn["compe#confirm"]("<cr>")
end, 20)
return npairs.esc("<c-n>")
end
else
return npairs.check_break_line_char()
end
end
remap('i' , '<CR>','v:lua.MUtils.completion_confirm()', {expr = true , noremap = true})

View file

@ -14,21 +14,3 @@ require'nvim-treesitter.configs'.setup {
}
}
-- require'nvim-treesitter.configs'.setup {
-- refactor = {
-- highlight_current_scope = { enable = false },
-- },
-- }
-- require'nvim-treesitter.configs'.setup {
-- refactor = {
-- smart_rename = {
-- enable = true,
-- keymaps = {
-- smart_rename = "grr",
-- },
-- },
-- },
-- }

69
lua/plugins.lua Normal file
View file

@ -0,0 +1,69 @@
local execute = vim.api.nvim_command
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
execute('!git clone https://github.com/wbthomason/packer.nvim '..install_path)
execute 'packadd packer.nvim'
end
return require('packer').startup(function()
-- Packer can manage itself as an optional plugin
use {'wbthomason/packer.nvim', opt = true}
-- Information
use 'nanotee/nvim-lua-guide'
-- LSP
use 'neovim/nvim-lspconfig'
use 'glepnir/lspsaga.nvim'
use 'onsails/lspkind-nvim'
use 'kosayoda/nvim-lightbulb'
use 'mfussenegger/nvim-jdtls'
-- Debugging
use 'mfussenegger/nvim-dap'
-- Autocomplete
use 'hrsh7th/nvim-compe'
use 'hrsh7th/vim-vsnip'
-- Treesitter
use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' }
use 'nvim-treesitter/playground'
use 'p00f/nvim-ts-rainbow'
-- Icons
use 'kyazdani42/nvim-web-devicons'
-- Status Line and Bufferline
use 'glepnir/galaxyline.nvim'
use {'akinsho/nvim-bufferline.lua', requires = 'kyazdani42/nvim-web-devicons'}
-- Telescope
use 'nvim-lua/popup.nvim'
use 'nvim-lua/plenary.nvim'
use 'nvim-telescope/telescope.nvim'
use 'nvim-telescope/telescope-media-files.nvim'
-- Explorer
use 'kyazdani42/nvim-tree.lua'
-- Color
use 'christianchiarulli/nvcode-color-schemes.vim'
use 'norcalli/nvim-colorizer.lua'
-- Git
use 'TimUntersberger/neogit'
use {'lewis6991/gitsigns.nvim', requires = { 'nvim-lua/plenary.nvim' } }
-- General Plugins
use 'windwp/nvim-autopairs'
use 'kevinhwang91/nvim-bqf'
use 'unblevable/quick-scope'
use 'airblade/vim-rooter'
end)

View file

@ -1,2 +0,0 @@

View file

@ -1,73 +0,0 @@
local actions = require('telescope.actions')
-- Global remapping
------------------------------
-- '--color=never',
require('telescope').load_extension('media_files')
require('telescope').setup {
defaults = {
vimgrep_arguments = {'rg', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case'},
prompt_position = "top",
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,
-- To disable a keymap, put [map] = false
-- So, to not map "<C-n>", just put
-- ["<c-x>"] = false,
-- 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
-- ["<esc>"] = actions.close,
-- ["<C-i>"] = my_cool_custom_action,
}
}
},
require'telescope'.setup {
extensions = {
media_files = {
-- filetypes whitelist
-- defaults to {"png", "jpg", "mp4", "webm", "pdf"}
filetypes = {"png", "webp", "jpg", "jpeg"},
find_cmd = "rg" -- find command (defaults to `fd`)
}
}
}
}

39
lua/settings.lua Normal file
View file

@ -0,0 +1,39 @@
--vim.o.iskeyword="+=-" --treat dash separated words as a word text object"
--vim.o.shortmess="c" --Don't pass messages to |ins-completion-menu|.
--vim.o.formatoptions="cro" --Stop newline continution of comments
vim.o.hidden=true --Required to keep multiple buffers open multiple buffers
vim.o.wrap=false --Display long lines as just one line
--vim.o.whichwrap="+=<,>,[,],h,l"
vim.o.encoding="utf-8" --The encoding displayed
vim.o.pumheight=10 --Makes popup menu smaller
vim.o.fileencoding="utf-8" --The encoding written to file
vim.o.ruler=true -- " Show the cursor position all the time
vim.o.cmdheight=2 --More space for displaying messages
vim.o.mouse="a" --Enable your mouse
vim.o.splitbelow=true --Horizontal splits will automatically be below
vim.o.termguicolors=true
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.o.tabstop=2 --Insert 2 spaces for a tab
vim.o.shiftwidth=2 --Change the number of space characters inserted for indentation
vim.o.smarttab=true --Makes tabbing smarter will realize you have 2 vs 4
vim.o.expandtab=true --Converts tabs to spaces
vim.o.smartindent=true --Makes indenting smart
vim.o.autoindent=true --Good auto indent
vim.o.laststatus=2 --Always display the status line
--vim.o.number=true --Line numbers
vim.wo.number = true
vim.o.cursorline=true --Enable highlighting of the current line
vim.o.background="dark" --tell vim what the background color looks like
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.o.signcolumn="yes" --Always show the signcolumn, otherwise it would shift the text each time
vim.o.updatetime=300 --Faster completion
vim.o.timeoutlen=1000 --By default timeoutlen is 1000 ms
vim.o.clipboard="unnamedplus" --Copy paste between vim and everything else
vim.o.incsearch=true
vim.o.guifont="JetBrainsMono\\ Nerd\\ Font\\ Mono:h18"