Skip to content

Commit

Permalink
format neovim lua code
Browse files Browse the repository at this point in the history
  • Loading branch information
contrun committed Oct 2, 2024
1 parent c7ff643 commit 5c18ebe
Show file tree
Hide file tree
Showing 15 changed files with 948 additions and 948 deletions.
34 changes: 17 additions & 17 deletions dot_config/nvim/lua/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,36 @@ vim.cmd('command! MakeCTags !ctags -R [email protected] .')
vim.cmd('language en_US.utf8')

function SmallScreenModeToggle()
if vim.wo.number then
SmallScreenModeEnable()
else
SmallScreenModeDisable()
end
if vim.wo.number then
SmallScreenModeEnable()
else
SmallScreenModeDisable()
end
end

function SmallScreenModeEnable()
vim.wo.number = false
vim.wo.relativenumber = false
vim.wo.signcolumn = 'no'
vim.wo.number = false
vim.wo.relativenumber = false
vim.wo.signcolumn = 'no'
end

function SmallScreenModeDisable()
vim.wo.number = true
vim.wo.relativenumber = true
vim.wo.signcolumn = 'yes'
vim.wo.number = true
vim.wo.relativenumber = true
vim.wo.signcolumn = 'yes'
end

vim.api.nvim_create_user_command('SmallScreenModeToggle', SmallScreenModeToggle,
{
{
desc = 'Toggle small screen mode to enable/disable maximizied screen usage'
})
})

vim.api.nvim_create_user_command('SmallScreenModeEnable', SmallScreenModeEnable,
{
{
desc = 'Enable small screen mode to maximize screen usage'
})
})

vim.api.nvim_create_user_command('SmallScreenModeDisable',
SmallScreenModeDisable, {
SmallScreenModeDisable, {
desc = 'Disable small screen mode to allow some gaps'
})
})
12 changes: 6 additions & 6 deletions dot_config/nvim/lua/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ nnoremap("<leader>xo", "<Cmd> !xdg-open %<CR><CR>")
nnoremap("<leader>xr", "<Cmd>source $MYVIMRC<CR>")
nnoremap("<leader>xs", "<Cmd>SmallScreenModeToggle<CR>")
nnoremap("<leader>xc",
"<Cmd>silent !make -C ~/.local/share/chezmoi home-install<CR>")
"<Cmd>silent !make -C ~/.local/share/chezmoi home-install<CR>")
nnoremap("<leader>xp",
"<Cmd>silent !make -C ~/.local/share/chezmoi home-install<CR><Cmd>PackerSync<CR>")
"<Cmd>silent !make -C ~/.local/share/chezmoi home-install<CR><Cmd>PackerSync<CR>")
nnoremap("<leader>xP", "<Cmd>PackerSync<CR>")

nnoremap("<leader>gg", "<Cmd>Neogit<CR>")

-- Show line diagnostics
nnoremap("<leader>d",
'<Cmd>lua vim.diagnostic.open_float(0, {scope = "line"})<CR>')
'<Cmd>lua vim.diagnostic.open_float(0, {scope = "line"})<CR>')

-- Open local diagnostics in local list
nnoremap("<leader>D", "<Cmd>lua vim.diagnostic.setloclist()<CR>")
Expand Down Expand Up @@ -119,16 +119,16 @@ nnoremap("<leader>dd", "<Cmd>lua require('dapui').toggle()<CR>")
nnoremap("<leader>dv", "<Cmd>DapVirtualTextToggle<CR>")
vnoremap("<leader>de", "<Cmd>lua require('dapui').eval()<CR>")
nnoremap("<leader>de",
"<Cmd>lua require('dapui').eval(vim.fn.input '[Expression] > ')<CR>")
"<Cmd>lua require('dapui').eval(vim.fn.input '[Expression] > ')<CR>")
nnoremap("<leader>dc", "<Cmd>lua require'dap'.continue()<CR>")
nnoremap("<leader>dso", "<Cmd>lua require'dap'.step_over()<CR>")
nnoremap("<leader>dsi", "<Cmd>lua require'dap'.step_into()<CR>")
nnoremap("<leader>dst", "<Cmd>lua require'dap'.step_out()<CR>")
nnoremap("<leader>db", "<Cmd>lua require'dap'.toggle_breakpoint()<CR>")
nnoremap("<leader>dB",
"<Cmd>lua require'dap'.toggle_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>")
"<Cmd>lua require'dap'.toggle_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>")
nnoremap("<leader>dl",
"<Cmd>lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))<CR>")
"<Cmd>lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))<CR>")
nnoremap("<leader>dr", "<Cmd>lua require'dap'.repl.toggle()<CR>")
nnoremap("<leader>dR", "<Cmd>lua require'dap'.run_last()<CR>")
nnoremap("<leader>dt", "<Cmd>lua require'dap'.terminate()<CR>")
Expand Down
28 changes: 14 additions & 14 deletions dot_config/nvim/lua/lsp/sumneko.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@ local common_on_attach = require('lsp.utils').common_on_attach

local system_name
if fn.has('mac') == 1 then
system_name = 'macOS'
system_name = 'macOS'
elseif fn.has('unix') == 1 then
system_name = 'Linux'
system_name = 'Linux'
elseif fn.has('win32') == 1 then
system_name = 'Windows'
system_name = 'Windows'
else
print('Unsuported system for sumneko')
print('Unsuported system for sumneko')
end

local runtime_path = vim.split(package.path, ';')
table.insert(runtime_path, "lua/?.lua")
table.insert(runtime_path, "lua/?/init.lua")

require'lspconfig'.lua_ls.setup {
settings = {
Lua = {
runtime = {version = 'LuaJIT', path = runtime_path},
diagnostics = {globals = {'vim'}},
workspace = {library = vim.api.nvim_get_runtime_file("", true)},
telemetry = {enable = false}
}
},
on_attach = common_on_attach
require 'lspconfig'.lua_ls.setup {
settings = {
Lua = {
runtime = { version = 'LuaJIT', path = runtime_path },
diagnostics = { globals = { 'vim' } },
workspace = { library = vim.api.nvim_get_runtime_file("", true) },
telemetry = { enable = false }
}
},
on_attach = common_on_attach
}
88 changes: 44 additions & 44 deletions dot_config/nvim/lua/lsp/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,50 @@ cmd([[autocmd ColorScheme * highlight FloatBorder guifg=white guibg=#1f2335]])

-- This function defines the on_attach function for several languages which share the same key-bidings
function M.common_on_attach(client, bufnr)
-- Set omnifunc
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")

-- Helper function
local opts = {noremap = false, silent = true}
local function bufnnoremap(lhs, rhs)
vim.api.nvim_buf_set_keymap(bufnr, 'n', lhs, rhs, opts)
end

bufnnoremap("gd", "<Cmd>lua vim.lsp.buf.definition()<CR>")
bufnnoremap("gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>")
bufnnoremap("gi", "<Cmd>Telescope lsp_implementations<CR>")

-- List symbol uses
-- bufnnoremap("gr", "<cmd>lua vim.lsp.buf.references()<CR>") -- Uses quickfix
bufnnoremap("gr", "<cmd>Telescope lsp_references<CR>") -- Uses Telescope
bufnnoremap("gR", "<Cmd>lua vim.lsp.buf.rename()<CR>")
bufnnoremap("K", "<Cmd>lua vim.lsp.buf.hover()<CR>")
bufnnoremap("<C-k>", "<Cmd>lua vim.lsp.buf.signature_help()<CR>")

bufnnoremap('<leader>lw', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>')
bufnnoremap('<leader>lr',
'<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>')
bufnnoremap('<leader>lW',
'<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>')
bufnnoremap('<leader>lv', '<cmd>Vista nvim_lsp<CR>')
bufnnoremap('<leader>lt', '<cmd>lua vim.lsp.buf.type_definition()<CR>')
bufnnoremap('<leader>la', '<cmd>lua vim.lsp.buf.code_action()<CR>')
bufnnoremap('<leader>le', '<cmd>lua vim.diagnostic.open_float()<CR>')
bufnnoremap('[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>')
bufnnoremap(']d', '<cmd>lua vim.diagnostic.goto_next()<CR>')
bufnnoremap('<leader>lq', '<cmd>lua vim.diagnostic.setloclist()<CR>')
bufnnoremap("<leader>ls", "<cmd>Telescope lsp_document_symbols<CR>")
bufnnoremap("<leader>l/", "<cmd>Telescope lsp_workspace_symbols<CR>")

-- https://github.com/neovim/neovim/issues/21391
if client.name == "omnisharp" then
client.server_capabilities.semanticTokensProvider.legend = {
tokenModifiers = { "static" },
tokenTypes = { "comment", "excluded", "identifier", "keyword", "keyword", "number", "operator", "operator", "preprocessor", "string", "whitespace", "text", "static", "preprocessor", "punctuation", "string", "string", "class", "delegate", "enum", "interface", "module", "struct", "typeParameter", "field", "enumMember", "constant", "local", "parameter", "method", "method", "property", "event", "namespace", "label", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "regexp", "regexp", "regexp", "regexp", "regexp", "regexp", "regexp", "regexp", "regexp" }
}
end

require"lsp-format".on_attach(client)
-- Set omnifunc
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")

-- Helper function
local opts = { noremap = false, silent = true }
local function bufnnoremap(lhs, rhs)
vim.api.nvim_buf_set_keymap(bufnr, 'n', lhs, rhs, opts)
end

bufnnoremap("gd", "<Cmd>lua vim.lsp.buf.definition()<CR>")
bufnnoremap("gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>")
bufnnoremap("gi", "<Cmd>Telescope lsp_implementations<CR>")

-- List symbol uses
-- bufnnoremap("gr", "<cmd>lua vim.lsp.buf.references()<CR>") -- Uses quickfix
bufnnoremap("gr", "<cmd>Telescope lsp_references<CR>") -- Uses Telescope
bufnnoremap("gR", "<Cmd>lua vim.lsp.buf.rename()<CR>")
bufnnoremap("K", "<Cmd>lua vim.lsp.buf.hover()<CR>")
bufnnoremap("<C-k>", "<Cmd>lua vim.lsp.buf.signature_help()<CR>")

bufnnoremap('<leader>lw', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>')
bufnnoremap('<leader>lr',
'<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>')
bufnnoremap('<leader>lW',
'<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>')
bufnnoremap('<leader>lv', '<cmd>Vista nvim_lsp<CR>')
bufnnoremap('<leader>lt', '<cmd>lua vim.lsp.buf.type_definition()<CR>')
bufnnoremap('<leader>la', '<cmd>lua vim.lsp.buf.code_action()<CR>')
bufnnoremap('<leader>le', '<cmd>lua vim.diagnostic.open_float()<CR>')
bufnnoremap('[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>')
bufnnoremap(']d', '<cmd>lua vim.diagnostic.goto_next()<CR>')
bufnnoremap('<leader>lq', '<cmd>lua vim.diagnostic.setloclist()<CR>')
bufnnoremap("<leader>ls", "<cmd>Telescope lsp_document_symbols<CR>")
bufnnoremap("<leader>l/", "<cmd>Telescope lsp_workspace_symbols<CR>")

-- https://github.com/neovim/neovim/issues/21391
if client.name == "omnisharp" then
client.server_capabilities.semanticTokensProvider.legend = {
tokenModifiers = { "static" },
tokenTypes = { "comment", "excluded", "identifier", "keyword", "keyword", "number", "operator", "operator", "preprocessor", "string", "whitespace", "text", "static", "preprocessor", "punctuation", "string", "string", "class", "delegate", "enum", "interface", "module", "struct", "typeParameter", "field", "enumMember", "constant", "local", "parameter", "method", "method", "property", "event", "namespace", "label", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "xml", "regexp", "regexp", "regexp", "regexp", "regexp", "regexp", "regexp", "regexp", "regexp" }
}
end

require "lsp-format".on_attach(client)
end

return M
18 changes: 9 additions & 9 deletions dot_config/nvim/lua/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ vim.o.conceallevel = 0 -- Don't hide quotes in markdown
vim.o.cmdheight = 1
vim.o.pumheight = 10
vim.o.showmode = false
vim.o.showtabline = 0 -- Never show tabline
vim.o.showtabline = 0 -- Never show tabline
vim.o.title = true
vim.o.termguicolors = true -- Use true colors, required for some plugins
vim.wo.number = true
Expand All @@ -18,8 +18,8 @@ vim.opt_global.shortmess:remove("F")
-- Behaviour
vim.o.whichwrap = 'b,s,h,l,<,>,[,]' -- wrap left/right key to previouse/next line
vim.o.hlsearch = false
vim.o.ignorecase = true -- Ignore case when using lowercase in search
vim.o.smartcase = true -- But don't ignore it when using upper case
vim.o.ignorecase = true -- Ignore case when using lowercase in search
vim.o.smartcase = true -- But don't ignore it when using upper case
vim.o.smarttab = true
vim.o.smartindent = true
vim.o.expandtab = true -- Convert tabs to spaces.
Expand All @@ -39,21 +39,21 @@ vim.o.spell = false
vim.o.spelllang = "en_us"
vim.o.completeopt = "menuone,noinsert,noselect"
vim.o.wildmode = "longest,full" -- Display auto-complete in Command Mode
vim.o.updatetime = 300 -- Delay until write to Swap and HoldCommand event
vim.o.updatetime = 300 -- Delay until write to Swap and HoldCommand event

-- Disable default plugins
-- vim.g.loaded_netrwPlugin = false

-- Disable inline error messages
vim.diagnostic.config {
virtual_text = true,
underline = true, -- Keep error underline
signs = true -- Keep gutter signs
virtual_text = true,
underline = true, -- Keep error underline
signs = true -- Keep gutter signs
}

if vim.fn.has('persistent_undo') == 1 then
vim.o.undofile = true
vim.o.undodir = vim.fn.stdpath('data') .. '/undo//'
vim.o.undofile = true
vim.o.undodir = vim.fn.stdpath('data') .. '/undo//'
end

vim.o.clipboard = vim.o.clipboard .. 'unnamedplus'
Loading

0 comments on commit 5c18ebe

Please sign in to comment.