changing file structure and adding harpoon

main
spinach 2 years ago
parent d09e5e3bc6
commit 8e1d6b1aae

@ -1,8 +1,6 @@
require('keymap')
require('plugins')
require('calcurse')
require('i3conf')
require('go')
require('autobuf')
-- prevent cursor override
vim.cmd('set guicursor=')
@ -12,8 +10,6 @@ vim.cmd('set ts=4 sts=4 sw=4 expandtab')
-- clipboard
vim.cmd('set clipboard+=unnamedplus')
vim.keymap.set('n', '<leader>Y', '"+y')
vim.keymap.set('n', '<leader>P', '"+p')
-- hybrid numbering
vim.opt.relativenumber = true
@ -52,86 +48,20 @@ vim.cmd([[
\ 'syntax': 'markdown', 'ext':'.md'}]
]])
-- language server setup
local lspconfig = require('lspconfig')
-- Go
lspconfig.gopls.setup{
cmd = {"gopls", "serve"},
filetypes = {"go", "gomod"},
settings = {
gopls = {
analyses = {
unusedparams = true,
},
staticcheck = true,
},
},
}
-- C/C++
lspconfig.clangd.setup{}
-- Lua
lspconfig.lua_ls.setup{
settings = {
Lua = {
diagnostics = {globals = {'vim', 'opts'}},
},
telemetry = {
enable = false,
},
},
}
-- Rust
lspconfig.rust_analyzer.setup{}
-- Python
lspconfig.pylsp.setup{}
-- TypeScript
lspconfig.tsserver.setup{}
-- Fix virtual text going off screen
vim.diagnostic.config({
virtual_text = false,
signs = true,
underline = true,
update_in_insert = false,
severity_sort = false,
})
vim.api.nvim_create_autocmd('LspAttach', {
callback = function(ev)
-- custom colors
vim.cmd('hi DiagnosticUnderlineError cterm=undercurl guisp=Red')
-- key mappings
local opts = { buffer = ev.buf,}
-- error viewing
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '<leader>[d', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', '<leader>]d', vim.diagnostic.goto_next, opts)
-- def viewing/rename
vim.keymap.set('n', '<leader>gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', '<leader>gd', vim.lsp.buf.definition, opts)
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
vim.keymap.set('n', '<leader>H', vim.lsp.buf.hover, opts)
-- auto hover for error viewing
vim.api.nvim_create_autocmd("CursorHold", {
callback = function()
opts = {
buffer = ev.buf,
focusable = false,
border = 'rounded',
source = 'always',
prefix = ' ',
scope = 'cursor',
close_events = { "BufLeave","CursorMoved","InsertEnter","FocusLost" },
}
vim.diagnostic.open_float(nil, opts)
-- go file settings
vim.g.go_hightlight_types = 1
vim.g.go_hightlight_fields = 1
vim.g.go_hightlight_functions = 1
vim.g.go_hightlight_function_calls = 1
vim.g.go_hightlight_operators = 1
vim.g.go_hightlight_extra_types = 1
-- airline settings
if vim.g.airline_symbols == nil then
vim.g.airline_symbols = vim.empty_dict()
end
})
end,
})
vim.g.airline_powerline_fonts = 1
vim.g.airline_symbols.linenr = ''
vim.g.airline_symbols.maxlinenr = ''
vim.g.airline_symbols.dirty = ''

@ -0,0 +1,12 @@
-- sets autocommands for bufenters etc
-- recognize i3 files as such
vim.api.nvim_create_autocmd({"BufRead","BufNewFile"}, {
pattern = {"*/i3/*.conf"},
command = "set filetype=i3config",
})
-- calcurse -> markdown
vim.api.nvim_create_autocmd({"BufRead","BufNewFile"}, {
pattern = {"/tmp/calcurse*","~/.local/share/calcurse/notes/*"},
command = "set filetype=markdown",
})

@ -1,7 +0,0 @@
-- calcurse -> markdown
vim.api.nvim_create_autocmd({"BufRead","BufNewFile"}, {
pattern = {"/tmp/calcurse*","~/.local/share/calcurse/notes/*"},
command = "set filetype=markdown",
})

@ -1,11 +0,0 @@
require('telescope').setup({
defaults = {
layout_config = {
horizontal = { width = 0.5 }
},
},
})
local builtin = require('telescope.builtin')
vim.keymap.set('n','<leader>f', builtin.find_files, {})
vim.keymap.set('n','<leader>s', builtin.spell_suggest, {})

@ -1,6 +0,0 @@
vim.g.go_hightlight_types = 1
vim.g.go_hightlight_fields = 1
vim.g.go_hightlight_functions = 1
vim.g.go_hightlight_function_calls = 1
vim.g.go_hightlight_operators = 1
vim.g.go_hightlight_extra_types = 1

@ -1,6 +0,0 @@
-- recognize i3 config from dotfiles
--
vim.api.nvim_create_autocmd({"BufRead","BufNewFile"}, {
pattern = {"*/i3/*.conf"},
command = "set filetype=i3config",
})

@ -1,5 +1,3 @@
require("transparent")
vim.g.mapleader = " "
vim.keymap.set("n", "<leader>b", ":lua ToggleTransparent()<CR>")
@ -10,15 +8,6 @@ vim.keymap.set("n", "<leader>t", ":NvimTreeToggle<CR>")
vim.keymap.set("n", "<leader>a", ":lua SpellToggle()<CR>")
-- toggle spell check
function SpellToggle()
if vim.o.spell == nil or vim.o.spell then
vim.o.spell = false
else
vim.o.spell = true
end
end
-- markdown preview
vim.keymap.set("n", "<leader>p", ":MarkdownPreviewToggle<CR>")
@ -36,3 +25,28 @@ vim.g.mkdp_browserfunc = 'OpenMarkdownPreview'
vim.keymap.set("n", "<leader>ga", ":Git add .<CR>")
vim.keymap.set("n", "<leader>gm", ":Git commit<CR>")
-- fuzzy finder keybindings
local telescope = require('telescope.builtin')
vim.keymap.set('n','<leader>f', telescope.find_files, {})
vim.keymap.set('n','<leader>s', telescope.spell_suggest, {})
-- global copy/paste
vim.keymap.set('n', '<leader>yg', '"+y')
vim.keymap.set('n', '<leader>pg', '"+p')
-- toggle dotfiles visibility
vim.keymap.set("n", "<leader>d", ":lua require('nvim-tree.api').tree.toggle_hidden_filter()<CR>")
-- harpoon bindings
local harpoon = require('harpoon.ui')
vim.keymap.set("n", "<leader>hh", ":Telescope harpoon marks")
vim.keymap.set("n", "<leader>ha", harpoon.add_file, {})
vim.keymap.set("n", "<leader>hn", harpoon.nav_next, {})
vim.keymap.set("n", "<leader>hp", harpoon.nav_prev, {})
-- jumping to specific files
vim.keymap.set("n", "<leader>h1", harpoon.nav_file, {1})
vim.keymap.set("n", "<leader>h2", harpoon.nav_file, {2})
vim.keymap.set("n", "<leader>h3", harpoon.nav_file, {3})
vim.keymap.set("n", "<leader>h4", harpoon.nav_file, {4})
vim.keymap.set("n", "<leader>h5", harpoon.nav_file, {5})

@ -0,0 +1,83 @@
-- language server setup
local lspconfig = require('lspconfig')
-- Go
lspconfig.gopls.setup{
cmd = {"gopls", "serve"},
filetypes = {"go", "gomod"},
settings = {
gopls = {
analyses = {
unusedparams = true,
},
staticcheck = true,
},
},
}
-- C/C++
lspconfig.clangd.setup{}
-- Lua
lspconfig.lua_ls.setup{
settings = {
Lua = {
diagnostics = {globals = {'vim', 'opts'}},
},
telemetry = {
enable = false,
},
},
}
-- Rust
lspconfig.rust_analyzer.setup{}
-- Python
lspconfig.pylsp.setup{}
-- TypeScript
lspconfig.tsserver.setup{}
-- Fix virtual text going off screen
vim.diagnostic.config({
virtual_text = false,
signs = true,
underline = true,
update_in_insert = false,
severity_sort = false,
})
vim.api.nvim_create_autocmd('LspAttach', {
callback = function(ev)
-- custom colors
--vim.cmd('hi DiagnosticUnderlineError cterm=undercurl guisp=Red')
-- key mappings
local opts = { buffer = ev.buf,}
-- error viewing
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '<leader>[d', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', '<leader>]d', vim.diagnostic.goto_next, opts)
-- def viewing/rename
vim.keymap.set('n', '<leader>gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', '<leader>gd', vim.lsp.buf.definition, opts)
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
vim.keymap.set('n', '<leader>H', vim.lsp.buf.hover, opts)
-- auto hover for error viewing
vim.api.nvim_create_autocmd("CursorHold", {
callback = function()
opts = {
buffer = ev.buf,
focusable = false,
border = 'rounded',
source = 'always',
prefix = ' ',
scope = 'cursor',
close_events = { "BufLeave","CursorMoved","InsertEnter","FocusLost" },
}
vim.diagnostic.open_float(nil, opts)
end
})
end,
})

@ -1,13 +1,52 @@
require('tree')
require('fuzzy')
require('lsp')
require('transparent')
require('spellcheck')
-- airline settings
if vim.g.airline_symbols == nil then
vim.g.airline_symbols = vim.empty_dict()
-- nvim tree setup
require('nvim-tree').setup({
open_on_tab = false,
filters = {
dotfiles = true,
},
actions = {
open_file = {
quit_on_open = true,
},
},
})
showHiddenFiles = false
local function open_nvim_tree(data)
-- buffer is a directory
local directory = vim.fn.isdirectory(data.file) == 1
local empty_file = data.file == ""
if not directory and not empty_file then
return
end
vim.g.airline_powerline_fonts = 1
vim.g.airline_symbols.linenr = ''
vim.g.airline_symbols.maxlinenr = ''
vim.g.airline_symbols.dirty = ''
if directory then
vim.cmd.cd(data.file)
end
vim.cmd.enew()
vim.cmd.bw(data.buf)
-- change to directory and open
require("nvim-tree.api").tree.open()
end
-- nvim-tree open at startup
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree, })
-- fuzzy finder setup
require('telescope').setup({
defaults = {
layout_config = {
horizontal = { width = 0.5 }
},
},
})
require.('telescope).load_extension('harpoon')

@ -0,0 +1,9 @@
-- simple spell check toggle
function SpellToggle()
if vim.o.spell == nil or vim.o.spell then
vim.o.spell = false
else
vim.o.spell = true
end
end

@ -1,9 +1,10 @@
-- allows for toggling of background
function ToggleTransparent()
Transparent = not Transparent
if Transparent then
vim.cmd("hi Normal ctermbg=NONE")
else
vim.cmd("set background=dark")
vim.cmd("syntax enable")
-- 234 is hybrid dark bg color
vim.cmd("hi Normal ctermbg=234")
end
end

@ -1,40 +0,0 @@
require('nvim-tree').setup({
open_on_tab = false,
filters = {
dotfiles = true,
},
actions = {
open_file = {
quit_on_open = true,
},
},
})
showHiddenFiles = false
local function open_nvim_tree(data)
-- buffer is a directory
local directory = vim.fn.isdirectory(data.file) == 1
local empty_file = data.file == ""
if not directory and not empty_file then
return
end
if directory then
vim.cmd.cd(data.file)
end
vim.cmd.enew()
vim.cmd.bw(data.buf)
-- change to directory and open
require("nvim-tree.api").tree.open()
end
-- toggle dotfiles visibility
vim.keymap.set("n", "<leader>d", ":lua require('nvim-tree.api').tree.toggle_hidden_filter()<CR>")
-- nvim-tree open at startup
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree, })
Loading…
Cancel
Save