mirror of
https://github.com/Ajetski/dotfiles.git
synced 2025-09-30 09:33:19 -09:00
improve commenting and svelte highlighting
This commit is contained in:
parent
cd550d4949
commit
e035f71725
@ -6,61 +6,71 @@ vim.opt.ignorecase = true
|
|||||||
vim.o.mouse = "a"
|
vim.o.mouse = "a"
|
||||||
vim.o.number = true
|
vim.o.number = true
|
||||||
vim.o.relativenumber = true
|
vim.o.relativenumber = true
|
||||||
vim.o.wrap = true -- wrap lines
|
vim.o.wrap = true -- wrap lines
|
||||||
vim.o.encoding = "UTF-8" -- set encoding to UTF-8 (default was "latin1")
|
vim.o.encoding = "UTF-8" -- set encoding to UTF-8 (default was "latin1")
|
||||||
vim.o.wildmenu = true -- visual autocomplete for command menu
|
vim.o.wildmenu = true -- visual autocomplete for command menu
|
||||||
vim.o.lazyredraw = true -- redraw screen only when we need to
|
vim.o.lazyredraw = true -- redraw screen only when we need to
|
||||||
vim.o.showmatch = true -- highlight matching parentheses / brackets [{()}]
|
vim.o.showmatch = true -- highlight matching parentheses / brackets [{()}]
|
||||||
vim.o.laststatus = 2 -- always show statusline (even with only single window)
|
vim.o.laststatus = 2 -- always show statusline (even with only single window)
|
||||||
vim.o.ruler = true -- show line and column number of the cursor on right side of statusline
|
vim.o.ruler = true -- show line and column number of the cursor on right side of statusline
|
||||||
vim.o.visualbell = true -- blink cursor on error, instead of beeping
|
vim.o.visualbell = true -- blink cursor on error, instead of beeping
|
||||||
vim.cmd('set invlist')
|
|
||||||
vim.api.nvim_set_var("toggle_syntax_state", true)
|
vim.api.nvim_set_var("toggle_syntax_state", true)
|
||||||
|
|
||||||
-- Plugins
|
-- Plugins
|
||||||
local Plug = vim.fn['plug#']
|
local Plug = vim.fn['plug#']
|
||||||
vim.call('plug#begin', '~/.config/nvim/plugged')
|
vim.call('plug#begin', '~/.config/nvim/plugged')
|
||||||
-- Editor basics and navigation
|
-- Editor basics and navigation
|
||||||
Plug 'tpope/vim-sensible' -- some good default configs, we love tpope :)
|
Plug 'tpope/vim-sensible' -- some good default configs, we love tpope :)
|
||||||
Plug 'tpope/vim-surround' -- add surround motion (s), example: to change the surrounding double quotes to single quotes type: cs"'
|
Plug 'tpope/vim-surround' -- add surround motion (s), example: to change the surrounding double quotes to single quotes type: cs"'
|
||||||
Plug('scrooloose/nerdtree', {on = {'NERDTreeToggle', 'NERDTree'}}) -- file browser
|
Plug 'tpope/vim-repeat'
|
||||||
Plug 'junegunn/goyo.vim' -- zen mode
|
Plug('scrooloose/nerdtree', { on = { 'NERDTreeToggle', 'NERDTree' } }) -- file browser
|
||||||
Plug('junegunn/fzf', {['do'] = vim.fn['fzf#install']})
|
Plug 'junegunn/goyo.vim' -- zen mode
|
||||||
Plug('nvim-treesitter/nvim-treesitter', {['do'] = vim.fn['TSUpdate']}) -- add support for text objects
|
Plug('junegunn/fzf', { ['do'] = vim.fn['fzf#install'] })
|
||||||
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
|
Plug('nvim-treesitter/nvim-treesitter', { ['do'] = vim.fn['TSUpdate'] }) -- add support for text objects
|
||||||
-- Plug 'ctrlpvim/ctrlp.vim' -- minimal fuzzyfinder
|
Plug 'JoosepAlviste/nvim-ts-context-commentstring'
|
||||||
Plug 'wadackel/vim-dogrun' -- colorscheme
|
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
|
||||||
Plug 'tribela/vim-transparent' -- clear background
|
-- Plug 'ctrlpvim/ctrlp.vim' -- minimal fuzzyfinder
|
||||||
Plug 'nvim-lua/plenary.nvim' -- testing framework, required for telescope
|
Plug 'wadackel/vim-dogrun' -- colorscheme
|
||||||
Plug 'nvim-telescope/telescope.nvim' -- fancy fuzzyfinder
|
Plug 'tribela/vim-transparent' -- clear background
|
||||||
Plug('nvim-telescope/telescope-fzf-native.nvim', { ['do'] = 'make' }) -- faster fzf
|
Plug 'nvim-lua/plenary.nvim' -- testing framework, required for telescope
|
||||||
Plug 'nvim-telescope/telescope-file-browser.nvim'
|
Plug 'nvim-telescope/telescope.nvim' -- fancy fuzzyfinder
|
||||||
Plug 'glepnir/dashboard-nvim'
|
Plug('nvim-telescope/telescope-fzf-native.nvim', { ['do'] = 'make' }) -- faster fzf
|
||||||
|
Plug 'nvim-telescope/telescope-file-browser.nvim'
|
||||||
|
Plug 'nvim-telescope/telescope-ui-select.nvim'
|
||||||
|
Plug 'glepnir/dashboard-nvim'
|
||||||
|
Plug 'kshenoy/vim-signature'
|
||||||
|
Plug 'phaazon/hop.nvim'
|
||||||
|
Plug 'terrortylor/nvim-comment'
|
||||||
|
|
||||||
-- Git Integration
|
-- Git Integration
|
||||||
Plug 'airblade/vim-gitgutter'
|
Plug 'airblade/vim-gitgutter'
|
||||||
|
|
||||||
-- LSP
|
-- LSP
|
||||||
Plug "williamboman/nvim-lsp-installer"
|
Plug "williamboman/nvim-lsp-installer"
|
||||||
Plug 'neovim/nvim-lspconfig'
|
Plug 'neovim/nvim-lspconfig'
|
||||||
Plug 'hrsh7th/cmp-nvim-lsp'
|
Plug 'hrsh7th/cmp-nvim-lsp'
|
||||||
Plug 'hrsh7th/cmp-buffer'
|
Plug 'hrsh7th/cmp-buffer'
|
||||||
Plug 'hrsh7th/cmp-path'
|
Plug 'hrsh7th/cmp-path'
|
||||||
Plug 'hrsh7th/cmp-cmdline'
|
Plug 'hrsh7th/cmp-cmdline'
|
||||||
Plug 'hrsh7th/nvim-cmp'
|
Plug 'hrsh7th/nvim-cmp'
|
||||||
Plug 'saadparwaiz1/cmp_luasnip' -- Snippets source for nvim-cmp
|
Plug 'saadparwaiz1/cmp_luasnip' -- Snippets source for nvim-cmp
|
||||||
Plug 'L3MON4D3/LuaSnip' -- Snippets plugin
|
Plug 'L3MON4D3/LuaSnip' -- Snippets plugin
|
||||||
|
|
||||||
-- Airline
|
-- Debugger
|
||||||
Plug 'vim-airline/vim-airline'
|
Plug 'mfussenegger/nvim-dap'
|
||||||
Plug 'vim-airline/vim-airline-themes'
|
Plug 'rcarriga/nvim-dap-ui'
|
||||||
|
|
||||||
-- Lang Support
|
-- Airline
|
||||||
Plug 'sheerun/vim-polyglot'
|
Plug 'vim-airline/vim-airline'
|
||||||
Plug 'evanleck/vim-svelte'
|
Plug 'vim-airline/vim-airline-themes'
|
||||||
Plug 'pantharshit00/vim-prisma'
|
|
||||||
Plug 'simrat39/rust-tools.nvim'
|
-- Lang Support
|
||||||
--Plug 'pangloss/vim-javascript'
|
Plug 'sheerun/vim-polyglot'
|
||||||
|
Plug 'pantharshit00/vim-prisma'
|
||||||
|
Plug 'simrat39/rust-tools.nvim'
|
||||||
|
Plug 'othree/html5.vim'
|
||||||
|
Plug 'pangloss/vim-javascript'
|
||||||
|
Plug('evanleck/vim-svelte', { ['branch'] = 'main' })
|
||||||
vim.call('plug#end')
|
vim.call('plug#end')
|
||||||
|
|
||||||
-- set colorscheme
|
-- set colorscheme
|
||||||
@ -74,14 +84,37 @@ vim.cmd("let g:airline#extensions#tabline#left_alt_sep = '|'")
|
|||||||
vim.cmd("let g:airline_theme='night_owl'")
|
vim.cmd("let g:airline_theme='night_owl'")
|
||||||
vim.cmd("let g:airline_section_y = '%{strftime(\"%H:%M\")}'")
|
vim.cmd("let g:airline_section_y = '%{strftime(\"%H:%M\")}'")
|
||||||
|
|
||||||
|
|
||||||
|
-- setup svelte
|
||||||
|
vim.cmd("let g:svelte_preprocessor_tags = [ { 'name': 'ts', 'tag': 'script', 'as': 'typescript' } ]")
|
||||||
|
vim.cmd("let g:svelte_preprocessors = ['ts']")
|
||||||
|
|
||||||
-- setup TreeSitter
|
-- setup TreeSitter
|
||||||
require'nvim-treesitter.configs'.setup {
|
require 'nvim-treesitter.configs'.setup {
|
||||||
ensure_installed = "all",
|
ensure_installed = "all",
|
||||||
sync_install = false
|
sync_install = false,
|
||||||
|
context_commentstring = {
|
||||||
|
enable = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- setup comments
|
||||||
|
require('nvim_comment').setup({
|
||||||
|
hook = function()
|
||||||
|
if vim.api.nvim_buf_get_option(0, "filetype") == "svelte" then
|
||||||
|
require("ts_context_commentstring.internal").update_commentstring()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
-- setup hop
|
||||||
|
require 'hop'.setup {}
|
||||||
|
|
||||||
|
-- setup comments
|
||||||
|
require('nvim_comment').setup()
|
||||||
|
|
||||||
-- setup dashboard
|
-- setup dashboard
|
||||||
local home = os.getenv('HOME')
|
local home = os.getenv('HOME')
|
||||||
local db = require('dashboard')
|
local db = require('dashboard')
|
||||||
db.preview_command = 'cat | lolcat -v 2'
|
db.preview_command = 'cat | lolcat -v 2'
|
||||||
db.preview_file_path = home .. '/.config/nvim/static/neovim.bold'
|
db.preview_file_path = home .. '/.config/nvim/static/neovim.bold'
|
||||||
@ -91,9 +124,15 @@ db.session_directory = home .. '/.sessions'
|
|||||||
db.custom_center = {
|
db.custom_center = {
|
||||||
{
|
{
|
||||||
icon = '🕑 ',
|
icon = '🕑 ',
|
||||||
desc = 'Recently latest session ',
|
desc = 'Open Most Recent Session ',
|
||||||
shortcut = '<leader>sl',
|
shortcut = '<leader>sl',
|
||||||
action ='SessionLoad'
|
action = 'SessionLoad'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon = '🕑 ',
|
||||||
|
desc = 'Open Default Layout Session ',
|
||||||
|
shortcut = '<leader>sd',
|
||||||
|
action = 'source ~/.sessions/default_layout.vim'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon = '🔍 ',
|
icon = '🔍 ',
|
||||||
@ -104,7 +143,7 @@ db.custom_center = {
|
|||||||
{
|
{
|
||||||
icon = '🌲 ',
|
icon = '🌲 ',
|
||||||
desc = 'File Browser ',
|
desc = 'File Browser ',
|
||||||
action = 'Telescope file_browser',
|
action = 'Telescope file_browser',
|
||||||
shortcut = '<leader>fb'
|
shortcut = '<leader>fb'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -115,34 +154,82 @@ db.custom_center = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- luasnip setup
|
-- snippets setup
|
||||||
local luasnip = require 'luasnip'
|
local ls = require 'luasnip'
|
||||||
|
local s = ls.s
|
||||||
|
local i = ls.insert_node
|
||||||
|
local t = ls.text_node
|
||||||
|
local fmt = require('luasnip.extras.fmt').fmt
|
||||||
|
|
||||||
|
ls.add_snippets("svelte", {
|
||||||
|
s("component-svelte", {
|
||||||
|
t { '<script lang="ts">', '\t' },
|
||||||
|
i(1, '// Typescript Goes Here'),
|
||||||
|
t { '', '</script>', '', '<main>', '\t' },
|
||||||
|
i(2, '<!-- HTML Goes Here-->'),
|
||||||
|
t { '', '</main>', '', '<style>', '\t' },
|
||||||
|
i(3, '/* CSS Goes Here */'),
|
||||||
|
t { '', '</style>', '' }
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
local has_words_before = function()
|
||||||
|
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||||
|
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local cmp = require 'cmp'
|
||||||
|
if not cmp then
|
||||||
|
vim.cmd("echo Error cmp not found")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local cmp = require'cmp'
|
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
luasnip.lsp_expand(args.body)
|
ls.lsp_expand(args.body)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
window = {},
|
window = {},
|
||||||
mapping = cmp.mapping.preset.insert({
|
mapping = cmp.mapping.preset.insert({
|
||||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
|
||||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
|
||||||
['<C-Space>'] = cmp.mapping.complete(),
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
['<tab>'] = cmp.mapping.select_next_item(),
|
['<Tab>'] = cmp.mapping.select_next_item(),
|
||||||
|
['<S-Tab>'] = cmp.mapping.select_prev_item(),
|
||||||
['<C-e>'] = cmp.mapping.abort(),
|
['<C-e>'] = cmp.mapping.abort(),
|
||||||
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||||
|
["<C-j>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
elseif ls.expand_or_jumpable() then
|
||||||
|
ls.expand_or_jump()
|
||||||
|
elseif has_words_before() then
|
||||||
|
cmp.complete()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
|
||||||
|
["<C-k>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
elseif ls.jumpable(-1) then
|
||||||
|
ls.jump(-1)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { "i", "s" }),
|
||||||
}),
|
}),
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = 'nvim_lsp' },
|
{ name = 'nvim_lsp' },
|
||||||
|
{ name = 'luasnip' },
|
||||||
}, {
|
}, {
|
||||||
{ name = 'buffer' }
|
{ name = 'buffer' },
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
-- setup LSP
|
-- setup LSP
|
||||||
local opts = { noremap=true, silent=true }
|
local opts = { noremap = true, silent = true }
|
||||||
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
|
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
|
||||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
||||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
||||||
@ -150,33 +237,35 @@ vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
|
|||||||
|
|
||||||
-- Use an on_attach function to only map the following keys
|
-- Use an on_attach function to only map the following keys
|
||||||
-- after the language server attaches to the current buffer
|
-- after the language server attaches to the current buffer
|
||||||
local on_attach = function(client, bufnr)
|
local on_attach = function(_, bufnr)
|
||||||
-- Enable completion triggered by <c-x><c-o>
|
-- Enable completion triggered by <c-x><c-o>
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||||
|
|
||||||
-- Mappings.
|
-- Mappings.
|
||||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||||
local bufopts = { noremap=true, silent=true, buffer=bufnr }
|
local bufopts = { noremap = true, silent = true, buffer = bufnr }
|
||||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
||||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
||||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
|
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
|
||||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
||||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
|
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
|
||||||
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
|
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
|
||||||
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
|
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
|
||||||
vim.keymap.set('n', '<space>wl', function()
|
vim.keymap.set('n', '<space>wl', function()
|
||||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||||
end, bufopts)
|
end, bufopts)
|
||||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
|
vim.keymap.set('n', 'gy', vim.lsp.buf.type_definition, bufopts)
|
||||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
|
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
|
||||||
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
|
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, { silent = true, buffer = bufnr })
|
||||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
||||||
vim.keymap.set('n', '<space>f', vim.lsp.buf.formatting, bufopts)
|
vim.keymap.set('n', '<space>F', vim.lsp.buf.formatting, bufopts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Auto-exit if it is the last buffer open
|
||||||
vim.api.nvim_create_autocmd(
|
vim.api.nvim_create_autocmd(
|
||||||
{ "BufEnter" },
|
{ "BufEnter" },
|
||||||
{ pattern = { "*" }, command = "if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif" }
|
{ pattern = { "*" },
|
||||||
|
command = "if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif" }
|
||||||
)
|
)
|
||||||
|
|
||||||
require("nvim-lsp-installer").setup {
|
require("nvim-lsp-installer").setup {
|
||||||
@ -203,24 +292,45 @@ lspconfig.sumneko_lua.setup {
|
|||||||
},
|
},
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
}
|
}
|
||||||
lspconfig.tsserver.setup{
|
lspconfig.tsserver.setup {
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
}
|
}
|
||||||
require('rust-tools').setup{
|
require('rust-tools').setup {
|
||||||
tools = { -- rust-tools options
|
tools = { -- rust-tools options
|
||||||
|
executor = require("rust-tools/executors").termopen,
|
||||||
|
on_initialized = nil,
|
||||||
|
reload_workspace_from_cargo_toml = true,
|
||||||
autoSetHints = true,
|
autoSetHints = true,
|
||||||
hover_with_actions = true,
|
hover_with_actions = false,
|
||||||
runnables = {
|
hover_actions = {
|
||||||
use_telescope = true
|
border = {
|
||||||
|
{ "╭", "FloatBorder" },
|
||||||
|
{ "─", "FloatBorder" },
|
||||||
|
{ "╮", "FloatBorder" },
|
||||||
|
{ "│", "FloatBorder" },
|
||||||
|
{ "╯", "FloatBorder" },
|
||||||
|
{ "─", "FloatBorder" },
|
||||||
|
{ "╰", "FloatBorder" },
|
||||||
|
{ "│", "FloatBorder" },
|
||||||
|
},
|
||||||
|
auto_focus = true,
|
||||||
},
|
},
|
||||||
inlay_hints = {
|
inlay_hints = {
|
||||||
show_parameter_hints = false,
|
show_parameter_hints = true,
|
||||||
parameter_hints_prefix = "",
|
parameter_hints_prefix = "<- ",
|
||||||
other_hints_prefix = "",
|
other_hints_prefix = "=> ",
|
||||||
|
current_line_only = false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
server = {
|
server = {
|
||||||
on_attach = on_attach,
|
on_attach = function(_, buffnr)
|
||||||
|
on_attach(_, buffnr)
|
||||||
|
local bufopts = { silent = true, buffer = buffnr }
|
||||||
|
vim.keymap.set('n', '<leader>ca', ':RustCodeAction<cr>', bufopts)
|
||||||
|
vim.keymap.set('n', '<leader>K', ':RustHoverActions<cr>', bufopts)
|
||||||
|
vim.keymap.set('n', '<leader>R', ':RustRunnables<cr>', bufopts)
|
||||||
|
vim.keymap.set('n', '<leader>D', ':RustDebuggables<cr>', bufopts)
|
||||||
|
end,
|
||||||
settings = {
|
settings = {
|
||||||
["rust-analyzer"] = {
|
["rust-analyzer"] = {
|
||||||
checkOnSave = {
|
checkOnSave = {
|
||||||
@ -228,9 +338,16 @@ require('rust-tools').setup{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
dap = {
|
||||||
|
adapter = {
|
||||||
|
type = "executable",
|
||||||
|
command = "lldb-vscode",
|
||||||
|
name = "rt_lldb",
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
require('lspconfig')['svelte'].setup{
|
require('lspconfig')['svelte'].setup {
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,13 +371,72 @@ telescope.setup({
|
|||||||
})
|
})
|
||||||
telescope.load_extension('file_browser')
|
telescope.load_extension('file_browser')
|
||||||
telescope.load_extension('fzf')
|
telescope.load_extension('fzf')
|
||||||
|
telescope.load_extension("ui-select")
|
||||||
|
|
||||||
|
-- Debugger
|
||||||
|
local dap = require('dap')
|
||||||
|
require("dapui").setup({
|
||||||
|
icons = { expanded = "▾", collapsed = "▸" },
|
||||||
|
mappings = {
|
||||||
|
expand = { "<CR>", "<2-LeftMouse>" },
|
||||||
|
open = "o",
|
||||||
|
remove = "d",
|
||||||
|
edit = "e",
|
||||||
|
repl = "r",
|
||||||
|
toggle = "t",
|
||||||
|
},
|
||||||
|
expand_lines = vim.fn.has("nvim-0.7"),
|
||||||
|
layouts = {
|
||||||
|
{
|
||||||
|
elements = {
|
||||||
|
{ id = "scopes", size = 0.25 },
|
||||||
|
"breakpoints",
|
||||||
|
"stacks",
|
||||||
|
"watches",
|
||||||
|
},
|
||||||
|
size = 40, -- 40 columns
|
||||||
|
position = "left",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
elements = {
|
||||||
|
"repl",
|
||||||
|
"console",
|
||||||
|
},
|
||||||
|
size = 0.25, -- 25% of total lines
|
||||||
|
position = "bottom",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
floating = {
|
||||||
|
max_height = nil, -- These can be integers or a float between 0 and 1.
|
||||||
|
max_width = nil, -- Floats will be treated as percentage of your screen.
|
||||||
|
border = "single", -- Border style. Can be "single", "double" or "rounded"
|
||||||
|
mappings = {
|
||||||
|
close = { "q", "<Esc>" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
windows = { indent = 1 },
|
||||||
|
render = {
|
||||||
|
max_type_length = nil, -- Can be integer or nil.
|
||||||
|
}
|
||||||
|
})
|
||||||
|
local dapui = require("dapui")
|
||||||
|
dap.listeners.after.event_initialized["dapui_config"] = function()
|
||||||
|
dapui.open {}
|
||||||
|
end
|
||||||
|
dap.listeners.before.event_terminated["dapui_config"] = function()
|
||||||
|
dapui.close {}
|
||||||
|
end
|
||||||
|
dap.listeners.before.event_exited["dapui_config"] = function()
|
||||||
|
dapui.close {}
|
||||||
|
end
|
||||||
|
|
||||||
-- keymaps
|
-- keymaps
|
||||||
local loud_opts = { noremap=true }
|
local loud_opts = { noremap = true }
|
||||||
vim.keymap.set("n", "<c-s>", ":wa<cr>:echo 'File saved.'<cr>", loud_opts)
|
vim.keymap.set("n", "<c-s>", ":wa<cr>:echo 'File saved.'<cr>", loud_opts)
|
||||||
vim.keymap.set("n", "<c-t>", ":NERDTreeToggle<cr>", opts)
|
vim.keymap.set("n", "<c-t>", ":NERDTreeToggle<cr>", opts)
|
||||||
vim.keymap.set("n", "<leader>tt", ":TransparentToggle<cr>", opts)
|
vim.keymap.set("n", "<leader>tt", ":TransparentToggle<cr>", opts)
|
||||||
vim.keymap.set("n", "<leader>tz", ":Goyo 150<cr>", opts)
|
vim.keymap.set("n", "<leader>tzz", ":Goyo<cr>", opts)
|
||||||
|
vim.keymap.set("n", "<leader>tzw", ":Goyo 160<cr>", opts)
|
||||||
vim.keymap.set("n", "<leader>tr", ":set relativenumber!<cr>")
|
vim.keymap.set("n", "<leader>tr", ":set relativenumber!<cr>")
|
||||||
vim.keymap.set("n", "<leader>ti", ":set invlist!<cr>")
|
vim.keymap.set("n", "<leader>ti", ":set invlist!<cr>")
|
||||||
vim.keymap.set("n", "gt", ":bn<cr>", opts)
|
vim.keymap.set("n", "gt", ":bn<cr>", opts)
|
||||||
@ -268,11 +444,12 @@ vim.keymap.set("n", "gT", ":bp<cr>", opts)
|
|||||||
vim.keymap.set("n", "<cr>", ":nohlsearch<cr><cr>", opts)
|
vim.keymap.set("n", "<cr>", ":nohlsearch<cr><cr>", opts)
|
||||||
vim.keymap.set("n", "<leader>ff", ":Telescope find_files<cr>", opts)
|
vim.keymap.set("n", "<leader>ff", ":Telescope find_files<cr>", opts)
|
||||||
vim.keymap.set('n', '<leader>fk', ':Telescope keymaps<cr>', opts)
|
vim.keymap.set('n', '<leader>fk', ':Telescope keymaps<cr>', opts)
|
||||||
vim.keymap.set('n', '<leader>fb', ':Telescope file_browser<cr>', opts)
|
vim.keymap.set('n', '<leader>fB', ':Telescope file_browser<cr>', opts)
|
||||||
|
vim.keymap.set('n', '<leader>fb', ':Telescope buffers<cr>', opts)
|
||||||
vim.keymap.set("n", "<c-p>", ":Telescope git_files<cr>", opts)
|
vim.keymap.set("n", "<c-p>", ":Telescope git_files<cr>", opts)
|
||||||
vim.keymap.set("n", "<leader>fc", ":Telescope git<cr>")
|
vim.keymap.set("n", "<leader>fc", ":Telescope git<cr>")
|
||||||
vim.keymap.set("n", "<leader>fg", ":Telescope live_grep<cr>", opts)
|
vim.keymap.set("n", "<leader>fg", ":Telescope live_grep<cr>", opts)
|
||||||
vim.keymap.set("n", "<leader>fbc", ":Telescope git_bcommits<cr>", opts)
|
vim.keymap.set("n", "<leader>fC", ":Telescope git_bcommits<cr>", opts)
|
||||||
vim.keymap.set("n", "<leader>fc", ":Telescope git_commits<cr>", opts)
|
vim.keymap.set("n", "<leader>fc", ":Telescope git_commits<cr>", opts)
|
||||||
vim.keymap.set("i", "<f1>", "", opts)
|
vim.keymap.set("i", "<f1>", "", opts)
|
||||||
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, opts)
|
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, opts)
|
||||||
@ -280,10 +457,32 @@ vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
|||||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
||||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, opts)
|
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, opts)
|
||||||
vim.keymap.set("n", "<cr>", ":nohlsearch<cr>", opts)
|
vim.keymap.set("n", "<cr>", ":nohlsearch<cr>", opts)
|
||||||
vim.keymap.set("n", "]h", "<Plug>(GitGutterNextHunk)")
|
vim.keymap.set("n", "]h", "<Plug>(GitGutterNextHunk)", opts)
|
||||||
vim.keymap.set("n", "[h", "<Plug>(GitGutterPrevHunk)")
|
vim.keymap.set("n", "[h", "<Plug>(GitGutterPrevHunk)", opts)
|
||||||
vim.keymap.set("n", "<leader>gd", ":GitGutterDiffOrig<cr>")
|
vim.keymap.set("n", "<leader>gd", ":GitGutterDiffOrig<cr>", opts)
|
||||||
vim.keymap.set("n", "<leader>gf", ":GitGutterFold<cr>")
|
vim.keymap.set("n", "<leader>gf", ":GitGutterFold<cr>", opts)
|
||||||
vim.keymap.set("n", "<leader>sl", ":SessionLoad<cr>")
|
vim.keymap.set("n", "<leader>sl", ":SessionLoad<cr><cr>", opts)
|
||||||
vim.keymap.set("n", "<leader>ss", ":SessionSave<cr>")
|
vim.keymap.set("n", "<leader>ss", ":SessionSave<cr><cr>", opts)
|
||||||
|
vim.keymap.set("n", "<leader>cb", ":%bd|e#<cr>:echo closed all other buffers<cr>", loud_opts)
|
||||||
|
vim.keymap.set("n", "<leader>P", ":!yarn format<cr>")
|
||||||
|
vim.keymap.set("n", "<leader>R", ":source ~/.config/nvim/init.lua<cr>")
|
||||||
|
vim.api.nvim_set_keymap('', 'f',
|
||||||
|
"<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.AFTER_CURSOR, current_line_only = true })<cr>"
|
||||||
|
, {})
|
||||||
|
vim.api.nvim_set_keymap('', 'F',
|
||||||
|
"<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.BEFORE_CURSOR, current_line_only = true })<cr>"
|
||||||
|
, {})
|
||||||
|
vim.api.nvim_set_keymap('', 't',
|
||||||
|
"<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.AFTER_CURSOR, current_line_only = true, hint_offset = -1 })<cr>"
|
||||||
|
, {})
|
||||||
|
vim.api.nvim_set_keymap('', 'T',
|
||||||
|
"<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.BEFORE_CURSOR, current_line_only = true, hint_offset = 1 })<cr>"
|
||||||
|
, {})
|
||||||
|
vim.keymap.set("n", "gw", ":HopWord<cr>", opts);
|
||||||
|
vim.keymap.set("n", "gh", ":HopWordCurrentLine<cr>", opts)
|
||||||
|
vim.keymap.set("n", "gl", ":HopLine<cr>", opts)
|
||||||
|
vim.keymap.set("n", "<leader>B", dap.toggle_breakpoint)
|
||||||
|
vim.keymap.set("n", "<f3>", dap.continue)
|
||||||
|
vim.keymap.set("n", "<f4>", dap.step_into)
|
||||||
|
vim.keymap.set("n", "<f5>", dap.step_over)
|
||||||
|
vim.keymap.set("t", "<esc>", "<C-\\><C-n>", opts)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user