mirror of
https://github.com/halfdan/dotfiles.git
synced 2025-09-10 19:56:24 +00:00
Refactor nvim config, thanks ThePrimeagen
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
-- functions
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.edit_dotfiles()
|
||||
require'telescope.builtin'.git_files {
|
||||
shorten_path = false,
|
||||
cwd = "~/.dotfiles",
|
||||
prompt = "~ dotfiles ~",
|
||||
height = 10,
|
||||
|
||||
layout_strategy = 'horizontal',
|
||||
layout_options = {
|
||||
preview_width = 0.75,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
76
.config/nvim/lua/halfdan/debugger/init.lua
Normal file
76
.config/nvim/lua/halfdan/debugger/init.lua
Normal file
@@ -0,0 +1,76 @@
|
||||
local dap = require("dap")
|
||||
local dapui = require("dapui")
|
||||
local daptext = require("nvim-dap-virtual-text")
|
||||
|
||||
local remap = require("halfdan.keymap")
|
||||
local nnoremap = remap.nnoremap
|
||||
|
||||
daptext.setup()
|
||||
dapui.setup({
|
||||
layouts = {
|
||||
{
|
||||
elements = {
|
||||
"console",
|
||||
},
|
||||
size = 7,
|
||||
position = "bottom",
|
||||
},
|
||||
{
|
||||
elements = {
|
||||
-- Elements can be strings or table with id and size keys.
|
||||
{ id = "scopes", size = 0.25 },
|
||||
"watches",
|
||||
},
|
||||
size = 40,
|
||||
position = "left",
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
dap.listeners.after.event_initialized["dapui_config"] = function()
|
||||
dapui.open(1)
|
||||
end
|
||||
dap.listeners.before.event_terminated["dapui_config"] = function()
|
||||
dapui.close()
|
||||
end
|
||||
dap.listeners.before.event_exited["dapui_config"] = function()
|
||||
dapui.close()
|
||||
end
|
||||
|
||||
-- require("theprimeagen.debugger.node");
|
||||
|
||||
nnoremap("<Home>", function()
|
||||
dapui.toggle(1)
|
||||
end)
|
||||
nnoremap("<End>", function()
|
||||
dapui.toggle(2)
|
||||
end)
|
||||
|
||||
nnoremap("<leader><leader>", function()
|
||||
dap.close()
|
||||
end)
|
||||
|
||||
nnoremap("<F5>", function()
|
||||
dap.continue()
|
||||
end)
|
||||
nnoremap("<F10>", function()
|
||||
dap.step_over()
|
||||
end)
|
||||
nnoremap("<F11>", function()
|
||||
dap.step_into()
|
||||
end)
|
||||
nnoremap("<F12>", function()
|
||||
dap.step_out()
|
||||
end)
|
||||
nnoremap("<Leader>b", function()
|
||||
dap.toggle_breakpoint()
|
||||
end)
|
||||
nnoremap("<Leader>B", function()
|
||||
dap.set_breakpoint(vim.fn.input('Breakpoint condition: '))
|
||||
end)
|
||||
nnoremap("<leader>rc", function()
|
||||
dap.run_to_cursor()
|
||||
end)
|
||||
nnoremap("<leader>dr", function()
|
||||
dap.repl.open()
|
||||
end)
|
14
.config/nvim/lua/halfdan/init.lua
Normal file
14
.config/nvim/lua/halfdan/init.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
require("halfdan.settings")
|
||||
require("halfdan.packer")
|
||||
require("halfdan.neogit")
|
||||
|
||||
require('halfdan.globals')
|
||||
require('halfdan.keymap')
|
||||
|
||||
require('halfdan.colorscheme')
|
||||
|
||||
require('halfdan.themes.nord')
|
||||
|
||||
require('halfdan.autocmds')
|
||||
|
||||
require('halfdan.debugger')
|
20
.config/nvim/lua/halfdan/keymap.lua
Normal file
20
.config/nvim/lua/halfdan/keymap.lua
Normal file
@@ -0,0 +1,20 @@
|
||||
local M = {}
|
||||
|
||||
local function bind(op, outer_opts)
|
||||
outer_opts = outer_opts or {noremap = true}
|
||||
return function(lhs, rhs, opts)
|
||||
opts = vim.tbl_extend("force",
|
||||
outer_opts,
|
||||
opts or {}
|
||||
)
|
||||
vim.keymap.set(op, lhs, rhs, opts)
|
||||
end
|
||||
end
|
||||
|
||||
M.nmap = bind("n", {noremap = false})
|
||||
M.nnoremap = bind("n")
|
||||
M.vnoremap = bind("v")
|
||||
M.xnoremap = bind("x")
|
||||
M.inoremap = bind("i")
|
||||
|
||||
return M
|
10
.config/nvim/lua/halfdan/neogit.lua
Normal file
10
.config/nvim/lua/halfdan/neogit.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
local neogit = require('neogit')
|
||||
local nnoremap = require('halfdan.keymap').nnoremap
|
||||
|
||||
neogit.setup {}
|
||||
|
||||
nnoremap("<leader>gs", function()
|
||||
neogit.open({ })
|
||||
end);
|
||||
|
||||
nnoremap("<leader>ga", "<cmd>!git fetch --all<CR>");
|
@@ -1,12 +1,12 @@
|
||||
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.hidden = true -- 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.wo.wrap = false -- 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
|
||||
@@ -22,8 +22,8 @@ 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.number = true -- set numbered lines
|
||||
vim.wo.relativenumber = true -- 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
|
||||
@@ -31,7 +31,7 @@ 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.timeoutlen = 500 -- By default timeoutlen is 1000 ms
|
||||
vim.o.clipboard = "unnamedplus" -- Copy paste between vim and everything else
|
||||
vim.o.laststatus = 3 -- Set global status bar
|
||||
vim.opt.showtabline = 0 -- Disable tabline
|
||||
@@ -40,3 +40,5 @@ vim.opt.showtabline = 0 -- Disable tabline
|
||||
-- Enable telescope theme
|
||||
vim.g.gruvbox_baby_telescope_theme = 1
|
||||
vim.g.gruvbox_baby_background_color = "dark"
|
||||
|
||||
vim.g.mapleader = ' '
|
@@ -1,96 +0,0 @@
|
||||
vim.g.mapleader = ' '
|
||||
|
||||
-- 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})
|
||||
|
||||
-- resize with arrows
|
||||
vim.api.nvim_set_keymap('n', '<C-Up>', ':resize -2<CR>', {silent = true})
|
||||
vim.api.nvim_set_keymap('n', '<C-Down>', ':resize +2<CR>', {silent = true})
|
||||
vim.api.nvim_set_keymap('n', '<C-Left>', ':vertical resize -2<CR>', {silent = true})
|
||||
vim.api.nvim_set_keymap('n', '<C-Right>', ':vertical resize +2<CR>', {silent = true})
|
||||
|
||||
-- improved keyboard support for navigation (especially terminal)
|
||||
vim.api.nvim_set_keymap('n', '<leader>h', '<C-w>h', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>j', '<C-w>j', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>k', '<C-w>k', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>l', '<C-w>l', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<A-h>', '<C-w>h', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<A-j>', '<C-w>j', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<A-k>', '<C-w>k', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<A-l>', '<C-w>l', {noremap = true})
|
||||
|
||||
-- Change 2 split windows from vert to horiz or horiz to vert
|
||||
vim.api.nvim_set_keymap('n', '<leader>th', '<C-w>t<C-w>H', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>tk', '<C-w>t<C-w>K', {noremap = true})
|
||||
|
||||
-- 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>
|
||||
]])
|
||||
|
||||
-- better indenting
|
||||
vim.api.nvim_set_keymap('v', '<', '<gv', {noremap = true, silent = true})
|
||||
vim.api.nvim_set_keymap('v', '>', '>gv', {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', 'J', ':move \'>+1<CR>gv-gv', {noremap = true, silent = true})
|
||||
vim.api.nvim_set_keymap('x', 'K', ':move \'<-2<CR>gv-gv', {noremap = true, silent = true})
|
||||
|
||||
vim.api.nvim_set_keymap('n', 'Q', '<Nop>', {noremap = true, silent = true})
|
||||
|
||||
-- Telescope
|
||||
vim.api.nvim_set_keymap('n', '<leader>fs', ':lua require(\'telescope.builtin\').grep_string({ search = vim.fn.input("Grep For > ")})<CR>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<Leader>ff', ':lua require(\'telescope.builtin\').find_files()<CR>', {noremap = true})
|
||||
|
||||
vim.api.nvim_set_keymap('n', '<leader>fw', ':lua require(\'telescope.builtin\').grep_string { search = vim.fn.expand("<cword>") }<CR>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>fb', ':lua require(\'telescope.builtin\').buffers()<CR>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>vh', ':lua require(\'telescope.builtin\').help_tags()<CR>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>gwl', ':lua require(\'telescope\').extensions.git_worktree.git_worktrees()<CR>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>gwc', ':lua require(\'telescope\').extensions.git_worktree.create_git_worktree()<CR>', {noremap = true})
|
||||
|
||||
-- Tagbar
|
||||
vim.api.nvim_set_keymap('n', '<Leader>hl', ':nohl<CR>', {noremap = true})
|
||||
|
||||
-- Vim Test
|
||||
vim.api.nvim_set_keymap('n', '<leader>t', ':TestNearest<CR>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>T', ':TestFile<CR>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>a', ':TestSuite<CR>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>l', ':TestLast<CR>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>g', ':TestVisit<CR>', {noremap = true})
|
||||
|
||||
-- LSP
|
||||
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> rn <cmd>lua vim.lsp.buf.rename()<CR>")
|
||||
vim.cmd("nnoremap <silent> ff <cmd>lua vim.lsp.buf.formatting()<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()')
|
||||
|
||||
-- Yank until end of line
|
||||
vim.api.nvim_set_keymap('n', 'Y', 'yg$', {noremap = true, silent = true})
|
||||
-- Next item, but center line
|
||||
vim.api.nvim_set_keymap('n', 'n', 'nzzzv', {noremap = true, silent = true})
|
||||
vim.api.nvim_set_keymap('n', 'N', 'Nzzzv', {noremap = true, silent = true})
|
||||
-- Join line but keep cursor intact
|
||||
vim.api.nvim_set_keymap('n', 'J', 'mzJ`z', {noremap = true, silent = true})
|
@@ -1,161 +0,0 @@
|
||||
-- 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"}
|
||||
)
|
||||
|
||||
-- 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 = 1,
|
||||
},
|
||||
signs = true,
|
||||
underline = true,
|
||||
}
|
||||
)
|
||||
|
||||
local saga = require 'lspsaga'
|
||||
saga.init_lsp_saga({
|
||||
-- symbols in winbar
|
||||
symbol_in_winbar = true,
|
||||
winbar_file_format = function()
|
||||
return vim.fn.expand("%=%m %f")
|
||||
end,
|
||||
})
|
||||
|
||||
-- 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)"
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
-- 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
|
||||
]])
|
||||
|
||||
|
||||
|
||||
-- Diagnostic keymaps
|
||||
vim.api.nvim_set_keymap('n', '<leader>e', '<cmd>lua vim.diagnostic.open_float()<CR>', { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', '<leader>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', { noremap = true, silent = true })
|
||||
|
||||
-- LSP settings
|
||||
local lspconfig = require 'lspconfig'
|
||||
local on_attach = function(_, bufnr)
|
||||
local opts = { noremap = true, silent = true }
|
||||
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', '<C-k>', '<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', '<leader>D', '<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', 'gr', '<cmd>lua vim.lsp.buf.references()<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', '<leader>so', [[<cmd>lua require('telescope.builtin').lsp_document_symbols()<CR>]], opts)
|
||||
vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]]
|
||||
end
|
||||
|
||||
-- nvim-cmp supports additional completion capabilities
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
||||
|
||||
|
||||
lspconfig['elixirls'].setup{
|
||||
cmd = { "/Users/fbecker18/opt/elixir-ls/language_server.sh"},
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
-- Enable the following language servers
|
||||
local servers = { 'gopls', 'julials', 'rust_analyzer', 'pyright' }
|
||||
for _, lsp in ipairs(servers) do
|
||||
lspconfig[lsp].setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
end
|
||||
|
||||
require('rust-tools').setup({
|
||||
tools = {
|
||||
inlay_hints = {
|
||||
parameter_hints_prefix = "← ",
|
||||
other_hints_prefix = "➜ ",
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
--vim.cmd([[
|
||||
--augroup
|
||||
--autocmd!
|
||||
--autocmd BufWritePre *.go lua vim.lsp.buf.formatting_sync(nil, 100)
|
||||
--autocmd BufWritePre *.rs lua vim.lsp.buf.formatting_sync(nil, 100)
|
||||
--autocmd BufWritePre *.ex,*.exs lua vim.lsp.buf.formatting_sync(nil, 100)
|
||||
--autocmd BufWritePre *.py lua vim.lsp.buf.formatting_sync(nil, 100)
|
||||
--augroup END
|
||||
--]])
|
@@ -1,98 +0,0 @@
|
||||
local cmp = require'cmp'
|
||||
local lspkind = require('lspkind')
|
||||
local luasnip = require 'luasnip'
|
||||
|
||||
local source_mapping = {
|
||||
buffer = "[Buffer]",
|
||||
nvim_lsp = "[LSP]",
|
||||
nvim_lua = "[Lua]",
|
||||
cmp_tabnine = "[TN]",
|
||||
path = "[Path]",
|
||||
}
|
||||
|
||||
cmp.setup({
|
||||
-- snippet = {
|
||||
-- -- REQUIRED - you must specify a snippet engine
|
||||
-- expand = function(args)
|
||||
-- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||
-- -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
||||
-- -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
|
||||
-- -- require'snippy'.expand_snippet(args.body) -- For `snippy` users.
|
||||
-- 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' }),
|
||||
--['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||
--},
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require'luasnip'.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
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.confirm {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = false, -- only replace if explicitly selected
|
||||
},
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'cmp_tabnine' },
|
||||
{ name = 'nvim_lsp' },
|
||||
}),
|
||||
formatting = {
|
||||
format = function(entry, vim_item)
|
||||
vim_item.kind = lspkind.presets.default[vim_item.kind]
|
||||
local menu = source_mapping[entry.source.name]
|
||||
if entry.source.name == 'cmp_tabnine' then
|
||||
if entry.completion_item.data ~= nil and entry.completion_item.data.detail ~= nil then
|
||||
menu = entry.completion_item.data.detail .. ' ' .. menu
|
||||
end
|
||||
vim_item.kind = '?'
|
||||
end
|
||||
vim_item.menu = menu
|
||||
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 tabnine
|
||||
local tabnine = require('cmp_tabnine.config')
|
||||
tabnine:setup({
|
||||
max_lines = 1000;
|
||||
max_num_results = 20;
|
||||
sort = true;
|
||||
run_on_every_keystroke = true;
|
||||
snippet_placeholder = '..';
|
||||
ignored_file_types = { -- default is not to ignore
|
||||
-- uncomment to ignore in lua:
|
||||
lua = true
|
||||
};
|
||||
})
|
||||
|
||||
-- Setup lspconfig.
|
||||
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
@@ -1,231 +0,0 @@
|
||||
local vim = vim
|
||||
local gl = require('galaxyline')
|
||||
local utils = require('utils')
|
||||
|
||||
local gls = gl.section
|
||||
gl.short_line_list = { 'defx', 'packager', 'vista' }
|
||||
|
||||
-- Colors
|
||||
local colors = {
|
||||
bg = '#282a36',
|
||||
fg = '#f8f8f2',
|
||||
section_bg = '#38393f',
|
||||
yellow = '#f1fa8c',
|
||||
cyan = '#8be9fd',
|
||||
green = '#50fa7b',
|
||||
orange = '#ffb86c',
|
||||
magenta = '#ff79c6',
|
||||
blue = '#8be9fd',
|
||||
red = '#ff5555'
|
||||
}
|
||||
|
||||
-- Local helper functions
|
||||
local buffer_not_empty = function()
|
||||
return not utils.is_buffer_empty()
|
||||
end
|
||||
|
||||
local in_git_repo = function ()
|
||||
local vcs = require('galaxyline.provider_vcs')
|
||||
local branch_name = vcs.get_git_branch()
|
||||
|
||||
return branch_name ~= nil
|
||||
end
|
||||
|
||||
local checkwidth = function()
|
||||
return utils.has_width_gt(40) and in_git_repo()
|
||||
end
|
||||
|
||||
local mode_color = function()
|
||||
local mode_colors = {
|
||||
n = colors.cyan,
|
||||
i = colors.green,
|
||||
c = colors.orange,
|
||||
V = colors.magenta,
|
||||
[''] = colors.magenta,
|
||||
v = colors.magenta,
|
||||
R = colors.red,
|
||||
}
|
||||
|
||||
local color = mode_colors[vim.fn.mode()]
|
||||
|
||||
if color == nil then
|
||||
color = colors.red
|
||||
end
|
||||
|
||||
return color
|
||||
end
|
||||
|
||||
-- Left side
|
||||
gls.left[1] = {
|
||||
FirstElement = {
|
||||
provider = function() return '▋' end,
|
||||
highlight = { colors.cyan, colors.section_bg }
|
||||
},
|
||||
}
|
||||
gls.left[2] = {
|
||||
ViMode = {
|
||||
provider = function()
|
||||
local alias = {
|
||||
n = 'NORMAL',
|
||||
i = 'INSERT',
|
||||
c = 'COMMAND',
|
||||
V = 'VISUAL',
|
||||
[''] = 'VISUAL',
|
||||
v = 'VISUAL',
|
||||
R = 'REPLACE',
|
||||
}
|
||||
vim.api.nvim_command('hi GalaxyViMode guifg='..mode_color())
|
||||
local alias_mode = alias[vim.fn.mode()]
|
||||
if alias_mode == nil then
|
||||
alias_mode = vim.fn.mode()
|
||||
end
|
||||
return alias_mode..' '
|
||||
end,
|
||||
highlight = { colors.bg, colors.bg },
|
||||
separator = " ",
|
||||
separator_highlight = {colors.bg, colors.section_bg},
|
||||
},
|
||||
}
|
||||
gls.left[3] ={
|
||||
FileIcon = {
|
||||
provider = 'FileIcon',
|
||||
condition = buffer_not_empty,
|
||||
highlight = { require('galaxyline.provider_fileinfo').get_file_icon_color, colors.section_bg },
|
||||
},
|
||||
}
|
||||
gls.left[4] = {
|
||||
FileName = {
|
||||
provider = 'FileName',
|
||||
condition = buffer_not_empty,
|
||||
highlight = { colors.fg, colors.section_bg },
|
||||
separator = " ",
|
||||
separator_highlight = {colors.section_bg, colors.bg},
|
||||
}
|
||||
}
|
||||
gls.left[5] = {
|
||||
GitIcon = {
|
||||
provider = function() return ' ' end,
|
||||
condition = in_git_repo,
|
||||
highlight = {colors.red,colors.bg},
|
||||
}
|
||||
}
|
||||
gls.left[6] = {
|
||||
GitBranch = {
|
||||
provider = function()
|
||||
local vcs = require('galaxyline.provider_vcs')
|
||||
local branch_name = vcs.get_git_branch()
|
||||
if (string.len(branch_name) > 28) then
|
||||
return string.sub(branch_name, 1, 25).."..."
|
||||
end
|
||||
return branch_name .. " "
|
||||
end,
|
||||
condition = in_git_repo,
|
||||
highlight = {colors.fg,colors.bg},
|
||||
}
|
||||
}
|
||||
gls.left[7] = {
|
||||
DiffAdd = {
|
||||
provider = 'DiffAdd',
|
||||
condition = checkwidth,
|
||||
icon = ' ',
|
||||
highlight = { colors.green, colors.bg },
|
||||
}
|
||||
}
|
||||
gls.left[8] = {
|
||||
DiffModified = {
|
||||
provider = 'DiffModified',
|
||||
condition = checkwidth,
|
||||
icon = ' ',
|
||||
highlight = { colors.orange, colors.bg },
|
||||
}
|
||||
}
|
||||
gls.left[9] = {
|
||||
DiffRemove = {
|
||||
provider = 'DiffRemove',
|
||||
condition = checkwidth,
|
||||
icon = ' ',
|
||||
highlight = { colors.red,colors.bg },
|
||||
}
|
||||
}
|
||||
gls.left[10] = {
|
||||
LeftEnd = {
|
||||
provider = function() return ' ' end,
|
||||
condition = buffer_not_empty,
|
||||
highlight = {colors.section_bg,colors.bg}
|
||||
}
|
||||
}
|
||||
gls.left[11] = {
|
||||
DiagnosticError = {
|
||||
provider = 'DiagnosticError',
|
||||
icon = ' ',
|
||||
highlight = {colors.red,colors.section_bg}
|
||||
}
|
||||
}
|
||||
gls.left[12] = {
|
||||
Space = {
|
||||
provider = function () return ' ' end,
|
||||
highlight = {colors.section_bg,colors.section_bg},
|
||||
}
|
||||
}
|
||||
gls.left[13] = {
|
||||
DiagnosticWarn = {
|
||||
provider = 'DiagnosticWarn',
|
||||
icon = ' ',
|
||||
highlight = {colors.orange,colors.section_bg},
|
||||
}
|
||||
}
|
||||
gls.left[14] = {
|
||||
Space = {
|
||||
provider = function () return ' ' end,
|
||||
highlight = {colors.section_bg,colors.section_bg},
|
||||
}
|
||||
}
|
||||
gls.left[15] = {
|
||||
DiagnosticInfo = {
|
||||
provider = 'DiagnosticInfo',
|
||||
icon = ' ',
|
||||
highlight = {colors.blue,colors.section_bg},
|
||||
separator = ' ',
|
||||
separator_highlight = { colors.section_bg, colors.bg },
|
||||
}
|
||||
}
|
||||
|
||||
-- Right side
|
||||
gls.right[1]= {
|
||||
FileFormat = {
|
||||
provider = function() return vim.bo.filetype end,
|
||||
highlight = { colors.fg,colors.section_bg },
|
||||
separator = ' ',
|
||||
separator_highlight = { colors.section_bg,colors.bg },
|
||||
}
|
||||
}
|
||||
gls.right[2] = {
|
||||
LineInfo = {
|
||||
provider = 'LineColumn',
|
||||
highlight = { colors.fg, colors.section_bg },
|
||||
separator = ' | ',
|
||||
separator_highlight = { colors.bg, colors.section_bg },
|
||||
},
|
||||
}
|
||||
|
||||
-- Short status line
|
||||
gls.short_line_left[1] = {
|
||||
BufferType = {
|
||||
provider = 'FileTypeName',
|
||||
highlight = { colors.fg, colors.section_bg },
|
||||
separator = ' ',
|
||||
separator_highlight = { colors.section_bg, colors.bg },
|
||||
}
|
||||
}
|
||||
|
||||
gls.short_line_right[1] = {
|
||||
BufferIcon = {
|
||||
provider= 'BufferIcon',
|
||||
highlight = { colors.yellow, colors.section_bg },
|
||||
separator = ' ',
|
||||
separator_highlight = { colors.section_bg, colors.bg },
|
||||
}
|
||||
}
|
||||
|
||||
-- Force manual load so that nvim boots with a status line
|
||||
gl.load_galaxyline()
|
@@ -1,8 +0,0 @@
|
||||
vim.cmd([[
|
||||
let g:sneak#label = 1
|
||||
let g:sneak#prompt = '🔎'
|
||||
let g:sneak#s_next = 1
|
||||
|
||||
let test#strategy = "neovim"
|
||||
let test#neovim#term_position = "vert rightbelow 50"
|
||||
]])
|
@@ -1 +0,0 @@
|
||||
vim.g.tagbar_ctags_bin = '/usr/local/bin/ctags'
|
@@ -1,13 +0,0 @@
|
||||
local M = {}
|
||||
|
||||
function M.is_buffer_empty()
|
||||
-- Check whether the current buffer is empty
|
||||
return vim.fn.empty(vim.fn.expand('%:t')) == 1
|
||||
end
|
||||
|
||||
function M.has_width_gt(cols)
|
||||
-- Check if the windows width is greater than a given number of columns
|
||||
return vim.fn.winwidth(0) / 2 > cols
|
||||
end
|
||||
|
||||
return M
|
Reference in New Issue
Block a user