Update config files to use stow
This commit is contained in:
6
nvim/.config/nvim/.stylua.toml
Normal file
6
nvim/.config/nvim/.stylua.toml
Normal file
@@ -0,0 +1,6 @@
|
||||
column_width = 160
|
||||
line_endings = "Unix"
|
||||
indent_type = "Spaces"
|
||||
indent_width = 2
|
||||
quote_style = "AutoPreferSingle"
|
||||
call_parentheses = "None"
|
||||
14
nvim/.config/nvim/init.lua
Normal file
14
nvim/.config/nvim/init.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
-- Set ',' as the leader key
|
||||
vim.g.mapleader = ','
|
||||
vim.g.maplocalleader = ','
|
||||
|
||||
-- Set to true if you have a Nerd Font installed and selected in the terminal
|
||||
vim.g.have_nerd_font = true
|
||||
|
||||
require 'options'
|
||||
require 'keymaps'
|
||||
|
||||
require 'config.lazy'
|
||||
require 'config.lsp'
|
||||
|
||||
vim.cmd.colorscheme 'catppuccin-mocha'
|
||||
12
nvim/.config/nvim/lazy-lock.json
Normal file
12
nvim/.config/nvim/lazy-lock.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"catppuccin": { "branch": "main", "commit": "beaf41a30c26fd7d6c386d383155cbd65dd554cd" },
|
||||
"conform.nvim": { "branch": "master", "commit": "c2526f1cde528a66e086ab1668e996d162c75f4f" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
|
||||
"neo-tree.nvim": { "branch": "main", "commit": "f3df514fff2bdd4318127c40470984137f87b62e" },
|
||||
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "746ffbb17975ebd6c40142362eee1b0249969c5c" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
|
||||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" },
|
||||
"telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
|
||||
"vimtex": { "branch": "master", "commit": "f707368022cdb851716be0d2970b90599c84a6a6" }
|
||||
}
|
||||
30
nvim/.config/nvim/lsp/lua_ls.lua
Normal file
30
nvim/.config/nvim/lsp/lua_ls.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
-- config for lua-language-server
|
||||
return {
|
||||
-- Command and arguments to start the server.
|
||||
cmd = { 'lua-language-server' },
|
||||
|
||||
-- Filetypes to automatically attach to.
|
||||
filetypes = { 'lua' },
|
||||
|
||||
-- Sets the "root directory" to the parent directory of the file in the
|
||||
-- current buffer that contains either a ".luarc.json" or a
|
||||
-- ".luarc.jsonc" file. Files that share a root directory will reuse
|
||||
-- the connection to the same LSP server.
|
||||
-- Nested lists indicate equal priority, see |vim.lsp.Config|.
|
||||
root_markers = { { '.luarc.json', '.luarc.jsonc' }, '.git' },
|
||||
|
||||
-- Specific settings to send to the server. The schema for this is
|
||||
-- defined by the server. For example the schema for lua-language-server
|
||||
-- can be found here https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
version = 'LuaJIT',
|
||||
},
|
||||
diagnostics = {
|
||||
-- Get the language server to recognize the `vim` global
|
||||
globals = { 'vim' },
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
59
nvim/.config/nvim/lsp/pyright.lua
Normal file
59
nvim/.config/nvim/lsp/pyright.lua
Normal file
@@ -0,0 +1,59 @@
|
||||
local function set_python_path(command)
|
||||
local path = command.args
|
||||
local clients = vim.lsp.get_clients {
|
||||
bufnr = vim.api.nvim_get_current_buf(),
|
||||
name = 'pyright',
|
||||
}
|
||||
for _, client in ipairs(clients) do
|
||||
if client.settings then
|
||||
client.settings.python = vim.tbl_deep_extend('force', client.settings.python, { pythonPath = path })
|
||||
else
|
||||
client.config.settings = vim.tbl_deep_extend('force', client.config.settings, { python = { pythonPath = path } })
|
||||
end
|
||||
client:notify('workspace/didChangeConfiguration', { settings = nil })
|
||||
end
|
||||
end
|
||||
|
||||
---@type vim.lsp.Config
|
||||
return {
|
||||
cmd = { 'pyright-langserver', '--stdio' },
|
||||
filetypes = { 'python' },
|
||||
root_markers = {
|
||||
'pyproject.toml',
|
||||
'setup.py',
|
||||
'setup.cfg',
|
||||
'requirements.txt',
|
||||
'Pipfile',
|
||||
'pyrightconfig.json',
|
||||
'.git',
|
||||
},
|
||||
settings = {
|
||||
python = {
|
||||
analysis = {
|
||||
autoSearchPaths = true,
|
||||
useLibraryCodeForTypes = true,
|
||||
diagnosticMode = 'openFilesOnly',
|
||||
},
|
||||
},
|
||||
},
|
||||
on_attach = function(client, bufnr)
|
||||
vim.api.nvim_buf_create_user_command(bufnr, 'LspPyrightOrganizeImports', function()
|
||||
local params = {
|
||||
command = 'pyright.organizeimports',
|
||||
arguments = { vim.uri_from_bufnr(bufnr) },
|
||||
}
|
||||
|
||||
-- Using client.request() directly because "pyright.organizeimports" is private
|
||||
-- (not advertised via capabilities), which client:exec_cmd() refuses to call.
|
||||
-- https://github.com/neovim/neovim/blob/c333d64663d3b6e0dd9aa440e433d346af4a3d81/runtime/lua/vim/lsp/client.lua#L1024-L1030
|
||||
client.request('workspace/executeCommand', params, nil, bufnr)
|
||||
end, {
|
||||
desc = 'Organize Imports',
|
||||
})
|
||||
vim.api.nvim_buf_create_user_command(bufnr, 'LspPyrightSetPythonPath', set_python_path, {
|
||||
desc = 'Reconfigure pyright with the provided python path',
|
||||
nargs = 1,
|
||||
complete = 'file',
|
||||
})
|
||||
end,
|
||||
}
|
||||
81
nvim/.config/nvim/lsp/ts_ls.lua
Normal file
81
nvim/.config/nvim/lsp/ts_ls.lua
Normal file
@@ -0,0 +1,81 @@
|
||||
return {
|
||||
init_options = { hostInfo = 'neovim' },
|
||||
cmd = { 'typescript-language-server', '--stdio' },
|
||||
filetypes = {
|
||||
'javascript',
|
||||
'javascriptreact',
|
||||
'javascript.jsx',
|
||||
'typescript',
|
||||
'typescriptreact',
|
||||
'typescript.tsx',
|
||||
},
|
||||
root_dir = function(bufnr, on_dir)
|
||||
-- The project root is where the LSP can be started from
|
||||
-- As stated in the documentation above, this LSP supports monorepos and simple projects.
|
||||
-- We select then from the project root, which is identified by the presence of a package
|
||||
-- manager lock file.
|
||||
local root_markers = { 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb', 'bun.lock' }
|
||||
-- Give the root markers equal priority by wrapping them in a table
|
||||
root_markers = vim.fn.has 'nvim-0.11.3' == 1 and { root_markers, { '.git' } } or vim.list_extend(root_markers, { '.git' })
|
||||
-- We fallback to the current working directory if no project root is found
|
||||
local project_root = vim.fs.root(bufnr, root_markers) or vim.fn.getcwd()
|
||||
|
||||
on_dir(project_root)
|
||||
end,
|
||||
handlers = {
|
||||
-- handle rename request for certain code actions like extracting functions / types
|
||||
['_typescript.rename'] = function(_, result, ctx)
|
||||
local client = assert(vim.lsp.get_client_by_id(ctx.client_id))
|
||||
vim.lsp.util.show_document({
|
||||
uri = result.textDocument.uri,
|
||||
range = {
|
||||
start = result.position,
|
||||
['end'] = result.position,
|
||||
},
|
||||
}, client.offset_encoding)
|
||||
vim.lsp.buf.rename()
|
||||
return vim.NIL
|
||||
end,
|
||||
},
|
||||
commands = {
|
||||
['editor.action.showReferences'] = function(command, ctx)
|
||||
local client = assert(vim.lsp.get_client_by_id(ctx.client_id))
|
||||
local file_uri, position, references = unpack(command.arguments)
|
||||
|
||||
local quickfix_items = vim.lsp.util.locations_to_items(references, client.offset_encoding)
|
||||
vim.fn.setqflist({}, ' ', {
|
||||
title = command.title,
|
||||
items = quickfix_items,
|
||||
context = {
|
||||
command = command,
|
||||
bufnr = ctx.bufnr,
|
||||
},
|
||||
})
|
||||
|
||||
vim.lsp.util.show_document({
|
||||
uri = file_uri,
|
||||
range = {
|
||||
start = position,
|
||||
['end'] = position,
|
||||
},
|
||||
}, client.offset_encoding)
|
||||
|
||||
vim.cmd 'botright copen'
|
||||
end,
|
||||
},
|
||||
on_attach = function(client, bufnr)
|
||||
-- ts_ls provides `source.*` code actions that apply to the whole file. These only appear in
|
||||
-- `vim.lsp.buf.code_action()` if specified in `context.only`.
|
||||
vim.api.nvim_buf_create_user_command(bufnr, 'LspTypescriptSourceAction', function()
|
||||
local source_actions = vim.tbl_filter(function(action)
|
||||
return vim.startswith(action, 'source.')
|
||||
end, client.server_capabilities.codeActionProvider.codeActionKinds)
|
||||
|
||||
vim.lsp.buf.code_action {
|
||||
context = {
|
||||
only = source_actions,
|
||||
},
|
||||
}
|
||||
end, {})
|
||||
end,
|
||||
}
|
||||
48
nvim/.config/nvim/lua/config/lazy.lua
Normal file
48
nvim/.config/nvim/lua/config/lazy.lua
Normal file
@@ -0,0 +1,48 @@
|
||||
-- Bootstrap lazy.nvim
|
||||
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
|
||||
local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
|
||||
if vim.v.shell_error ~= 0 then
|
||||
vim.api.nvim_echo({
|
||||
{ 'Failed to clone lazy.nvim:\n', 'ErrorMsg' },
|
||||
{ out, 'WarningMsg' },
|
||||
{ '\nPress any key to exit...' },
|
||||
}, true, {})
|
||||
vim.fn.getchar()
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
-- Setup lazy.nvim
|
||||
require('lazy').setup {
|
||||
spec = {
|
||||
-- import your plugins
|
||||
{ import = 'plugins' },
|
||||
},
|
||||
-- Configure any other settings here. See the documentation for more details.
|
||||
-- colorscheme that will be used when installing plugins.
|
||||
install = { colorscheme = { 'catppuccin-mocha' } },
|
||||
-- automatically check for plugin updates
|
||||
checker = { enabled = true, notify = false },
|
||||
ui = {
|
||||
-- If you are using a Nerd Font: set icons to an empty table which will use the
|
||||
-- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table
|
||||
icons = vim.g.have_nerd_font and {} or {
|
||||
cmd = '⌘',
|
||||
config = '🛠',
|
||||
event = '📅',
|
||||
ft = '📂',
|
||||
init = '⚙',
|
||||
keys = '🗝',
|
||||
plugin = '🔌',
|
||||
runtime = '💻',
|
||||
require = '🌙',
|
||||
source = '📄',
|
||||
start = '🚀',
|
||||
task = '📌',
|
||||
lazy = '💤 ',
|
||||
},
|
||||
},
|
||||
}
|
||||
30
nvim/.config/nvim/lua/config/lsp.lua
Normal file
30
nvim/.config/nvim/lua/config/lsp.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
-- enables LSPs and configures useful bindings
|
||||
|
||||
vim.lsp.enable 'lua_ls'
|
||||
vim.lsp.enable 'ts_ls'
|
||||
vim.lsp.enable 'pyright'
|
||||
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
callback = function(ev)
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_completion) then
|
||||
vim.opt.completeopt = { 'menu', 'menuone', 'noinsert', 'fuzzy', 'popup' }
|
||||
vim.lsp.completion.enable(true, client.id, ev.buf, { autotrigger = true })
|
||||
vim.keymap.set('i', '<C-Space>', function()
|
||||
vim.lsp.completion.get()
|
||||
end)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Diagnostics
|
||||
vim.diagnostic.config {
|
||||
-- Use the default configuration
|
||||
-- virtual_lines = true
|
||||
|
||||
-- Alternatively, customize specific options
|
||||
virtual_lines = {
|
||||
-- Only show virtual line diagnostics for the current cursor line
|
||||
current_line = true,
|
||||
},
|
||||
}
|
||||
18
nvim/.config/nvim/lua/keymaps.lua
Normal file
18
nvim/.config/nvim/lua/keymaps.lua
Normal file
@@ -0,0 +1,18 @@
|
||||
-- [[ Basic Keymaps ]]
|
||||
|
||||
-- Clear highlights on search when pressing <Esc> in normal mode
|
||||
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
|
||||
|
||||
-- Diagnostic keymaps
|
||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
|
||||
|
||||
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easie:
|
||||
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
|
||||
-- is not what someone will guess without a bit more experience.
|
||||
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
|
||||
|
||||
-- Keybinds to make split navigation easier.
|
||||
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
|
||||
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
|
||||
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
|
||||
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
|
||||
67
nvim/.config/nvim/lua/options.lua
Normal file
67
nvim/.config/nvim/lua/options.lua
Normal file
@@ -0,0 +1,67 @@
|
||||
-- [[ Setting options ]]
|
||||
-- See `:help vim.o`
|
||||
|
||||
-- Make line numbers default
|
||||
vim.o.relativenumber = true
|
||||
|
||||
-- Enable mouse mode, can be useful for resizing splits for example!
|
||||
vim.o.mouse = 'a'
|
||||
|
||||
-- Don't show the mode, since it's already in the status line
|
||||
vim.o.showmode = false
|
||||
|
||||
-- Sync clipboard between OS and Neovim.
|
||||
-- Schedule the setting after `UiEnter` because it can increase startup-time.
|
||||
-- Remove this option if you want your OS clipboard to remain independent.
|
||||
-- See `:help 'clipboard'`
|
||||
vim.schedule(function()
|
||||
vim.o.clipboard = 'unnamedplus'
|
||||
end)
|
||||
|
||||
-- Enable break indent
|
||||
vim.o.breakindent = true
|
||||
|
||||
-- Save undo history
|
||||
vim.o.undofile = true
|
||||
|
||||
-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
|
||||
vim.o.ignorecase = true
|
||||
vim.o.smartcase = true
|
||||
|
||||
-- Keep signcolumn on by default
|
||||
vim.o.signcolumn = 'yes'
|
||||
|
||||
-- Decrease update time
|
||||
vim.o.updatetime = 250
|
||||
|
||||
-- Decrease mapped sequence wait time
|
||||
vim.o.timeoutlen = 300
|
||||
|
||||
-- Configure how new splits should be opened
|
||||
vim.o.splitright = true
|
||||
vim.o.splitbelow = true
|
||||
|
||||
-- Sets how neovim will display certain whitespace characters in the editor.
|
||||
vim.o.list = true
|
||||
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }
|
||||
|
||||
-- Preview substitutions live, as you type!
|
||||
vim.o.inccommand = 'split'
|
||||
|
||||
-- Show which line your cursor is on
|
||||
vim.o.cursorline = true
|
||||
|
||||
-- Minimal number of screen lines to keep above and below the cursor.
|
||||
vim.o.scrolloff = 10
|
||||
|
||||
-- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`),
|
||||
-- instead raise a dialog asking if you wish to save the current file(s)
|
||||
-- See `:help 'confirm'`
|
||||
vim.o.confirm = true
|
||||
|
||||
-- default tab/space configuration
|
||||
vim.o.tabstop = 2
|
||||
vim.o.softtabstop = 2
|
||||
vim.o.shiftwidth = 2
|
||||
vim.o.expandtab = true
|
||||
|
||||
3
nvim/.config/nvim/lua/plugins/catppuccin.lua
Normal file
3
nvim/.config/nvim/lua/plugins/catppuccin.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
return {
|
||||
'catppuccin/nvim', name = 'catppuccin', priority = 1000
|
||||
}
|
||||
28
nvim/.config/nvim/lua/plugins/conform.lua
Normal file
28
nvim/.config/nvim/lua/plugins/conform.lua
Normal file
@@ -0,0 +1,28 @@
|
||||
return {
|
||||
{
|
||||
'stevearc/conform.nvim',
|
||||
opts = {
|
||||
formatters = {
|
||||
prettier_markdown = {
|
||||
command = 'prettier',
|
||||
args = {
|
||||
'--parser=markdown',
|
||||
'--prose-wrap',
|
||||
'always',
|
||||
'--print-width',
|
||||
'120',
|
||||
},
|
||||
},
|
||||
},
|
||||
formatters_by_ft = {
|
||||
lua = { 'stylua' },
|
||||
markdown = { 'prettier_markdown' },
|
||||
javascript = { 'prettier' },
|
||||
},
|
||||
format_on_save = {
|
||||
timeout_ms = 500,
|
||||
lsp_format = 'fallback',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
15
nvim/.config/nvim/lua/plugins/neotree.lua
Normal file
15
nvim/.config/nvim/lua/plugins/neotree.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
return {
|
||||
{
|
||||
"nvim-neo-tree/neo-tree.nvim",
|
||||
version = "*",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"MunifTanjim/nui.nvim",
|
||||
"nvim-tree/nvim-web-devicons", -- optional, but recommended
|
||||
},
|
||||
lazy = false, -- neo-tree will lazily load itself
|
||||
keys = {
|
||||
{ '<leader>d', ':Neotree toggle<CR>', desc = 'NeoTree toggle', silent = true }
|
||||
}
|
||||
}
|
||||
}
|
||||
46
nvim/.config/nvim/lua/plugins/telescope.lua
Normal file
46
nvim/.config/nvim/lua/plugins/telescope.lua
Normal file
@@ -0,0 +1,46 @@
|
||||
return {
|
||||
{
|
||||
'nvim-telescope/telescope.nvim',
|
||||
tag = '0.1.8',
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
{
|
||||
'nvim-telescope/telescope-fzf-native.nvim',
|
||||
build = 'make',
|
||||
config = function()
|
||||
require('telescope').load_extension 'fzf'
|
||||
end,
|
||||
},
|
||||
},
|
||||
keys = {
|
||||
{
|
||||
'<leader>t',
|
||||
function()
|
||||
require('telescope.builtin').find_files()
|
||||
end,
|
||||
desc = 'Find file',
|
||||
},
|
||||
{
|
||||
'<leader>f',
|
||||
function()
|
||||
require('telescope.builtin').live_grep()
|
||||
end,
|
||||
desc = 'Codesearch',
|
||||
},
|
||||
{
|
||||
'<leader>g',
|
||||
function()
|
||||
require('telescope.builtin').lsp_references()
|
||||
end,
|
||||
desc = 'View references',
|
||||
},
|
||||
},
|
||||
opts = {
|
||||
pickers = {
|
||||
lsp_references = {
|
||||
theme = 'ivy',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
12
nvim/.config/nvim/lua/plugins/vimtext.lua
Normal file
12
nvim/.config/nvim/lua/plugins/vimtext.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
return {
|
||||
'lervag/vimtex',
|
||||
lazy = false,
|
||||
ft = { 'tex', 'latex', 'bib' },
|
||||
init = function()
|
||||
vim.g.vimtex_view_method = 'zathura'
|
||||
vim.g.vimtex_compiler_method = 'latexmk'
|
||||
end,
|
||||
keys = {
|
||||
{ '<leader>r', '<cmd>VimtexCompile<cr>', desc = 'Compile LaTeX and view PDF', ft = 'tex' },
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user