dotfiles/home/config/nvim/lua/settings_after.lua

211 lines
6.2 KiB
Lua
Raw Normal View History

2023-09-28 13:29:31 +00:00
vim.opt.shell = "zsh"
2023-01-02 20:15:50 +00:00
vim.opt.history = 1000
vim.opt.termguicolors = true
vim.opt.background = "dark"
vim.opt.mouse = "" -- disable
-- vim.opt.ruler = true -- Position at the bottom of the screen
vim.opt.joinspaces = false
vim.opt.hidden = true
vim.opt.previewheight = 5
--
vim.opt.shortmess = vim.o.shortmess .. "atI"
vim.opt.lazyredraw = true
vim.opt.splitbelow = true
vim.opt.splitright = true
2023-05-05 20:55:13 +00:00
vim.opt.cursorline = true
vim.opt.cursorcolumn = true
2023-01-02 20:15:50 +00:00
-- Global settings
2024-09-29 02:36:43 +00:00
vim.opt.autochdir = false -- Keep vim's directory context same as the current buffer
2023-01-02 20:15:50 +00:00
vim.opt.listchars = "tab:> ,trail:.,extends:$,nbsp:_"
vim.opt.fillchars = "fold:-"
-- Search
vim.opt.hlsearch = true
vim.opt.incsearch = true
vim.opt.ignorecase = true
vim.opt.wildmode = "list:longest" -- Autocomplete
-- Buffer settings
vim.opt.autoindent = true
vim.opt.expandtab = true
vim.opt.shiftwidth = 2
vim.opt.softtabstop = 4
vim.opt.tabstop = 2
vim.opt.undofile = true
vim.opt.number = true
vim.opt.relativenumber = true
2024-04-11 02:56:00 +00:00
vim.cmd 'colorscheme bamboo'
2023-01-02 20:15:50 +00:00
vim.g.floaterm_keymap_toggle = '<F9>'
vim.g.floaterm_width = 0.9
vim.g.floaterm_height = 0.9
2024-09-30 14:21:25 +00:00
vim.g.floaterm_shell = "/bin/zsh"
2023-01-02 20:15:50 +00:00
2023-06-24 16:13:26 +00:00
vim.g.rustfmt_autosave = 1
vim.g.rust_use_custom_ctags_defs = 1
2023-01-02 20:15:50 +00:00
vim.g.tagbar_autofocus=1
2023-09-28 13:29:31 +00:00
-- vim.g.UltiSnipsExpandTrigger="<C-Tab>"
-- vim.g.UltiSnipsJumpForwardTrigger="<C-b>"
-- vim.g.UltiSnipsJumpBackwardTrigger="<C-z>"
2023-01-02 20:15:50 +00:00
-- Highlight yank
vim.api.nvim_command([[
au TextYankPost * lua vim.highlight.on_yank {higroup="IncSearch", timeout=150, on_visual=true}
]])
-- TODO: ... the rest of plugin/legacy.vim
local map = vim.api.nvim_set_keymap
local function t(str) -- Convert termcodes for mapping
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
_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>")
elseif vim.fn.call("vsnip#jumpable", { -1 }) == 1 then
return t("<Plug>(vsnip-jump-prev)")
else
-- If <S-Tab> is not working in your terminal, change it to <C-h>
return t("<S-Tab>")
end
end
2023-01-02 20:22:22 +00:00
-- 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 })
2023-01-02 20:15:50 +00:00
map("v", ">", ">gv", {}) -- Retain visual select when indenting
map("v", "<", "<gv", {}) -- Retain visual select when indenting
vim.api.nvim_set_keymap("n", "<Leader>bq",":bp <BAR> bd #<CR>", {silent=true})
vim.api.nvim_set_keymap("n", "<Leader>ff", ":Telescope find_files<cr>", {silent=true})
vim.api.nvim_set_keymap("n", "<Leader>fg", ":Telescope live_grep<cr>", {silent=true})
vim.api.nvim_set_keymap("n", "<Leader>fb", ":Telescope buffers<cr>", {silent=true})
vim.api.nvim_set_keymap("n", "<Leader>fa", ":Ag<cr>", {silent=true})
2023-10-30 14:00:12 +00:00
-- vim.api.nvim_set_keymap("n", "<Leader>fp", ":Telescope projects<cr>", {silent=true})
-- vim.api.nvim_set_keymap("n", "<leader>gb",":.GBrowse<CR>", {silent=true})
-- vim.api.nvim_set_keymap("n", "<F2>",":SearchSession<CR>", {silent = true })
2023-01-02 20:15:50 +00:00
vim.api.nvim_set_keymap("n", "<C-J>", ":bprev<CR>", {silent = true})
vim.api.nvim_set_keymap("n", "<C-K>", ":bnext<CR>", {silent = true})
vim.api.nvim_set_keymap("n", "<C-o>", ":NERDTreeToggle<CR>", {silent = true})
2024-08-13 13:16:04 +00:00
vim.api.nvim_set_keymap("n", "<F1>", ":set invrnu<CR>", {silent = true })
2023-05-28 17:35:08 +00:00
vim.api.nvim_set_keymap("i", "<F1>", "<Esc>", {silent = true })
2023-01-02 20:15:50 +00:00
vim.api.nvim_set_keymap("n", "<F8>", ":Tagbar<CR>", {silent = true })
2024-04-11 02:56:00 +00:00
vim.api.nvim_set_keymap("n", "<F9>", ":FloatermToggle<CR>", {silent = true })
2023-01-02 20:15:50 +00:00
2023-11-16 17:37:21 +00:00
-- LSP Diagnostics Options Setup
local sign = function(opts)
vim.fn.sign_define(opts.name, {
texthl = opts.name,
text = opts.text,
numhl = ''
})
end
sign({name = 'DiagnosticSignError', text = ''})
sign({name = 'DiagnosticSignWarn', text = ''})
sign({name = 'DiagnosticSignHint', text = ''})
sign({name = 'DiagnosticSignInfo', text = ''})
vim.diagnostic.config({
virtual_text = false,
signs = true,
update_in_insert = true,
underline = true,
severity_sort = false,
float = {
border = 'rounded',
source = 'always',
header = '',
prefix = '',
},
})
vim.cmd([[
set signcolumn=yes
autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false })
]])
2023-09-27 20:31:31 +00:00
2023-11-16 17:37:21 +00:00
-- Vimspector
-- KEYS
vim.cmd([[
nmap <Leader><F6> <cmd>call vimspector#Launch()<cr>
nmap <Leader><F7> <cmd>call vimspector#StepOver()<cr>
nmap <Leader><F4> <cmd>call vimspector#Reset()<cr>
nmap <Leader><F11> <cmd>call vimspector#StepOver()<cr>
nmap <Leader><F12> <cmd>call vimspector#StepOut()<cr>
nmap <Leader><F10> <cmd>call vimspector#StepInto()<cr>
nmap <Leader>Db <cmd>:call vimspector#ToggleBreakpoint()<cr>
nmap <Leader>Dw <cmd>:call vimspector#AddWatch()<cr>
nmap <Leader>De <cmd>:call vimspector#Evaluate()<cr>
]])
-- OPTS
vim.opt.completeopt = {'menuone', 'noselect', 'noinsert'}
vim.opt.shortmess = vim.opt.shortmess + { c = true}
vim.api.nvim_set_option('updatetime', 300)
-- Fixed column for diagnostics to appear
-- Show autodiagnostic popup on cursor hover_range
-- Goto previous / next diagnostic warning / error
-- Show inlay_hints more frequently
vim.cmd([[
set signcolumn=yes
autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false })
]])
vim.cmd([[
let g:vimspector_sidebar_width = 85
let g:vimspector_bottombar_height = 15
let g:vimspector_terminal_maxwidth = 70
]])
2024-09-29 02:36:43 +00:00
local cwd = vim.fn.getcwd()
-- Generate a server address based on the current directory
local server_address = "/tmp/nvim_" .. cwd:gsub("/", "_"):gsub("\\", "_")
local success = pcall(vim.fn.serverstart, server_address)
if not success then
-- print("Error: Unable to start Neovim server. The address '" .. server_address .. "' is already in use.")
else
print("Neovim is listening on: " .. server_address)
end