half spaces
parent
6484e98f92
commit
0ecc6c07ef
707
neovim/init.lua
707
neovim/init.lua
|
@ -7,7 +7,7 @@
|
||||||
-- - Harpoon marks: Navigate through main files within each project
|
-- - Harpoon marks: Navigate through main files within each project
|
||||||
--
|
--
|
||||||
-- REQUIREMENTS:
|
-- REQUIREMENTS:
|
||||||
-- - zk @ https://github.com/mickael-menu/zk
|
-- - zk @ https://github.com/mickael-menu/zk
|
||||||
-- - prettierd @ npm install -g @fsouza/prettierd
|
-- - prettierd @ npm install -g @fsouza/prettierd
|
||||||
|
|
||||||
-- Basic settings of vim
|
-- Basic settings of vim
|
||||||
|
@ -36,6 +36,7 @@ vim.opt.completeopt = 'menuone,noselect'
|
||||||
-- vim.opt.clipboard = "unnamedplus"
|
-- vim.opt.clipboard = "unnamedplus"
|
||||||
|
|
||||||
vim.g.mapleader = ' '
|
vim.g.mapleader = ' '
|
||||||
|
vim.g.maplocalleader = ','
|
||||||
|
|
||||||
-- basic keymaps
|
-- basic keymaps
|
||||||
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true }) -- since we're using space for leader
|
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true }) -- since we're using space for leader
|
||||||
|
@ -53,10 +54,11 @@ vim.keymap.set('n', '<leader>wq', '<cmd>TroubleToggle workspace_diagnostics<cr>'
|
||||||
|
|
||||||
|
|
||||||
-- vim-plug
|
-- vim-plug
|
||||||
|
local data_dir = vim.fn.stdpath('data')
|
||||||
vim.cmd([[
|
vim.cmd([[
|
||||||
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
|
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
|
||||||
if empty(glob(data_dir . '/autoload/plug.vim'))
|
if empty(glob(data_dir . '/autoload/plug.vim'))
|
||||||
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
|
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
|
||||||
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
|
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
|
||||||
endif
|
endif
|
||||||
]])
|
]])
|
||||||
|
@ -72,7 +74,7 @@ Plug('nvim-treesitter/nvim-treesitter') -- language parser engine for highlighti
|
||||||
Plug('nvim-treesitter/nvim-treesitter-textobjects') -- more text objects
|
Plug('nvim-treesitter/nvim-treesitter-textobjects') -- more text objects
|
||||||
Plug('nvim-telescope/telescope.nvim', { tag = '0.1.0' }) -- file browser
|
Plug('nvim-telescope/telescope.nvim', { tag = '0.1.0' }) -- file browser
|
||||||
Plug('nvim-telescope/telescope-fzf-native.nvim',
|
Plug('nvim-telescope/telescope-fzf-native.nvim',
|
||||||
{ ['do'] = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=release && cmake --build build --config Release && cmake --install build --prefix build' })
|
{ ['do'] = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=release && cmake --build build --config Release && cmake --install build --prefix build' })
|
||||||
Plug('nvim-telescope/telescope-file-browser.nvim')
|
Plug('nvim-telescope/telescope-file-browser.nvim')
|
||||||
|
|
||||||
-- cmp: auto-complete/suggestions
|
-- cmp: auto-complete/suggestions
|
||||||
|
@ -81,7 +83,7 @@ Plug('hrsh7th/cmp-nvim-lsp')
|
||||||
Plug('hrsh7th/cmp-buffer')
|
Plug('hrsh7th/cmp-buffer')
|
||||||
Plug('hrsh7th/nvim-cmp')
|
Plug('hrsh7th/nvim-cmp')
|
||||||
Plug('onsails/lspkind-nvim')
|
Plug('onsails/lspkind-nvim')
|
||||||
Plug('tzachar/cmp-tabnine', { ['do'] = './install.sh' })
|
-- Plug('tzachar/cmp-tabnine', { ['do'] = './install.sh' })
|
||||||
|
|
||||||
-- DevExp
|
-- DevExp
|
||||||
Plug('windwp/nvim-autopairs') -- matches pairs like [] (),...
|
Plug('windwp/nvim-autopairs') -- matches pairs like [] (),...
|
||||||
|
@ -95,6 +97,10 @@ Plug('williamboman/mason-lspconfig.nvim') -- lsp config for mason
|
||||||
Plug('ThePrimeagen/harpoon') -- 1-click through marked files per project
|
Plug('ThePrimeagen/harpoon') -- 1-click through marked files per project
|
||||||
Plug('TimUntersberger/neogit') -- Easy-to-see git status
|
Plug('TimUntersberger/neogit') -- Easy-to-see git status
|
||||||
Plug('folke/trouble.nvim') -- File-grouped workspace diagnostics
|
Plug('folke/trouble.nvim') -- File-grouped workspace diagnostics
|
||||||
|
Plug('tpope/vim-dispatch') -- Allows quick build/compile/test vim commands
|
||||||
|
Plug('clojure-vim/vim-jack-in') -- Clojure: ":Boot", ":Clj", ":Lein"
|
||||||
|
Plug('radenling/vim-dispatch-neovim') -- Add support for neovim's terminal emulator
|
||||||
|
Plug('Olical/conjure') -- REPL on the source for Clojure (and other LISPs)
|
||||||
|
|
||||||
-- UI & colorscheme
|
-- UI & colorscheme
|
||||||
Plug('gruvbox-community/gruvbox') -- theme provider
|
Plug('gruvbox-community/gruvbox') -- theme provider
|
||||||
|
@ -118,13 +124,13 @@ vim.call('plug#end')
|
||||||
vim.cmd([[ colorscheme gruvbox ]])
|
vim.cmd([[ colorscheme gruvbox ]])
|
||||||
require('hlargs').setup()
|
require('hlargs').setup()
|
||||||
require('shade').setup {
|
require('shade').setup {
|
||||||
overlay_opacity = 60,
|
overlay_opacity = 60,
|
||||||
opacity_step = 1,
|
opacity_step = 1,
|
||||||
keys = {
|
keys = {
|
||||||
brightness_up = '<C-Up>',
|
brightness_up = '<C-Up>',
|
||||||
brightness_down = '<C-Down>',
|
brightness_down = '<C-Down>',
|
||||||
toggle = '<Leader>s', -- s: sha
|
toggle = '<Leader>s', -- s: sha
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
require('nvim-web-devicons').setup()
|
require('nvim-web-devicons').setup()
|
||||||
require('trouble').setup()
|
require('trouble').setup()
|
||||||
|
@ -133,8 +139,8 @@ require('todo-comments').setup()
|
||||||
-- plugin keymaps
|
-- plugin keymaps
|
||||||
|
|
||||||
local function remap(mode, key_cmd, binded_fn, opts)
|
local function remap(mode, key_cmd, binded_fn, opts)
|
||||||
opts = opts or { remap = true }
|
opts = opts or { remap = true }
|
||||||
return vim.keymap.set(mode, key_cmd, binded_fn, opts)
|
return vim.keymap.set(mode, key_cmd, binded_fn, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Comment.nvim
|
-- Comment.nvim
|
||||||
|
@ -145,74 +151,74 @@ vim.opt.listchars:append "space:⋅"
|
||||||
vim.opt.listchars:append "eol:↴"
|
vim.opt.listchars:append "eol:↴"
|
||||||
|
|
||||||
require("indent_blankline").setup {
|
require("indent_blankline").setup {
|
||||||
show_end_of_line = true,
|
show_end_of_line = true,
|
||||||
space_char_blankline = " ",
|
space_char_blankline = " ",
|
||||||
}
|
}
|
||||||
-- User command that transform into 2-spaces by translating to tabstop
|
-- User command that transform into 2-spaces by translating to tabstop
|
||||||
vim.api.nvim_create_user_command(
|
vim.api.nvim_create_user_command(
|
||||||
'HalfSpaces',
|
'HalfSpaces',
|
||||||
function(opts)
|
function(opts)
|
||||||
vim.api.nvim_command("set ts=2 sts=2 noet")
|
vim.api.nvim_command("set ts=2 sts=2 noet")
|
||||||
vim.api.nvim_command("retab!")
|
vim.api.nvim_command("retab!")
|
||||||
vim.api.nvim_command("set ts=1 sts=1 et")
|
vim.api.nvim_command("set ts=1 sts=1 et")
|
||||||
vim.api.nvim_command("retab")
|
vim.api.nvim_command("retab")
|
||||||
vim.api.nvim_command("GuessIndent")
|
vim.api.nvim_command("GuessIndent")
|
||||||
end,
|
end,
|
||||||
{ nargs = 0 }
|
{ nargs = 0 }
|
||||||
)
|
)
|
||||||
vim.api.nvim_create_user_command(
|
vim.api.nvim_create_user_command(
|
||||||
'DoubleSpaces',
|
'DoubleSpaces',
|
||||||
function(opts)
|
function(opts)
|
||||||
vim.api.nvim_command("set ts=1 sts=1 noet")
|
vim.api.nvim_command("set ts=1 sts=1 noet")
|
||||||
vim.api.nvim_command("retab!")
|
vim.api.nvim_command("retab!")
|
||||||
vim.api.nvim_command("set ts=2 sts=2 et")
|
vim.api.nvim_command("set ts=2 sts=2 et")
|
||||||
vim.api.nvim_command("retab")
|
vim.api.nvim_command("retab")
|
||||||
vim.api.nvim_command("GuessIndent")
|
vim.api.nvim_command("GuessIndent")
|
||||||
end,
|
end,
|
||||||
{ nargs = 0 }
|
{ nargs = 0 }
|
||||||
)
|
)
|
||||||
|
|
||||||
-- telescope
|
-- telescope
|
||||||
local fb_actions = require "telescope".extensions.file_browser.actions
|
local fb_actions = require "telescope".extensions.file_browser.actions
|
||||||
require('telescope').setup {
|
require('telescope').setup {
|
||||||
defaults = {
|
defaults = {
|
||||||
mappings = {
|
mappings = {
|
||||||
i = {
|
i = {
|
||||||
['<C-u>'] = false,
|
['<C-u>'] = false,
|
||||||
['<C-d>'] = false,
|
['<C-d>'] = false,
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
},
|
||||||
extensions = {
|
},
|
||||||
fzf = {
|
extensions = {
|
||||||
fuzzy = true, -- allow fuzzy matches
|
fzf = {
|
||||||
override_generic_sorter = true,
|
fuzzy = true, -- allow fuzzy matches
|
||||||
override_file_sorter = true,
|
override_generic_sorter = true,
|
||||||
case_mode = 'smart_case'
|
override_file_sorter = true,
|
||||||
},
|
case_mode = 'smart_case'
|
||||||
file_browser = {
|
},
|
||||||
theme = "ivy",
|
file_browser = {
|
||||||
hiject_netrw = true, -- disables netrw and use file-browser instead
|
theme = "ivy",
|
||||||
mappings = {
|
hiject_netrw = true, -- disables netrw and use file-browser instead
|
||||||
["i"] = {}, -- disable any shortcut in insert mode for now
|
mappings = {
|
||||||
["n"] = {
|
["i"] = {}, -- disable any shortcut in insert mode for now
|
||||||
["c"] = fb_actions.create,
|
["n"] = {
|
||||||
["r"] = fb_actions.rename,
|
["c"] = fb_actions.create,
|
||||||
["m"] = fb_actions.move,
|
["r"] = fb_actions.rename,
|
||||||
["y"] = fb_actions.copy,
|
["m"] = fb_actions.move,
|
||||||
["d"] = fb_actions.remove,
|
["y"] = fb_actions.copy,
|
||||||
["o"] = fb_actions.open,
|
["d"] = fb_actions.remove,
|
||||||
["g"] = fb_actions.goto_parent_dir,
|
["o"] = fb_actions.open,
|
||||||
["e"] = fb_actions.goto_home_dir,
|
["g"] = fb_actions.goto_parent_dir,
|
||||||
["w"] = fb_actions.goto_cwd,
|
["e"] = fb_actions.goto_home_dir,
|
||||||
["t"] = fb_actions.change_cwd,
|
["w"] = fb_actions.goto_cwd,
|
||||||
["f"] = fb_actions.toggle_browser,
|
["t"] = fb_actions.change_cwd,
|
||||||
["h"] = fb_actions.toggle_hidden,
|
["f"] = fb_actions.toggle_browser,
|
||||||
["s"] = fb_actions.toggle_all,
|
["h"] = fb_actions.toggle_hidden,
|
||||||
}
|
["s"] = fb_actions.toggle_all,
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Telescope key remap stuffs
|
-- Telescope key remap stuffs
|
||||||
|
@ -221,116 +227,118 @@ pcall(require('telescope').load_extension, 'file_browser')
|
||||||
remap('n', '<C-p>', '<cmd>Telescope<cr>', { desc = 'Open Telescope general search' })
|
remap('n', '<C-p>', '<cmd>Telescope<cr>', { desc = 'Open Telescope general search' })
|
||||||
|
|
||||||
remap('n', '<leader>fm', function()
|
remap('n', '<leader>fm', function()
|
||||||
require("telescope").extensions.file_browser.file_browser()
|
require("telescope").extensions.file_browser.file_browser()
|
||||||
end, { desc = '[F]ile [M]utation' })
|
end, { desc = '[F]ile [M]utation' })
|
||||||
|
|
||||||
remap('n', '<leader>ff', function()
|
remap('n', '<leader>ff', function()
|
||||||
require('telescope.builtin').find_files({
|
require('telescope.builtin').find_files({
|
||||||
hidden = false,
|
hidden = false,
|
||||||
no_ignore = false,
|
no_ignore = false,
|
||||||
follow = false,
|
follow = false,
|
||||||
})
|
})
|
||||||
end, { desc = '[F]ind [F]ile' })
|
end, { desc = '[F]ind [F]ile' })
|
||||||
|
|
||||||
remap('n', '<leader>fa', function()
|
remap('n', '<leader>fa', function()
|
||||||
require('telescope.builtin').find_files({
|
require('telescope.builtin').find_files({
|
||||||
hidden = true,
|
hidden = true,
|
||||||
no_ignore = true,
|
no_ignore = true,
|
||||||
follow = true,
|
follow = true,
|
||||||
})
|
})
|
||||||
end, { desc = '[F]ind [A]ll files' })
|
end, { desc = '[F]ind [A]ll files' })
|
||||||
|
|
||||||
remap('n', '<leader>fg', function()
|
remap('n', '<leader>fg', function()
|
||||||
require('telescope.builtin').live_grep()
|
require('telescope.builtin').live_grep()
|
||||||
end, { desc = '[F]ind by [G]rep' })
|
end, { desc = '[F]ind by [G]rep' })
|
||||||
|
|
||||||
remap('n', '<leader>fb', function()
|
remap('n', '<leader>fb', function()
|
||||||
require('telescope.builtin').buffers()
|
require('telescope.builtin').buffers()
|
||||||
end, { desc = '[F]ind existing [B]uffers' })
|
end, { desc = '[F]ind existing [B]uffers' })
|
||||||
|
|
||||||
remap('n', '<leader>fh', function()
|
remap('n', '<leader>fh', function()
|
||||||
require('telescope.builtin').help_tags()
|
require('telescope.builtin').help_tags()
|
||||||
end, { desc = '[F]ind [H]elp' })
|
end, { desc = '[F]ind [H]elp' })
|
||||||
|
|
||||||
remap('n', '<leader>fd', function()
|
remap('n', '<leader>fd', function()
|
||||||
require('telescope.builtin').diagnostics()
|
require('telescope.builtin').diagnostics()
|
||||||
end, { desc = '[F]ind [D]iagnostics' })
|
end, { desc = '[F]ind [D]iagnostics' })
|
||||||
|
|
||||||
-- ZK remap stuffs
|
-- ZK remap stuffs
|
||||||
remap('n', '<leader>zf', function()
|
remap('n', '<leader>zf', function()
|
||||||
vim.cmd([[:ZkNotes]])
|
vim.cmd([[:ZkNotes]])
|
||||||
end, { desc = '[Z]ettelkasten [F]iles' })
|
end, { desc = '[Z]ettelkasten [F]iles' })
|
||||||
|
|
||||||
remap('n', '<leader>zg', function()
|
remap('n', '<leader>zg', function()
|
||||||
vim.cmd([[:ZkGrep]])
|
vim.cmd([[:ZkGrep]])
|
||||||
end, { desc = '[Z]ettelkasten [G]rep' })
|
end, { desc = '[Z]ettelkasten [G]rep' })
|
||||||
|
|
||||||
-- treesitter
|
-- treesitter
|
||||||
require('nvim-treesitter.configs').setup {
|
require('nvim-treesitter.configs').setup {
|
||||||
ensure_installed = {
|
ensure_installed = {
|
||||||
'tsx', 'toml', 'lua', 'typescript', 'rust', 'go', 'yaml', 'json', 'php', 'css',
|
'tsx', 'toml', 'lua', 'typescript', 'rust', 'go', 'yaml', 'json', 'php', 'css',
|
||||||
'python', 'prisma', 'html', "dockerfile", "c", "cpp", "hcl", "svelte", "astro",
|
'python', 'prisma', 'html', "dockerfile", "c", "cpp", "hcl", "svelte", "astro",
|
||||||
"clojure"
|
"clojure", "fennel"
|
||||||
},
|
},
|
||||||
sync_install = false,
|
sync_install = false,
|
||||||
highlight = { enable = true },
|
highlight = { enable = true },
|
||||||
indent = { enable = true },
|
indent = { enable = true },
|
||||||
incremental_selection = {
|
incremental_selection = {
|
||||||
enable = true,
|
enable = true,
|
||||||
keymaps = {
|
keymaps = {
|
||||||
init_selection = '<c-space>',
|
init_selection = '<c-space>',
|
||||||
node_incremental = '<c-space>',
|
node_incremental = '<c-space>',
|
||||||
node_decremental = '<c-backspace>',
|
node_decremental = '<c-backspace>',
|
||||||
scope_incremental = '<c-S>'
|
scope_incremental = '<c-S>'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
textobjects = {
|
textobjects = {
|
||||||
select = {
|
select = {
|
||||||
enable = true,
|
enable = true,
|
||||||
lookahead = true,
|
lookahead = true,
|
||||||
keymaps = {
|
keymaps = {
|
||||||
['af'] = '@function.outer',
|
['af'] = '@function.outer',
|
||||||
['if'] = '@function.inner',
|
['if'] = '@function.inner',
|
||||||
['ac'] = '@class.outer',
|
['ac'] = '@class.outer',
|
||||||
['ic'] = '@class.inner',
|
['ic'] = '@class.inner',
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
-- automatically close and modify HTML and TSX tags
|
|
||||||
autotag = {
|
|
||||||
enable = true,
|
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
-- automatically close and modify HTML and TSX tags
|
||||||
|
autotag = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
require('nvim-autopairs').setup {
|
require('nvim-autopairs').setup {
|
||||||
check_ts = true,
|
check_ts = true,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local parser_config = require('nvim-treesitter.parsers').get_parser_configs()
|
local parser_config = require('nvim-treesitter.parsers').get_parser_configs()
|
||||||
parser_config.tsx.filetype_to_parsername = { "javascript", "typescript.tsx" }
|
parser_config.tsx.filetype_to_parsername = { "javascript", "typescript.tsx" }
|
||||||
|
parser_config.astro.filetype_to_parsername = { "javascript", "typescript.tsx", "astro" }
|
||||||
|
|
||||||
|
|
||||||
require('guess-indent').setup {
|
require('guess-indent').setup {
|
||||||
auto_cmd = true, -- Set to false to disable automatic execution
|
auto_cmd = true, -- Set to false to disable automatic execution
|
||||||
filetype_exclude = { -- A list of filetypes for which the auto command gets disabled
|
filetype_exclude = { -- A list of filetypes for which the auto command gets disabled
|
||||||
"netrw",
|
"netrw",
|
||||||
"tutor",
|
"tutor",
|
||||||
},
|
},
|
||||||
buftype_exclude = { -- A list of buffer types for which the auto command gets disabled
|
buftype_exclude = { -- A list of buffer types for which the auto command gets disabled
|
||||||
"help",
|
"help",
|
||||||
"nofile",
|
"nofile",
|
||||||
"terminal",
|
"terminal",
|
||||||
-- "prompt",
|
-- "prompt",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- harpoon: mark significant files & switch between them
|
-- harpoon: mark significant files & switch between them
|
||||||
remap('n', '<leader>m', function() require('harpoon.mark').add_file() end)
|
remap('n', '<leader>m', function() require('harpoon.mark').add_file() end)
|
||||||
local function harpoon_nav(key, nav_file_index, lead_keybind)
|
local function harpoon_nav(key, nav_file_index, lead_keybind)
|
||||||
lead_keybind = lead_keybind or '<leader>h'
|
lead_keybind = lead_keybind or '<leader>h'
|
||||||
assert(type(key) == "string", "expect key to be string(keybind)")
|
assert(type(key) == "string", "expect key to be string(keybind)")
|
||||||
assert(type(nav_file_index) == "number" and nav_file_index >= 1, "expect 1-indexed number for file index")
|
assert(type(nav_file_index) == "number" and nav_file_index >= 1, "expect 1-indexed number for file index")
|
||||||
return remap('n', lead_keybind .. key, function() require('harpoon.ui').nav_file(nav_file_index) end)
|
return remap('n', lead_keybind .. key, function() require('harpoon.ui').nav_file(nav_file_index) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- remap letters to index. Inspired by alternating number of Dvorak programmer
|
-- remap letters to index. Inspired by alternating number of Dvorak programmer
|
||||||
|
@ -360,133 +368,146 @@ remap('n', '<leader>gs', function() require('neogit').open({}) end);
|
||||||
require('nvim-lsp-installer').setup {}
|
require('nvim-lsp-installer').setup {}
|
||||||
-- This function gets run when an LSP connects to a particular buffer.
|
-- This function gets run when an LSP connects to a particular buffer.
|
||||||
local on_attach = function(_client, bufnr)
|
local on_attach = function(_client, bufnr)
|
||||||
-- NOTE: Remember that lua is a real programming language, and as such it is possible
|
-- NOTE: Remember that lua is a real programming language, and as such it is possible
|
||||||
-- to define small helper and utility functions so you don't have to repeat yourself
|
-- to define small helper and utility functions so you don't have to repeat yourself
|
||||||
-- many times.
|
-- many times.
|
||||||
--
|
--
|
||||||
-- In this case, we create a function that lets us more easily define mappings specific
|
-- In this case, we create a function that lets us more easily define mappings specific
|
||||||
-- for LSP related items. It sets the mode, buffer and description for us each time.
|
-- for LSP related items. It sets the mode, buffer and description for us each time.
|
||||||
local nmap = function(keys, func, desc)
|
local nmap = function(keys, func, desc)
|
||||||
if desc then
|
if desc then
|
||||||
desc = 'LSP: ' .. desc
|
desc = 'LSP: ' .. desc
|
||||||
end
|
|
||||||
|
|
||||||
vim.keymap.set('n', keys, func, { noremap = true, buffer = bufnr, desc = desc })
|
|
||||||
end
|
end
|
||||||
|
|
||||||
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
vim.keymap.set('n', keys, func, { noremap = true, buffer = bufnr, desc = desc })
|
||||||
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
|
end
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
|
||||||
nmap('<leader>df', function() vim.lsp.buf.format({ async = true }) end, '[D]ocument [F]ormat')
|
|
||||||
|
|
||||||
-- symbols and gotos
|
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
||||||
nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
|
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
|
||||||
nmap('gi', vim.lsp.buf.implementation, '[G]oto [I]mplementation')
|
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||||
nmap('gr', require('telescope.builtin').lsp_references)
|
nmap('<leader>df', function() vim.lsp.buf.format({ async = true }) end, '[D]ocument [F]ormat')
|
||||||
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
|
|
||||||
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
|
||||||
|
|
||||||
-- documentations. See `:help K` for why this keymap
|
-- symbols and gotos
|
||||||
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
|
nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
|
||||||
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
|
nmap('gi', vim.lsp.buf.implementation, '[G]oto [I]mplementation')
|
||||||
|
nmap('gr', require('telescope.builtin').lsp_references)
|
||||||
|
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
|
||||||
|
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
||||||
|
|
||||||
-- Lesser used LSP functionality
|
-- documentations. See `:help K` for why this keymap
|
||||||
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
|
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
|
||||||
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
|
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
|
||||||
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
|
|
||||||
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
|
-- Lesser used LSP functionality
|
||||||
nmap('<leader>wl', function()
|
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
|
||||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
|
||||||
end, '[W]orkspace [L]ist Folders')
|
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
|
||||||
|
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
|
||||||
|
nmap('<leader>wl', function()
|
||||||
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||||
|
end, '[W]orkspace [L]ist Folders')
|
||||||
|
|
||||||
end
|
end
|
||||||
-- nvim-cmp supports additional completion capabilities
|
-- nvim-cmp supports additional completion capabilities
|
||||||
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
local tabnine = require('cmp_tabnine.config')
|
-- local tabnine = require('cmp_tabnine.config')
|
||||||
tabnine.setup({
|
-- tabnine.setup({
|
||||||
max_lines = 1000,
|
-- max_lines = 1000,
|
||||||
max_num_results = 20,
|
-- max_num_results = 20,
|
||||||
sort = true,
|
-- sort = true,
|
||||||
run_on_every_keystroke = true,
|
-- run_on_every_keystroke = true,
|
||||||
snippet_placeholder = '..',
|
-- snippet_placeholder = '..',
|
||||||
ignored_file_types = {},
|
-- ignored_file_types = {},
|
||||||
show_prediction_strength = true,
|
-- show_prediction_strength = true,
|
||||||
})
|
-- })
|
||||||
-- default language servers
|
-- default language servers
|
||||||
local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', 'cmake', 'tailwindcss', 'prismals',
|
local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', 'cmake', 'tailwindcss', 'prismals',
|
||||||
'rnix', 'eslint', 'terraform-ls', 'tflint', 'svelte', 'astro', 'clojure_lsp' }
|
'rnix', 'eslint', 'terraform-ls', 'tflint', 'svelte', 'astro', 'clojure_lsp' }
|
||||||
require("mason").setup({
|
require("mason").setup({
|
||||||
ui = {
|
ui = {
|
||||||
icons = {
|
icons = {
|
||||||
package_installed = "✓",
|
package_installed = "✓",
|
||||||
package_pending = "➜",
|
package_pending = "➜",
|
||||||
package_uninstalled = "✗"
|
package_uninstalled = "✗"
|
||||||
},
|
},
|
||||||
check_outdated_packages_on_open = true,
|
check_outdated_packages_on_open = true,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
require('mason-lspconfig').setup({
|
require('mason-lspconfig').setup({
|
||||||
ensure_installed = servers,
|
ensure_installed = servers,
|
||||||
automatic_installation = true
|
automatic_installation = true
|
||||||
})
|
})
|
||||||
require('mason-lspconfig').setup_handlers({
|
require('mason-lspconfig').setup_handlers({
|
||||||
-- default handler
|
-- default handler
|
||||||
function(server_name)
|
function(server_name)
|
||||||
require('lspconfig')[server_name].setup {
|
require('lspconfig')[server_name].setup {
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
["sumneko_lua"] = function()
|
["sumneko_lua"] = function()
|
||||||
require('lspconfig').sumneko_lua.setup {
|
require('lspconfig').sumneko_lua.setup {
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
runtime = {
|
runtime = {
|
||||||
version = "LuaJIT",
|
version = "LuaJIT",
|
||||||
path = vim.split(package.path, ";"),
|
path = vim.split(package.path, ";"),
|
||||||
},
|
},
|
||||||
diagnostics = {
|
diagnostics = {
|
||||||
globals = { "vim" }
|
globals = { "vim" }
|
||||||
},
|
},
|
||||||
workspace = {
|
workspace = {
|
||||||
library = vim.api.nvim_get_runtime_file('', true)
|
library = vim.api.nvim_get_runtime_file('', true)
|
||||||
},
|
},
|
||||||
telemetry = { enable = false },
|
telemetry = { enable = false },
|
||||||
format = {
|
format = {
|
||||||
enable = true,
|
enable = true,
|
||||||
defaultConfig = {
|
defaultConfig = {
|
||||||
indent_style = "space",
|
indent_style = "space",
|
||||||
indent_size = 2,
|
indent_size = 2,
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
end
|
}
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
-- ["astro"] = function()
|
||||||
|
-- print('configuring astro')
|
||||||
|
-- require('lspconfig').astro.setup {
|
||||||
|
-- on_attach = on_attach,
|
||||||
|
-- capabilities = capabilities,
|
||||||
|
-- init_options = {
|
||||||
|
-- configuration = {},
|
||||||
|
-- typescript = {
|
||||||
|
-- serverPath = data_dir
|
||||||
|
-- }
|
||||||
|
-- }
|
||||||
|
-- }
|
||||||
|
-- end
|
||||||
})
|
})
|
||||||
require('zk').setup({
|
require('zk').setup({
|
||||||
picker = "telescope",
|
picker = "telescope",
|
||||||
lsp = {
|
lsp = {
|
||||||
config = {
|
config = {
|
||||||
cmd = { "zk", "lsp" },
|
cmd = { "zk", "lsp" },
|
||||||
name = "zk",
|
name = "zk",
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
},
|
|
||||||
auto_attach = {
|
|
||||||
enable = true,
|
|
||||||
filetypes = { "markdown" }
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
auto_attach = {
|
||||||
|
enable = true,
|
||||||
|
filetypes = { "markdown" }
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Custom ZkOrphans that determines unlinked notes
|
-- Custom ZkOrphans that determines unlinked notes
|
||||||
-- `:ZkOrphans {tags = {"work"}}`
|
-- `:ZkOrphans {tags = {"work"}}`
|
||||||
require('zk.commands').add("ZkOrphans", function(options)
|
require('zk.commands').add("ZkOrphans", function(options)
|
||||||
options = vim.tbl_extend("force", { orphan = true }, options or {})
|
options = vim.tbl_extend("force", { orphan = true }, options or {})
|
||||||
-- zk.edit opens notes picker
|
-- zk.edit opens notes picker
|
||||||
require('zk').edit(options, { title = "Zk Orphans (unlinked notes)" })
|
require('zk').edit(options, { title = "Zk Orphans (unlinked notes)" })
|
||||||
end)
|
end)
|
||||||
-- ZkGrep: opens file picker
|
-- ZkGrep: opens file picker
|
||||||
-- In the case where `match_ctor` is falsy, create a prompt.
|
-- In the case where `match_ctor` is falsy, create a prompt.
|
||||||
|
@ -494,18 +515,18 @@ end)
|
||||||
-- Params:
|
-- Params:
|
||||||
-- match_ctor: string | {match= :string,...} | "" | nil
|
-- match_ctor: string | {match= :string,...} | "" | nil
|
||||||
require('zk.commands').add("ZkGrep", function(match_ctor)
|
require('zk.commands').add("ZkGrep", function(match_ctor)
|
||||||
-- handle polymorphic `match_ctor`
|
-- handle polymorphic `match_ctor`
|
||||||
local grep_str = match_ctor
|
local grep_str = match_ctor
|
||||||
local match
|
local match
|
||||||
if match_ctor == nil or match_ctor == '' then
|
if match_ctor == nil or match_ctor == '' then
|
||||||
vim.fn.inputsave()
|
vim.fn.inputsave()
|
||||||
grep_str = vim.fn.input('Grep string: >')
|
grep_str = vim.fn.input('Grep string: >')
|
||||||
vim.fn.inputrestore()
|
vim.fn.inputrestore()
|
||||||
match = { match = grep_str }
|
match = { match = grep_str }
|
||||||
elseif type(match_ctor) == 'string' then
|
elseif type(match_ctor) == 'string' then
|
||||||
match = { match = grep_str }
|
match = { match = grep_str }
|
||||||
end
|
end
|
||||||
require('zk').edit(match, { title = "Grep: '" .. grep_str .. "'" })
|
require('zk').edit(match, { title = "Grep: '" .. grep_str .. "'" })
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- nvim-cmp
|
-- nvim-cmp
|
||||||
|
@ -513,113 +534,113 @@ local cmp = require 'cmp'
|
||||||
local luasnip = require 'luasnip'
|
local luasnip = require 'luasnip'
|
||||||
local lspkind = require('lspkind')
|
local lspkind = require('lspkind')
|
||||||
local source_mapping = {
|
local source_mapping = {
|
||||||
buffer = '[Buffer]',
|
buffer = '[Buffer]',
|
||||||
nvim_lsp = '[LSP]',
|
nvim_lsp = '[LSP]',
|
||||||
nvim_lua = '[Lua]',
|
nvim_lua = '[Lua]',
|
||||||
cmp_tabnine = '[T9]',
|
-- cmp_tabnine = '[T9]',
|
||||||
path = '[Path]',
|
path = '[Path]',
|
||||||
}
|
}
|
||||||
|
|
||||||
cmp.setup {
|
cmp.setup {
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
luasnip.lsp_expand(args.body)
|
luasnip.lsp_expand(args.body)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
mapping = cmp.mapping.preset.insert {
|
mapping = cmp.mapping.preset.insert {
|
||||||
['<C-u>'] = cmp.mapping.scroll_docs(-4),
|
['<C-u>'] = cmp.mapping.scroll_docs(-4),
|
||||||
['<C-d>'] = cmp.mapping.scroll_docs(4),
|
['<C-d>'] = cmp.mapping.scroll_docs(4),
|
||||||
['<C-Space>'] = cmp.mapping.complete(),
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
['<CR>'] = cmp.mapping.confirm {
|
['<CR>'] = cmp.mapping.confirm {
|
||||||
behavior = cmp.ConfirmBehavior.Replace,
|
behavior = cmp.ConfirmBehavior.Replace,
|
||||||
select = true,
|
select = true,
|
||||||
},
|
|
||||||
['<Tab>'] = cmp.mapping(function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_next_item()
|
|
||||||
elseif luasnip.expand_or_jumpable() then
|
|
||||||
luasnip.expand_or_jump()
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { 'i', 's' }),
|
|
||||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_prev_item()
|
|
||||||
elseif luasnip.jumpable(-1) then
|
|
||||||
luasnip.jump(-1)
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { 'i', 's' }),
|
|
||||||
},
|
|
||||||
formatting = {
|
|
||||||
format = function(entry, vim_item)
|
|
||||||
vim_item.kind = lspkind.symbolic(vim_item.kind, { mode = 'symbol' })
|
|
||||||
vim_item.menu = source_mapping[entry.source_name]
|
|
||||||
if entry.source.name == "cmp_tabnine" then
|
|
||||||
local detail = (entry.completion_item.data or {}).detail
|
|
||||||
vim_item.kind = ""
|
|
||||||
if detail and detail:find('.*%%.*') then
|
|
||||||
vim_item.kind = vim_item.kind .. ' ' .. detail
|
|
||||||
end
|
|
||||||
|
|
||||||
if (entry.completion_item.data or {}).multiline then
|
|
||||||
vim_item.kind = vim_item.kind .. ' ' .. '[ML]'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local maxwidth = 80
|
|
||||||
vim_item.abbr = string.sub(vim_item.abbr, 1, maxwidth)
|
|
||||||
return vim_item
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
sources = {
|
|
||||||
{ name = 'nvim_lsp' },
|
|
||||||
{ name = 'luasnip' },
|
|
||||||
{ name = 'cmp_tabnine' },
|
|
||||||
},
|
},
|
||||||
|
['<Tab>'] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
elseif luasnip.expand_or_jumpable() then
|
||||||
|
luasnip.expand_or_jump()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { 'i', 's' }),
|
||||||
|
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
elseif luasnip.jumpable(-1) then
|
||||||
|
luasnip.jump(-1)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { 'i', 's' }),
|
||||||
|
},
|
||||||
|
formatting = {
|
||||||
|
format = function(entry, vim_item)
|
||||||
|
vim_item.kind = lspkind.symbolic(vim_item.kind, { mode = 'symbol' })
|
||||||
|
vim_item.menu = source_mapping[entry.source_name]
|
||||||
|
-- if entry.source.name == "cmp_tabnine" then
|
||||||
|
-- local detail = (entry.completion_item.data or {}).detail
|
||||||
|
-- vim_item.kind = ""
|
||||||
|
-- if detail and detail:find('.*%%.*') then
|
||||||
|
-- vim_item.kind = vim_item.kind .. ' ' .. detail
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- if (entry.completion_item.data or {}).multiline then
|
||||||
|
-- vim_item.kind = vim_item.kind .. ' ' .. '[ML]'
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
local maxwidth = 80
|
||||||
|
vim_item.abbr = string.sub(vim_item.abbr, 1, maxwidth)
|
||||||
|
return vim_item
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
sources = {
|
||||||
|
{ name = 'nvim_lsp' },
|
||||||
|
{ name = 'luasnip' },
|
||||||
|
-- { name = 'cmp_tabnine' },
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Gitsigns
|
-- Gitsigns
|
||||||
require('gitsigns').setup {
|
require('gitsigns').setup {
|
||||||
signs = {
|
signs = {
|
||||||
add = { text = '+' },
|
add = { text = '+' },
|
||||||
change = { text = '~' },
|
change = { text = '~' },
|
||||||
delete = { text = '_' },
|
delete = { text = '_' },
|
||||||
topdelete = { text = '‾' },
|
topdelete = { text = '‾' },
|
||||||
changedelete = { text = '~' },
|
changedelete = { text = '~' },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
require('lualine').setup {
|
require('lualine').setup {
|
||||||
options = {
|
options = {
|
||||||
icons_enabled = true,
|
icons_enabled = true,
|
||||||
},
|
},
|
||||||
sections = {
|
sections = {
|
||||||
lualine_a = { 'mode' },
|
lualine_a = { 'mode' },
|
||||||
lualine_b = { 'branch', 'diff', 'diagnostics' },
|
lualine_b = { 'branch', 'diff', 'diagnostics' },
|
||||||
lualine_c = {
|
lualine_c = {
|
||||||
{ 'filename',
|
{ 'filename',
|
||||||
file_status = true,
|
file_status = true,
|
||||||
newfile_status = false,
|
newfile_status = false,
|
||||||
path = 1,
|
path = 1,
|
||||||
symbols = {
|
symbols = {
|
||||||
modified = '[+]',
|
modified = '[+]',
|
||||||
readonly = '[-]',
|
readonly = '[-]',
|
||||||
unnamed = '[Unnamed]',
|
unnamed = '[Unnamed]',
|
||||||
newfile = '[New]',
|
newfile = '[New]',
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
lualine_x = { 'encoding', 'fileformat', 'filetype', },
|
},
|
||||||
lualine_y = { 'progress' },
|
|
||||||
lualine_z = { 'location' },
|
|
||||||
},
|
},
|
||||||
inactive_sections = {
|
lualine_x = { 'encoding', 'fileformat', 'filetype', },
|
||||||
lualine_a = {},
|
lualine_y = { 'progress' },
|
||||||
lualine_b = {},
|
lualine_z = { 'location' },
|
||||||
lualine_c = { { 'filename', path = 1, file_status = true, }, },
|
},
|
||||||
lualine_x = { 'location' },
|
inactive_sections = {
|
||||||
lualine_y = {},
|
lualine_a = {},
|
||||||
lualine_z = {},
|
lualine_b = {},
|
||||||
}
|
lualine_c = { { 'filename', path = 1, file_status = true, }, },
|
||||||
|
lualine_x = { 'location' },
|
||||||
|
lualine_y = {},
|
||||||
|
lualine_z = {},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue